From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754113AbbG2UiC (ORCPT ); Wed, 29 Jul 2015 16:38:02 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35289 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbbG2Uh7 (ORCPT ); Wed, 29 Jul 2015 16:37:59 -0400 Message-ID: <1438202275.20182.99.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [PATCH 1/2] net: Export __netdev_alloc_frag() to allow gfp_mask flags From: Eric Dumazet To: Murali Karicheri Cc: WingMan Kwok , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 29 Jul 2015 22:37:55 +0200 In-Reply-To: <55B93611.7070506@ti.com> References: <1438182653-2136-1-git-send-email-w-kwok2@ti.com> <1438187516.20182.95.camel@edumazet-glaptop2.roam.corp.google.com> <55B93611.7070506@ti.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2015-07-29 at 16:22 -0400, Murali Karicheri wrote: > Eric, > > On 07/29/2015 12:31 PM, Eric Dumazet wrote: > > On Wed, 2015-07-29 at 11:10 -0400, WingMan Kwok wrote: > >> This patch makes the function __netdev_alloc_frag() non-static and > >> exports it so that drivers that need to specify additional flags, > >> such as __GFP_DMA, can use it. The currently exported function, > >> netdev_alloc_frag() doesn't allow passing in gfp_mask flags. > >> > >> Signed-off-by: WingMan Kwok > >> Signed-off-by: Reece R. Pollack > >> --- > >> include/linux/skbuff.h | 1 + > >> net/core/skbuff.c | 3 ++- > >> 2 files changed, 3 insertions(+), 1 deletion(-) > > > > You can not do this. > > > > __napi_alloc_frag() uses __alloc_page_frag() using a per cpu reserve. > > > Thanks for your response. > > I assume you mean to say __netdev_alloc_frag() which is what the patch > affects. Right? > > > This per cpu reserve would be shared by regular GFP_ATOMIC and your > > __GFP_DMA allocations. > > I am trying to understand the issue here. Is there any issue in sharing > this per CPU reserve between DMA and ATOMIC allocations. Without this > flag, the assumption is this function can return memory which is not > DMA-able and this flag assures it is allocated from DMA zone. First caller __netdev_alloc_frag() uses GFP_ATOMIC. A big page (32 KB) is allocated and stored into cache. Part of it given to caller. (like 1536 bytes or so) Then your driver calls with __GFP_DMA. We find a prior page on percpu cache with enough room in it to allocate a fragment. Your driver getd a fragment from the prior GFP_ATOMIC allocation, with no DMA guarantee. Therefore, your patch is not working in all cases.