From patchwork Fri Oct 5 13:02:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 189476 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 240802C031D for ; Fri, 5 Oct 2012 23:03:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752988Ab2JENC7 (ORCPT ); Fri, 5 Oct 2012 09:02:59 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:37657 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401Ab2JENC6 (ORCPT ); Fri, 5 Oct 2012 09:02:58 -0400 Received: by mail-bk0-f46.google.com with SMTP id jk13so912836bkc.19 for ; Fri, 05 Oct 2012 06:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; bh=IifqXrVa54KEfdNIEFB3OkNlsBfz9IUBgOrshpDBVUI=; b=ZPfJ+BHEqAURAw3N3udPsNDV1jzM30nbBLHYHc7A4R3UphShvTtMP9GE5z67+9lqTv s4hZYVJQwZ3x2pAYpTRZMVK4fO4KUnrt1s+YwghTSBf1Q0c5jESJ2VEkEMtSmGL2ywpW EO82ATBLsruwrF8lGKlLeGwYO1Fz8PGmpov385k9KrqV1Dh6aCX6qoRHI9WTQS+LBX7k 8aSbBfgIH/NoRkUNXiBdPk6fQ0+v+CWRHvsWFCLvnNukmuGH6la1yqDHXKJ2CeBbO6Mf T/MTx0A45IQC8URCzTtMg9OE0WCgLOYGEpEeOk6dn5JfnqD4ajd8LHVt6V+FZLzioEgr Tm7w== Received: by 10.204.129.23 with SMTP id m23mr2819792bks.20.1349442176964; Fri, 05 Oct 2012 06:02:56 -0700 (PDT) Received: from [172.28.90.176] ([172.28.90.176]) by mx.google.com with ESMTPS id ia2sm7653038bkc.11.2012.10.05.06.02.54 (version=SSLv3 cipher=OTHER); Fri, 05 Oct 2012 06:02:55 -0700 (PDT) Subject: Re: kernel 3.2.27 on arm: WARNING: at mm/page_alloc.c:2109 __alloc_pages_nodemask+0x1d4/0x68c() From: Eric Dumazet To: mbizon@freebox.fr Cc: David Madore , Francois Romieu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hugh Dickins In-Reply-To: <1349441509.28867.17.camel@sakura.staff.proxad.net> References: <20120829002548.GA7063@aldebaran.gro-tsen.net> <1349366521.2532.12.camel@sakura.staff.proxad.net> <1349368171.16011.79.camel@edumazet-glaptop> <1349422868.21172.38.camel@edumazet-glaptop> <1349434194.16710.44.camel@sakura.staff.proxad.net> <1349439732.21172.52.camel@edumazet-glaptop> <1349441509.28867.17.camel@sakura.staff.proxad.net> Date: Fri, 05 Oct 2012 15:02:53 +0200 Message-ID: <1349442173.21172.66.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2012-10-05 at 14:51 +0200, Maxime Bizon wrote: > > New convention would be : pass number of needed bytes after current > > tail, not after current end. > > Fully agree on this > Here is the proposal : Change all occurrences of : pskb_expand_head(skb, 0, 0, gfp) to pskb_realloc_head(skb, gfp) [ an inline calling a common function ] And few other pskb_expand_head() calls a new function pskb_may_expand_head(skb, nhead, ntail, gfp) [ an inline calling same common function ] nhead : number of needed bytes before [data,tail] portion (might be already < skb_headroom(skb)) ntail : number of needed bytes after [data,tail] portion (might be already > skb_tailroom(skb)) For example, net/xfrm/xfrm_output.c would be like the following : (Note how all the various ugly tests will be centralized in the common function) And the common function would now know the caller intent. --- 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/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 95a338c..15760df 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -24,18 +24,10 @@ static int xfrm_output2(struct sk_buff *skb); static int xfrm_skb_check_space(struct sk_buff *skb) { struct dst_entry *dst = skb_dst(skb); - int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) - - skb_headroom(skb); - int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); - - if (nhead <= 0) { - if (ntail <= 0) - return 0; - nhead = 0; - } else if (ntail < 0) - ntail = 0; - - return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); + int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev); + int ntail = dst->dev->needed_tailroom; + + return pskb_may_expand_head(skb, nhead, ntail, GFP_ATOMIC); } static int xfrm_output_one(struct sk_buff *skb, int err)