1. 09 7月, 2015 1 次提交
    • P
      rhashtable: fix for resize events during table walk · 142b942a
      Phil Sutter 提交于
      If rhashtable_walk_next detects a resize operation in progress, it jumps
      to the new table and continues walking that one. But it misses to drop
      the reference to it's current item, leading it to continue traversing
      the new table's bucket in which the current item is sorted into, and
      after reaching that bucket's end continues traversing the new table's
      second bucket instead of the first one, thereby potentially missing
      items.
      
      This fixes the rhashtable runtime test for me. Bug probably introduced
      by Herbert Xu's patch eddee5ba ("rhashtable: Fix walker behaviour during
      rehash") although not explicitly tested.
      
      Fixes: eddee5ba ("rhashtable: Fix walker behaviour during rehash")
      Signed-off-by: NPhil Sutter <phil@nwl.cc>
      Acked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      142b942a
  2. 07 6月, 2015 1 次提交
  3. 17 5月, 2015 1 次提交
    • H
      rhashtable: Add cap on number of elements in hash table · 07ee0722
      Herbert Xu 提交于
      We currently have no limit on the number of elements in a hash table.
      This is a problem because some users (tipc) set a ceiling on the
      maximum table size and when that is reached the hash table may
      degenerate.  Others may encounter OOM when growing and if we allow
      insertions when that happens the hash table perofrmance may also
      suffer.
      
      This patch adds a new paramater insecure_max_entries which becomes
      the cap on the table.  If unset it defaults to max_size * 2.  If
      it is also zero it means that there is no cap on the number of
      elements in the table.  However, the table will grow whenever the
      utilisation hits 100% and if that growth fails, you will get ENOMEM
      on insertion.
      
      As allowing oversubscription is potentially dangerous, the name
      contains the word insecure.
      
      Note that the cap is not a hard limit.  This is done for performance
      reasons as enforcing a hard limit will result in use of atomic ops
      that are heavier than the ones we currently use.
      
      The reasoning is that we're only guarding against a gross over-
      subscription of the table, rather than a small breach of the limit.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      07ee0722
  4. 06 5月, 2015 1 次提交
  5. 23 4月, 2015 2 次提交
  6. 26 3月, 2015 1 次提交
  7. 25 3月, 2015 4 次提交
  8. 24 3月, 2015 7 次提交
  9. 21 3月, 2015 3 次提交
    • H
      rhashtable: Rip out obsolete out-of-line interface · dc0ee268
      Herbert Xu 提交于
      Now that all rhashtable users have been converted over to the
      inline interface, this patch removes the unused out-of-line
      interface.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dc0ee268
    • H
      rhashtable: Allow hash/comparison functions to be inlined · 02fd97c3
      Herbert Xu 提交于
      This patch deals with the complaint that we make indirect function
      calls on the fast paths unnecessarily in rhashtable.  We resolve
      it by moving the fast paths into inline functions that take struct
      rhashtable_param (which obviously must be the same set of parameters
      supplied to rhashtable_init) as an argument.
      
      The only remaining indirect call is to obj_hashfn (or key_hashfn it
      obj_hashfn is unset) on the rehash as well as the insert-during-
      rehash slow path.
      
      This patch also extends the support of vairable-length keys to
      include those where the key is fixed but scattered in the object.
      For example, in netlink we want to key off the namespace and the
      portid but they're not next to each other.
      
      This patch does this by directly using the object hash function
      as the indicator of whether the key is accessible or not.  It
      also adds a new function obj_cmpfn to compare a key against an
      object.  This means that the caller no longer needs to supply
      explicit compare functions.
      
      All this is done in a backwards compatible manner so no existing
      users are affected until they convert to the new interface.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      02fd97c3
    • H
      rhashtable: Make rhashtable_init params argument const · 488fb86e
      Herbert Xu 提交于
      This patch marks the rhashtable_init params argument const as
      there is no reason to modify it since we will always make a copy
      of it in the rhashtable.
      
      This patch also fixes a bug where we don't actually round up the
      value of min_size unless it is less than HASH_MIN_SIZE.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Acked-by: NThomas Graf <tgraf@suug.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      488fb86e
  10. 20 3月, 2015 1 次提交
  11. 19 3月, 2015 3 次提交
  12. 17 3月, 2015 2 次提交
  13. 16 3月, 2015 2 次提交
    • H
      rhashtable: Fix rhashtable_remove failures · 565e8640
      Herbert Xu 提交于
      The commit 9d901bc0 ("rhashtable:
      Free bucket tables asynchronously after rehash") causes gratuitous
      failures in rhashtable_remove.
      
      The reason is that it inadvertently introduced multiple rehashing
      from the perspective of readers.  IOW it is now possible to see
      more than two tables during a single RCU critical section.
      
      Fortunately the other reader rhashtable_lookup already deals with
      this correctly thanks to c4db8848
      ("rhashtable: rhashtable: Move future_tbl into struct bucket_table")
      so only rhashtable_remove is broken by this change.
      
      This patch fixes this by looping over every table from the first
      one to the last or until we find the element that we were trying
      to delete.
      
      Incidentally the simple test for detecting rehashing to prevent
      starting another shrinking no longer works.  Since it isn't needed
      anyway (the work queue and the mutex serves as a natural barrier
      to unnecessary rehashes) I've simply killed the test.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      565e8640
    • H
      rhashtable: Fix use-after-free in rhashtable_walk_stop · 963ecbd4
      Herbert Xu 提交于
      The commit c4db8848 ("rhashtable:
      Move future_tbl into struct bucket_table") introduced a use-after-
      free bug in rhashtable_walk_stop because it dereferences tbl after
      droping the RCU read lock.
      
      This patch fixes it by moving the RCU read unlock down to the bottom
      of rhashtable_walk_stop.  In fact this was how I had it originally
      but it got dropped while rearranging patches because this one
      depended on the async freeing of bucket_table.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      963ecbd4
  14. 15 3月, 2015 6 次提交
  15. 13 3月, 2015 5 次提交