* cds_lfht: Top-level data structure representing a lock-free hash
* table. Defined in the implementation file to make it be an opaque
* cookie to users.
+ *
+ * The fields used in fast-paths are placed near the end of the
+ * structure, because we need to have a variable-sized union to contain
+ * the mm plugin fields, which are used in the fast path.
*/
struct cds_lfht {
- unsigned long size; /* always a power of 2, shared (RCU) */
- int flags;
+ /* Initial configuration items */
+ unsigned long max_nr_buckets;
+ const struct cds_lfht_mm_type *mm; /* memory management plugin */
+ const struct rcu_flavor_struct *flavor; /* RCU flavor */
+
+ long count; /* global approximate item count */
/*
* We need to put the work threads offline (QSBR) when taking this
unsigned int in_progress_resize, in_progress_destroy;
unsigned long resize_target;
int resize_initiated;
- const struct rcu_flavor_struct *flavor;
-
- long count; /* global approximate item count */
- struct ht_items_count *split_count; /* split item count */
-
- /* memory management related fields are located at the end */
- const struct cds_lfht_mm_type *mm;
+ /*
+ * Variables needed for add and remove fast-paths.
+ */
+ int flags;
unsigned long min_alloc_buckets_order;
unsigned long min_nr_alloc_buckets;
- unsigned long max_nr_buckets;
+ struct ht_items_count *split_count; /* split item count */
+ /*
+ * Variables needed for the lookup, add and remove fast-paths.
+ */
+ unsigned long size; /* always a power of 2, shared (RCU) */
+ /*
+ * bucket_at pointer is kept here to skip the extra level of
+ * dereference needed to get to "mm" (this is a fast-path).
+ */
struct cds_lfht_node *(*bucket_at)(struct cds_lfht *ht,
unsigned long index);
-
+ /*
+ * Dynamic length "tbl_chunk" needs to be at the end of
+ * cds_lfht.
+ */
union {
/*
* Contains the per order-index-level bucket node table.
*/
struct cds_lfht_node *tbl_mmap;
};
+ /*
+ * End of variables needed for the lookup, add and remove
+ * fast-paths.
+ */
};
extern unsigned int fls_ulong(unsigned long x);