From patchwork Fri Jun 22 10:54:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 166575 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 E8412B6FAB for ; Fri, 22 Jun 2012 20:55:19 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758106Ab2FVKy5 (ORCPT ); Fri, 22 Jun 2012 06:54:57 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48718 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755505Ab2FVKy4 (ORCPT ); Fri, 22 Jun 2012 06:54:56 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id E1A19A2FB8; Fri, 22 Jun 2012 12:54:54 +0200 (CEST) Date: Fri, 22 Jun 2012 11:54:51 +0100 From: Mel Gorman To: Sebastian Andrzej Siewior Cc: Andrew Morton , Linux-MM , Linux-Netdev , LKML , David Miller , Neil Brown , Peter Zijlstra , Mike Christie , Eric B Munson Subject: Re: [PATCH 10/17] netvm: Allow skb allocation to use PFMEMALLOC reserves Message-ID: <20120622105451.GC8271@suse.de> References: <1340192652-31658-1-git-send-email-mgorman@suse.de> <1340192652-31658-11-git-send-email-mgorman@suse.de> <20120621163029.GB6045@breakpoint.cc> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120621163029.GB6045@breakpoint.cc> 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, Jun 21, 2012 at 06:30:29PM +0200, Sebastian Andrzej Siewior wrote: > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > > index 1d6ecc8..9a58dcc 100644 > > --- a/net/core/skbuff.c > > +++ b/net/core/skbuff.c > > @@ -167,14 +206,19 @@ static void skb_under_panic(struct sk_buff *skb, int sz, void *here) > > * %GFP_ATOMIC. > > */ > > struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, > > - int fclone, int node) > > + int flags, int node) > > { > > struct kmem_cache *cache; > > struct skb_shared_info *shinfo; > > struct sk_buff *skb; > > u8 *data; > > + bool pfmemalloc; > > > > - cache = fclone ? skbuff_fclone_cache : skbuff_head_cache; > > + cache = (flags & SKB_ALLOC_FCLONE) > > + ? skbuff_fclone_cache : skbuff_head_cache; > > + > > + if (sk_memalloc_socks() && (flags & SKB_ALLOC_RX)) > > + gfp_mask |= __GFP_MEMALLOC; > > > > /* Get the HEAD */ > > skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node); > > This is mostly used by nic to refil their RX skb pool. You add the > __GFP_MEMALLOC to the allocation to rise the change of a successfull refill > for the swap case. > A few drivers use build_skb() to create the skb. __netdev_alloc_skb() > shouldn't be affected since the allocation happens with GFP_ATOMIC. Looking at > TG3 it uses build_skb() and get_pages() / kmalloc(). Shouldn't this be some > considered? > While TG3 is not exactly as you describe after rebasing build_skb should make a similar check to __alloc_skb. As it is always used for RX allocation from the skbuff_head_cache cache the following should be suitable. Thanks. --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9832001..063830c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -310,8 +310,12 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size) struct skb_shared_info *shinfo; struct sk_buff *skb; unsigned int size = frag_size ? : ksize(data); + gfp_t gfp_mask = GFP_ATOMIC; - skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); + if (sk_memalloc_socks()) + gfp_mask |= __GFP_MEMALLOC; + + skb = kmem_cache_alloc(skbuff_head_cache, gfp_mask); if (!skb) return NULL;