As stated previously, for linked lists, when working with the Linux's hash table interface, we should always bear in mind that these hashing functions perform no locking, so it is possible that our device driver (or other kernel entities) could attempt to perform concurrent operations on the same hash table. This is why we must be sure to also implement a good locking scheme to protect our data against race conditions.
As with kernel lists, we can declare and then initialize a hash table with a size of power-of-2 bits, using the following code:
DECLARE_HASHTABLE(data_hash, bits)
hash_init(data_hash);
As per lists, we have the compile time counterpart macro DEFINE_HASHTABLE(), which can be used to do the same in case of a non-dynamic hash table allocation. In our example, we can use DEFINE_HASHTABLE(data_hash, bits);
This creates and initializes a table named...