]> git.baikalelectronics.ru Git - kernel.git/commit
lib: test_rhashtable: fix for large entry counts
authorPhil Sutter <phil@nwl.cc>
Fri, 21 Jul 2017 14:51:31 +0000 (16:51 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Jul 2017 21:13:58 +0000 (14:13 -0700)
commit526cb22aea331bc206f7100aa41fb039827feb2d
treeb2c0df42a39c4458a782eace46523fe9fd95bdb5
parent22e3d853455acc99f3c71cba6a4b6ec54449f3d7
lib: test_rhashtable: fix for large entry counts

During concurrent access testing, threadfunc() concatenated thread ID
and object index to create a unique key like so:

| tdata->objs[i].value = (tdata->id << 16) | i;

This breaks if a user passes an entries parameter of 64k or higher,
since 'i' might use more than 16 bits then. Effectively, this will lead
to duplicate keys in the table.

Fix the problem by introducing a struct holding object and thread ID and
using that as key instead of a single integer type field.

Fixes: 72ad2562f74e4 ("rhashtable-test: extend to test concurrency")
Reported by: Manuel Messner <mm@skelett.io>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/test_rhashtable.c