From patchwork Fri Dec 4 14:39:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 552730 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0924F14017E for ; Sat, 5 Dec 2015 01:40:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753488AbbLDOkI (ORCPT ); Fri, 4 Dec 2015 09:40:08 -0500 Received: from helcar.hengli.com.au ([209.40.204.226]:33183 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbbLDOkH (ORCPT ); Fri, 4 Dec 2015 09:40:07 -0500 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by norbury.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1a4rWi-0005Lc-UA; Sat, 05 Dec 2015 01:40:00 +1100 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1a4rWe-0004b8-Ca; Fri, 04 Dec 2015 22:39:56 +0800 Date: Fri, 4 Dec 2015 22:39:56 +0800 From: Herbert Xu To: Eric Dumazet Cc: Phil Sutter , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, tgraf@suug.ch, fengguang.wu@intel.com, wfg@linux.intel.com, lkp@01.org Subject: rhashtable: Use __vmalloc with GFP_ATOMIC for table allocation Message-ID: <20151204143956.GA17471@gondor.apana.org.au> References: <1448039840-11367-1-git-send-email-phil@nwl.cc> <20151130093755.GA8159@gondor.apana.org.au> <20151130101401.GA17712@orbit.nwl.cc> <20151130101859.GA8378@gondor.apana.org.au> <20151203125117.GB5505@gondor.apana.org.au> <1449158919.6379.27.camel@edumazet-glaptop2.roam.corp.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1449158919.6379.27.camel@edumazet-glaptop2.roam.corp.google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Dec 03, 2015 at 08:08:39AM -0800, Eric Dumazet wrote: > > Anyway, __vmalloc() can be used with GFP_ATOMIC, have you tried this ? OK I've tried it and I no longer get any ENOMEM errors! ---8<--- When an rhashtable user pounds rhashtable hard with back-to-back insertions we may end up growing the table in GFP_ATOMIC context. Unfortunately when the table reaches a certain size this often fails because we don't have enough physically contiguous pages to hold the new table. Eric Dumazet suggested (and in fact wrote this patch) using __vmalloc instead which can be used in GFP_ATOMIC context. Reported-by: Phil Sutter Suggested-by: Eric Dumazet Signed-off-by: Herbert Xu diff --git a/lib/rhashtable.c b/lib/rhashtable.c index a54ff89..1c624db 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -120,8 +120,9 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) || gfp != GFP_KERNEL) tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY); - if (tbl == NULL && gfp == GFP_KERNEL) - tbl = vzalloc(size); + if (tbl == NULL) + tbl = __vmalloc(size, gfp | __GFP_HIGHMEM | __GFP_ZERO, + PAGE_KERNEL); if (tbl == NULL) return NULL;