From: David Miller <davem@davemloft.net>
To: nhorman@tuxdriver.com
Cc: linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
dvyukov@google.com, vyasevich@gmail.com
Subject: Re: [PATCH] sctp: Fix port hash table size computation
Date: Thu, 18 Feb 2016 15:39:21 -0500 (EST) [thread overview]
Message-ID: <20160218.153921.2010668846576353053.davem@davemloft.net> (raw)
In-Reply-To: <1455807724-7985-1-git-send-email-nhorman@tuxdriver.com>
From: Neil Horman <nhorman@tuxdriver.com>
Date: Thu, 18 Feb 2016 10:02:04 -0500
> Dmitry Vyukov noted recently that the sctp_port_hashtable had an error in
> its size computation, observing that the current method never guaranteed
> that the hashsize (measured in number of entries) would be a power of two,
> which the input hash function for that table requires. The root cause of
> the problem is that two values need to be computed (one, the allocation
> order of the storage requries, as passed to __get_free_pages, and two the
> number of entries for the hash table). Both need to be ^2, but for
> different reasons, and the existing code is simply computing one order
> value, and using it as the basis for both, which is wrong (i.e. it assumes
> that ((1<<order)*PAGE_SIZE)/sizeof(bucket) is still ^2 when its not).
>
> To fix this, we change the logic slightly. We start by computing a goal
> allocation order (which is limited by the maximum size hash table we want
> to support. Then we attempt to allocate that size table, decreasing the
> order until a successful allocation is made. Then, with the resultant
> successful order we compute the number of buckets that hash table supports,
> which we then round down to the nearest power of two, giving us the number
> of entries the table actually supports.
>
> I've tested this locally here, using non-debug and spinlock-debug kernels,
> and the number of entries in the hashtable consistently work out to be
> powers of two in all cases.
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
This needs some work:
In file included from include/linux/list.h:8:0,
from include/linux/module.h:9, from net/sctp/protocol.c:44:
net/sctp/protocol.c: In function ‘sctp_init’:
include/linux/kernel.h:752:17: warning: comparison of distinct
pointer types lacks a cast (void) (&_min1 == &_min2); \ ^
net/sctp/protocol.c:1431:10: note: in expansion of macro ‘min’ order
= min(order, max_entry_order); ^ In file included from
include/linux/printk.h:6:0, from include/linux/kernel.h:13, from
include/linux/list.h:8, from include/linux/module.h:9, from
net/sctp/protocol.c:44:
include/linux/kern_levels.h:4:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:13:19: note: in expansion of macro ‘KERN_SOH’
#define KERN_INFO KERN_SOH "6" /* informational */
^
include/linux/printk.h:259:9: note: in expansion of macro ‘KERN_INFO’
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^
net/sctp/protocol.c:1484:2: note: in expansion of macro ‘pr_info’
pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize,
^
next prev parent reply other threads:[~2016-02-18 20:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 15:02 [PATCH] sctp: Fix port hash table size computation Neil Horman
2016-02-18 20:39 ` David Miller [this message]
2016-02-18 21:10 ` [PATCHv2] " Neil Horman
2016-02-19 10:28 ` Eric Dumazet
2016-02-19 14:07 ` Neil Horman
2016-02-19 14:41 ` Eric Dumazet
2016-02-19 16:46 ` Neil Horman
2016-02-22 2:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160218.153921.2010668846576353053.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=dvyukov@google.com \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=vyasevich@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).