X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vlib%2Fvlib%2Fthreads.h;h=e65794cfb6b05d22a34797ac9fd2572ce3ac40ab;hb=9876520f9ba746ed4d9923f392911c4f1888a105;hp=5773ed05a6254edadd7d4ece3bcdbb37caccbdc0;hpb=42f2006975c5a0ea58c835df4461213072f8813f;p=vpp.git diff --git a/vlib/vlib/threads.h b/vlib/vlib/threads.h index 5773ed05a62..e65794cfb6b 100644 --- a/vlib/vlib/threads.h +++ b/vlib/vlib/threads.h @@ -16,31 +16,34 @@ #define included_vlib_threads_h #include +#include vlib_main_t **vlib_mains; -void -vlib_set_thread_name (char *name); +void vlib_set_thread_name (char *name); /* arg is actually a vlib__thread_t * */ -typedef void (vlib_thread_function_t) (void * arg); +typedef void (vlib_thread_function_t) (void *arg); -typedef struct vlib_thread_registration_ { +typedef struct vlib_thread_registration_ +{ /* constructor generated list of thread registrations */ - struct vlib_thread_registration_ * next; + struct vlib_thread_registration_ *next; /* config parameters */ - char * name; - char * short_name; - vlib_thread_function_t * function; + char *name; + char *short_name; + vlib_thread_function_t *function; uword mheap_size; int fixed_count; u32 count; int no_data_structure_clone; + u32 frame_queue_nelts; + /* All threads of this type run on pthreads */ int use_pthreads; u32 first_index; - uword * coremask; + uword *coremask; } vlib_thread_registration_t; /* @@ -48,25 +51,29 @@ typedef struct vlib_thread_registration_ { * Make VLIB_MAX_CPUS a power-of-two, please... */ +#ifndef VLIB_MAX_CPUS #define VLIB_MAX_CPUS 256 +#endif #if VLIB_MAX_CPUS > CLIB_MAX_MHEAPS #error Please increase number of per-cpu mheaps #endif -#define VLIB_CPU_MASK (VLIB_MAX_CPUS - 1) /* 0x3f, max */ +#define VLIB_CPU_MASK (VLIB_MAX_CPUS - 1) /* 0x3f, max */ #define VLIB_OFFSET_MASK (~VLIB_CPU_MASK) #define VLIB_LOG2_THREAD_STACK_SIZE (20) #define VLIB_THREAD_STACK_SIZE (1< 0) { - if (os_get_cpu_number()) - fformat(stderr, "%s: SMP unsafe warning...\n", __FUNCTION__); + if (os_get_cpu_number ()) + fformat (stderr, "%s: SMP unsafe warning...\n", __FUNCTION__); } } -typedef enum { - VLIB_WORKER_THREAD_FORK_FIXUP_ILLEGAL = 0, - VLIB_WORKER_THREAD_FORK_FIXUP_NEW_SW_IF_INDEX, +typedef enum +{ + VLIB_WORKER_THREAD_FORK_FIXUP_ILLEGAL = 0, + VLIB_WORKER_THREAD_FORK_FIXUP_NEW_SW_IF_INDEX, } vlib_fork_fixup_t; void vlib_worker_thread_fork_fixup (vlib_fork_fixup_t which); -static inline void vlib_worker_thread_barrier_check (void) +static inline void +vlib_worker_thread_barrier_check (void) { - if (PREDICT_FALSE(*vlib_worker_threads->wait_at_barrier)) + if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier)) { - clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1); - while (*vlib_worker_threads->wait_at_barrier) - ; - clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1); + clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1); + while (*vlib_worker_threads->wait_at_barrier) + ; + clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1); } } @@ -240,32 +249,46 @@ do { \ #define VLIB_EFD_DEF_WORKER_HI_THRESH_PCT 90 /* EFD worker thread settings */ -typedef struct vlib_efd_t { +typedef struct vlib_efd_t +{ u16 enabled; u16 queue_hi_thresh; - u8 ip_prec_bitmap; - u8 mpls_exp_bitmap; - u8 vlan_cos_bitmap; - u8 pad; + u8 ip_prec_bitmap; + u8 mpls_exp_bitmap; + u8 vlan_cos_bitmap; + u8 pad; } vlib_efd_t; -typedef struct { +#define foreach_sched_policy \ + _(SCHED_OTHER, OTHER, "other") \ + _(SCHED_BATCH, BATCH, "batch") \ + _(SCHED_IDLE, IDLE, "idle") \ + _(SCHED_FIFO, FIFO, "fifo") \ + _(SCHED_RR, RR, "rr") + +typedef enum +{ +#define _(v,f,s) SCHED_POLICY_##f = v, + foreach_sched_policy +#undef _ + SCHED_POLICY_N, +} sched_policy_t; + +typedef struct +{ /* Link list of registrations, built by constructors */ - vlib_thread_registration_t * next; - - /* Vector of registrations, w/ non-data-structure clones at the top */ - vlib_thread_registration_t ** registrations; + vlib_thread_registration_t *next; - uword * thread_registrations_by_name; + /* Vector of registrations, w/ non-data-structure clones at the top */ + vlib_thread_registration_t **registrations; - vlib_worker_thread_t * worker_threads; + uword *thread_registrations_by_name; - /* thread / cpu / io thread parameters */ - u32 main_thread_is_io_node; + vlib_worker_thread_t *worker_threads; - /* - * Launch all threads as pthreads, - * not eal_rte_launch (strict affinity) threads + /* + * Launch all threads as pthreads, + * not eal_rte_launch (strict affinity) threads */ int use_pthreads; @@ -291,13 +314,29 @@ typedef struct { u8 main_lcore; /* Bitmap of available CPU cores */ - uword * cpu_core_bitmap; + uword *cpu_core_bitmap; /* Bitmap of available CPU sockets (NUMA nodes) */ - uword * cpu_socket_bitmap; + uword *cpu_socket_bitmap; vlib_efd_t efd; - + + /* handoff node index */ + u32 handoff_dispatch_node_index; + + /* for frame queue tracing */ + frame_queue_trace_t *frame_queue_traces; + frame_queue_nelt_counter_t *frame_queue_histogram; + + /* worker thread initialization barrier */ + volatile u32 worker_thread_release; + + /* scheduling policy */ + u32 sched_policy; + + /* scheduling policy priority */ + u32 sched_priority; + } vlib_thread_main_t; vlib_thread_main_t vlib_thread_main; @@ -312,6 +351,14 @@ static void __vlib_add_thread_registration_##x (void) \ x.next = tm->next; \ tm->next = &x; \ } \ -__VA_ARGS__ vlib_thread_registration_t x +__VA_ARGS__ vlib_thread_registration_t x #endif /* included_vlib_threads_h */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */