Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3127427pxa; Tue, 18 Aug 2020 07:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHuX+LLi91HTAB9DaXQnBvGjQzMYAWXX78ULH1C3CfzXOmwYke6Oa8NS6Phgmj3rUi8jM5 X-Received: by 2002:a17:906:b2d7:: with SMTP id cf23mr20349191ejb.113.1597760389703; Tue, 18 Aug 2020 07:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597760389; cv=none; d=google.com; s=arc-20160816; b=TI5ydAKT5hNddsdl44QDLvvn22mnwW4oJHtHvkrO0fNeIXo2tE31TO3XWNr61z6YOb /SXgcMNRyPS4lEOwl/uckcaAdJ1+gjKmQcUwh0Qf57gYv56v2vA2YnsBxFaK4DT/gc3e Xy7ohsKrwBFBi413WE4rGjyICbwi8v4AsmM3cYccIncAgQSyB0e7wciguZBRQuPR4kaw oO1ck8XTiIsvTy+9BAavfQsbAdohg2L7jxHjpOPHDPTRYjLEQAcnOZBGxmIM68uP25l3 XhgtulcS9h7HurdloAmRcVW9R5m9eHRDL3Khp8CcU7scJj9X1yT+M1PIfLKMMSaUwcpN LwJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NbZdFPM5mBHqNGZT0LL+I7dna9RSXYnxxpFw086pKfU=; b=xS47rWLik4rxatpPfI6xUy9vnaD1iZ2vOGbJ1zpClmOdBa78PxWYasjpLlGsGSgpku 36al+xcCvuDGjIkQuBwzkDlgD7UAUSZc93oIMGXAh2NPTOt63ngdCFNEd7LwLN0g38up Q8kY3Xqb0QcAkopJ8VC1VCukf1XWNUlAovDKb/td22Z6ZNk2atu49wym5vbZnPp5BtnG 8ZH1KvlXcknwfFxXFFV5Uvl+GSRt1LaIgt9V+Uvc3zasJbsVNvdeKeWkYDH9Aivbcn0l JHSqg0Tln9CHUrQWAQnrq0YlC2FXrvXFoEI6hw5L5VrhxNztkunx1W7WbmlPSROcoUrt YJGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RmVr4Ws8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb5si13479825ejb.206.2020.08.18.07.19.25; Tue, 18 Aug 2020 07:19:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RmVr4Ws8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbgHROQH (ORCPT + 99 others); Tue, 18 Aug 2020 10:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgHROPr (ORCPT ); Tue, 18 Aug 2020 10:15:47 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D2BC061389 for ; Tue, 18 Aug 2020 07:15:47 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id k4so17718474ilr.12 for ; Tue, 18 Aug 2020 07:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NbZdFPM5mBHqNGZT0LL+I7dna9RSXYnxxpFw086pKfU=; b=RmVr4Ws8VwlRGBEkpomlyGq7Aa0s7haUzbe8y/edlWahTFpVVmh6pJL1CXEQXYIUMn KxKzn9CWd8KWZVijUNs5WUvP5lHaCC/QdCQwNFqlKfruuVjzi4lrNfv+Tlqr5gTPTTOK ZnSmqHecyXnOclp15Ft5knVdiGdSIIBiIvg1KB+h/U2p3IeTvxUWJavPZvXRUdSrleeG NGhG5Pt85VWQ8TgPQZLu2hglWQCkb6xYpLuh7aPxYBer5dh+edoA5MXkRNmCgydpMcbO BXfXuDsO64NYGcxdY0OuwhTzrMZaFxF8KLNg0jLHU9puqySUm11CZ4y3CpnYIwCjcYWJ dFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NbZdFPM5mBHqNGZT0LL+I7dna9RSXYnxxpFw086pKfU=; b=YsLlaegqs1MQfW+/QoRf+lI5M9/UUfAlOy5myRTWZSXi+xwuwHIayt9HVWATkQqVGc qku8Q3MB5KO6KIy9ESu1IiGSjyhV1yQrzLs4BWHjlTRHs7nYYfvhI02jgjTXSyMC4OT/ ySEYnBDJuLCNtNbnFyE3ZUsd0KHV8C3nUUs2rr9XkFWdeDFS8mWqzp+YYC9z+Qlq8cTB XvuXNeM+Opm3bkn/amy2dPhTayyT5nnXlVanK6ktKBvlBQmZ1XTGNzWqU1U496xe/nXz HOY3eqAN746Tz9aKrUCnksEg9Mj9GNHdnpOkLZGgD6EcOTr4PJ9Q4sCF77488pod7I+m G2Mw== X-Gm-Message-State: AOAM533qCbbeprvRJ3D5t/cXXZoLK4deLH+bET6F4Y9G9SIxsz/yMwJg AKSzoY9xMRUOp/uY8Ntc6Om8K8O37LdOsvUsTMWw+g== X-Received: by 2002:a92:bb0e:: with SMTP id w14mr16467650ili.68.1597760146420; Tue, 18 Aug 2020 07:15:46 -0700 (PDT) MIME-Version: 1.0 References: <20200818115712.36497-1-linmiaohe@huawei.com> In-Reply-To: <20200818115712.36497-1-linmiaohe@huawei.com> From: Eric Dumazet Date: Tue, 18 Aug 2020 07:15:35 -0700 Message-ID: Subject: Re: [PATCH] net: Relax the npages test against MAX_SKB_FRAGS To: Miaohe Lin Cc: David Miller , Jakub Kicinski , martin.varghese@nokia.com, Florian Westphal , Pravin B Shelar , Davide Caratti , Steffen Klassert , Paolo Abeni , shmulik@metanetworks.com, kyk.segfault@gmail.com, netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 18, 2020 at 4:58 AM Miaohe Lin wrote: > > The npages test against MAX_SKB_FRAGS can be relaxed if we succeed to > allocate high order pages as the note in comment said. > > Signed-off-by: Miaohe Lin > --- > net/core/skbuff.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 2f7dd689bccc..ca432bbfd90b 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -5758,13 +5758,6 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, > struct page *page; > int i; > > - *errcode = -EMSGSIZE; > - /* Note this test could be relaxed, if we succeed to allocate > - * high order pages... > - */ > - if (npages > MAX_SKB_FRAGS) > - return NULL; > - > *errcode = -ENOBUFS; > skb = alloc_skb(header_len, gfp_mask); > if (!skb) > @@ -5775,6 +5768,10 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, > for (i = 0; npages > 0; i++) { > int order = max_page_order; > > + if (unlikely(i >= MAX_SKB_FRAGS)) { > + *errcode = -EMSGSIZE; > + goto failure; > + } > while (order) { > if (npages >= 1 << order) { > page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) | > -- > 2.19.1 We do not want this change. This interface is used by datagram providers, we do not want to claim they can safely use skb allocations over 64KB. Returning -EMSGSIZE should not depend on availability of high-order pages. The comment was a hint, but we need first a valid user before considering expanding the interface.