• Herbert Xu's avatar
    rhashtable: Add nested tables · 40137906
    Herbert Xu authored
    This patch adds code that handles GFP_ATOMIC kmalloc failure on
    insertion.  As we cannot use vmalloc, we solve it by making our
    hash table nested.  That is, we allocate single pages at each level
    and reach our desired table size by nesting them.
    
    When a nested table is created, only a single page is allocated
    at the top-level.  Lower levels are allocated on demand during
    insertion.  Therefore for each insertion to succeed, only two
    (non-consecutive) pages are needed.
    
    After a nested table is created, a rehash will be scheduled in
    order to switch to a vmalloced table as soon as possible.  Also,
    the rehash code will never rehash into a nested table.  If we
    detect a nested table during a rehash, the rehash will be aborted
    and a new rehash will be scheduled.
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    40137906
rhashtable.h 37.3 KB