Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-pa0-f44.google.com ([209.85.220.44]:42784 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026AbaEGUDn (ORCPT ); Wed, 7 May 2014 16:03:43 -0400 Received: by mail-pa0-f44.google.com with SMTP id ld10so1669306pab.3 for ; Wed, 07 May 2014 13:03:43 -0700 (PDT) Date: Wed, 7 May 2014 13:03:41 -0700 (PDT) From: David Rientjes To: Trond Myklebust , David Miller cc: Jeff Layton , Marc Dietrich , "J. Bruce Fields" , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, Mel Gorman Subject: [patch] net, sunrpc: suppress allocation warning in rpc_malloc() In-Reply-To: <20140505070812.470c66bd@tlielax.poochiereds.net> Message-ID: References: <2562595.ix17LO7uqe@fb07-iapwap2> <20140505070812.470c66bd@tlielax.poochiereds.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-nfs-owner@vger.kernel.org List-ID: rpc_malloc() allocates with GFP_NOWAIT without making any attempt at reclaim so it easily fails when low on memory. This ends up spamming the kernel log: SLAB: Unable to allocate memory on node 0 (gfp=0x4000) cache: kmalloc-8192, object size: 8192, order: 1 node 0: slabs: 207/207, objs: 207/207, free: 0 rekonq: page allocation failure: order:1, mode:0x204000 CPU: 2 PID: 14321 Comm: rekonq Tainted: G O 3.15.0-rc3-12.gfc9498b-desktop+ #6 Hardware name: System manufacturer System Product Name/M4A785TD-V EVO, BIOS 2105 07/23/2010 0000000000000000 ffff880010ff17d0 ffffffff815e693c 0000000000204000 ffff880010ff1858 ffffffff81137bd2 0000000000000000 0000001000000000 ffff88011ffebc38 0000000000000001 0000000000204000 ffff88011ffea000 Call Trace: [] dump_stack+0x4d/0x6f [] warn_alloc_failed+0xd2/0x140 [] __alloc_pages_nodemask+0x7e9/0xa30 [] kmem_getpages+0x58/0x140 [] fallback_alloc+0x1d6/0x210 [] ____cache_alloc_node+0x123/0x150 [] __kmalloc+0x203/0x490 [] rpc_malloc+0x32/0xa0 [sunrpc] [] call_allocate+0xb9/0x170 [sunrpc] [] __rpc_execute+0x88/0x460 [sunrpc] [] rpc_execute+0x59/0xc0 [sunrpc] [] rpc_run_task+0x6b/0x90 [sunrpc] [] nfs4_call_sync_sequence+0x51/0x80 [nfsv4] [] _nfs4_do_setattr+0x1ed/0x280 [nfsv4] [] nfs4_do_setattr+0x72/0x180 [nfsv4] [] nfs4_proc_setattr+0xbc/0x140 [nfsv4] [] nfs_setattr+0xd8/0x240 [nfs] [] notify_change+0x231/0x380 [] chmod_common+0xfc/0x120 [] SyS_chmod+0x40/0x90 [] system_call_fastpath+0x1a/0x1f ... If the allocation fails, simply return NULL and avoid spamming the kernel log. Reported-by: Marc Dietrich Signed-off-by: David Rientjes --- net/sunrpc/sched.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -832,7 +832,8 @@ static void rpc_async_schedule(struct work_struct *work) * @size: requested byte size * * To prevent rpciod from hanging, this allocator never sleeps, - * returning NULL if the request cannot be serviced immediately. + * returning NULL and suppressing warning if the request cannot be serviced + * immediately. * The caller can arrange to sleep in a way that is safe for rpciod. * * Most requests are 'small' (under 2KiB) and can be serviced from a @@ -845,7 +846,7 @@ static void rpc_async_schedule(struct work_struct *work) void *rpc_malloc(struct rpc_task *task, size_t size) { struct rpc_buffer *buf; - gfp_t gfp = GFP_NOWAIT; + gfp_t gfp = GFP_NOWAIT | __GFP_NOWARN; if (RPC_IS_SWAPPER(task)) gfp |= __GFP_MEMALLOC;