diff mbox

[12/21] compat: avoid usage of kvzalloc() in rhashtable.c

Message ID 20170821222817.17376-13-hauke@hauke-m.de (mailing list archive)
State Accepted
Headers show

Commit Message

Hauke Mehrtens Aug. 21, 2017, 10:28 p.m. UTC
This reverts commit 12e8fd6fd3802 ("lib/rhashtable.c: use kvzalloc() in
bucket_table_alloc() when possible") from upstream kernel.
Kernel versions older that 4.12 do not have kvzalloc() try to avoid the
usage of this.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 patches/lib-rhashtable.patch | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Johannes Berg Sept. 6, 2017, 3:05 p.m. UTC | #1
On Tue, 2017-08-22 at 00:28 +0200, Hauke Mehrtens wrote:
> This reverts commit 12e8fd6fd3802 ("lib/rhashtable.c: use kvzalloc()
> in
> bucket_table_alloc() when possible") from upstream kernel.
> Kernel versions older that 4.12 do not have kvzalloc() try to avoid
> the
> usage of this.

Can't we backport these? There was a patch from AceLan Kao to do so in
a pretty simple fashion, but that should still be better than a patch?

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Hauke Mehrtens Sept. 6, 2017, 10:12 p.m. UTC | #2
On 09/06/2017 05:05 PM, Johannes Berg wrote:
> On Tue, 2017-08-22 at 00:28 +0200, Hauke Mehrtens wrote:
>> This reverts commit 12e8fd6fd3802 ("lib/rhashtable.c: use kvzalloc()
>> in
>> bucket_table_alloc() when possible") from upstream kernel.
>> Kernel versions older that 4.12 do not have kvzalloc() try to avoid
>> the
>> usage of this.
> 
> Can't we backport these? There was a patch from AceLan Kao to do so in
> a pretty simple fashion, but that should still be better than a patch?
> 
> johannes

Hi,

I think AceLan Kao's patch misses the implementation of kvmalloc_node().
We can implement this for node == NUMA_NO_NODE by using __vmalloc()
instead of __vmalloc_node_flags_caller() which should be fine.

Hauke
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Johannes Berg Sept. 8, 2017, 9:25 a.m. UTC | #3
On Thu, 2017-09-07 at 00:12 +0200, Hauke Mehrtens wrote:
> On 09/06/2017 05:05 PM, Johannes Berg wrote:
> > On Tue, 2017-08-22 at 00:28 +0200, Hauke Mehrtens wrote:
> > > This reverts commit 12e8fd6fd3802 ("lib/rhashtable.c: use
> > > kvzalloc()
> > > in
> > > bucket_table_alloc() when possible") from upstream kernel.
> > > Kernel versions older that 4.12 do not have kvzalloc() try to
> > > avoid
> > > the
> > > usage of this.
> > 
> > Can't we backport these? There was a patch from AceLan Kao to do so
> > in
> > a pretty simple fashion, but that should still be better than a
> > patch?
> > 
> > johannes
> 
> Hi,
> 
> I think AceLan Kao's patch misses the implementation of
> kvmalloc_node().
> We can implement this for node == NUMA_NO_NODE by using __vmalloc()
> instead of __vmalloc_node_flags_caller() which should be fine.

Sounds reasonable to me.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox

Patch

diff --git a/patches/lib-rhashtable.patch b/patches/lib-rhashtable.patch
index 9c262b02..35424efb 100644
--- a/patches/lib-rhashtable.patch
+++ b/patches/lib-rhashtable.patch
@@ -27,6 +27,19 @@ 
  		if (!tbl->locks)
  			return -ENOMEM;
  		for (i = 0; i < size; i++)
--- 
-1.9.1
+@@ -226,10 +226,11 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
+ 	int i;
+ 
+ 	size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
+-	if (gfp != GFP_KERNEL)
++	if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) ||
++	    gfp != GFP_KERNEL)
+ 		tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY);
+-	else
+-		tbl = kvzalloc(size, gfp);
++	if (tbl == NULL && gfp == GFP_KERNEL)
++		tbl = vzalloc(size);
+ 
+ 	size = nbuckets;
+