]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - lib/rhashtable.c
cxgb: Use napi_alloc_skb instead of netdev_alloc_skb_ip_align
[karo-tx-linux.git] / lib / rhashtable.c
index 25e4c213b08aebbf3e57ffb6de6c15ac855764c7..c7e987ab33611fc60af79809a732d2a44f879740 100644 (file)
@@ -229,7 +229,7 @@ int rhashtable_expand(struct rhashtable *ht)
        ht->shift++;
 
        /* For each new bucket, search the corresponding old bucket
-        * for the rst entry that hashes to the new bucket, and
+        * for the first entry that hashes to the new bucket, and
         * link the new bucket to that entry. Since all the entries
         * which will end up in the new bucket appear in the same
         * old bucket, this constructs an entirely valid new hash
@@ -247,8 +247,8 @@ int rhashtable_expand(struct rhashtable *ht)
        }
 
        /* Publish the new table pointer. Lookups may now traverse
-        * the new table, but they will not benet from any
-        * additional efciency until later steps unzip the buckets.
+        * the new table, but they will not benefit from any
+        * additional efficiency until later steps unzip the buckets.
         */
        rcu_assign_pointer(ht->tbl, new_tbl);
 
@@ -304,14 +304,14 @@ int rhashtable_shrink(struct rhashtable *ht)
 
        ht->shift--;
 
-       /* Link each bucket in the new table to the rst bucket
+       /* Link each bucket in the new table to the first bucket
         * in the old table that contains entries which will hash
         * to the new bucket.
         */
        for (i = 0; i < ntbl->size; i++) {
                ntbl->buckets[i] = tbl->buckets[i];
 
-               /* Link each bucket in the new table to the rst bucket
+               /* Link each bucket in the new table to the first bucket
                 * in the old table that contains entries which will hash
                 * to the new bucket.
                 */
@@ -653,15 +653,15 @@ static int __init test_rht_lookup(struct rhashtable *ht)
        return 0;
 }
 
-static void test_bucket_stats(struct rhashtable *ht,
-                                    struct bucket_table *tbl,
-                                    bool quiet)
+static void test_bucket_stats(struct rhashtable *ht, bool quiet)
 {
-       unsigned int cnt, i, total = 0;
+       unsigned int cnt, rcu_cnt, i, total = 0;
        struct test_obj *obj;
+       struct bucket_table *tbl;
 
+       tbl = rht_dereference_rcu(ht->tbl, ht);
        for (i = 0; i < tbl->size; i++) {
-               cnt = 0;
+               rcu_cnt = cnt = 0;
 
                if (!quiet)
                        pr_info(" [%#4x/%zu]", i, tbl->size);
@@ -673,6 +673,13 @@ static void test_bucket_stats(struct rhashtable *ht,
                                pr_cont(" [%p],", obj);
                }
 
+               rht_for_each_entry_rcu(obj, tbl->buckets[i], node)
+                       rcu_cnt++;
+
+               if (rcu_cnt != cnt)
+                       pr_warn("Test failed: Chain count mismach %d != %d",
+                               cnt, rcu_cnt);
+
                if (!quiet)
                        pr_cont("\n  [%#x] first element: %p, chain length: %u\n",
                                i, tbl->buckets[i], cnt);
@@ -680,6 +687,9 @@ static void test_bucket_stats(struct rhashtable *ht,
 
        pr_info("  Traversal complete: counted=%u, nelems=%zu, entries=%d\n",
                total, ht->nelems, TEST_ENTRIES);
+
+       if (total != ht->nelems || total != TEST_ENTRIES)
+               pr_warn("Test failed: Total count mismatch ^^^");
 }
 
 static int __init test_rhashtable(struct rhashtable *ht)
@@ -710,8 +720,7 @@ static int __init test_rhashtable(struct rhashtable *ht)
        }
 
        rcu_read_lock();
-       tbl = rht_dereference_rcu(ht->tbl, ht);
-       test_bucket_stats(ht, tbl, true);
+       test_bucket_stats(ht, true);
        test_rht_lookup(ht);
        rcu_read_unlock();
 
@@ -735,6 +744,10 @@ static int __init test_rhashtable(struct rhashtable *ht)
                rcu_read_unlock();
        }
 
+       rcu_read_lock();
+       test_bucket_stats(ht, true);
+       rcu_read_unlock();
+
        pr_info("  Deleting %d keys\n", TEST_ENTRIES);
        for (i = 0; i < TEST_ENTRIES; i++) {
                u32 key = i * 2;