aboutsummaryrefslogtreecommitdiff
path: root/datapath/table.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-12-27 16:06:08 -0800
committerBen Pfaff <blp@nicira.com>2010-12-28 09:17:12 -0800
commitc6fadeb1f0488997b44e85a00a8887756232156d (patch)
tree5dbccd7f7d21df949cb23e94cb3b5bd26f584dd7 /datapath/table.c
parentddffedda18b6f919cb896265e126574d75fcaf00 (diff)
datapath: Clarify meaning of n_buckets argument to tbl_create().
The n_buckets argument to tbl_create() can be zero, but the comment didn't mention that. However, there's no reason that the caller can't just pass in a correct size, so this commit changes them to do that. Also, TBL_L1_SIZE was conceptually wrong as the minimum size: the minimum size is one L2 page, e.g. TBL_L2_SIZE. But TBL_MIN_BUCKETS seems like a better all-around way to indicate the minimum size, so this commit also introduces that macro and uses it. Jesse Gross pointed out inconsistencies in this area. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'datapath/table.c')
-rw-r--r--datapath/table.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/datapath/table.c b/datapath/table.c
index 28063085..8a105324 100644
--- a/datapath/table.c
+++ b/datapath/table.c
@@ -90,16 +90,13 @@ static struct tbl_bucket ***alloc_buckets(unsigned int n_buckets)
* @n_buckets: number of buckets in the new table
*
* Creates and returns a new hash table, or %NULL if memory cannot be
- * allocated. @n_buckets must be a power of 2 in the range %TBL_L1_SIZE to
+ * allocated. @n_buckets must be a power of 2 in the range %TBL_MIN_BUCKETS to
* %TBL_MAX_BUCKETS.
*/
struct tbl *tbl_create(unsigned int n_buckets)
{
struct tbl *table;
- if (!n_buckets)
- n_buckets = TBL_L1_SIZE;
-
table = kzalloc(sizeof *table, GFP_KERNEL);
if (!table)
goto err;
@@ -273,7 +270,7 @@ struct tbl *tbl_expand(struct tbl *table)
}
err = -ENOMEM;
- new_table = tbl_create(n_buckets);
+ new_table = tbl_create(TBL_MIN_BUCKETS);
if (!new_table)
goto error;