Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp38297rwi; Sun, 30 Oct 2022 19:59:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TAeq4Vo/CLGUvXCUivSgjlMw0kcrsTR5OO06lxRJdtLfb8FgRyjDELLhNmpCKGEzM3qzg X-Received: by 2002:a17:90b:f06:b0:212:cb07:fb82 with SMTP id br6-20020a17090b0f0600b00212cb07fb82mr28932234pjb.221.1667185197015; Sun, 30 Oct 2022 19:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667185197; cv=none; d=google.com; s=arc-20160816; b=PwLHeep8DEfIqPn8gSOxkIQE2WJZ1eGsPm/+WTQdrgKYmS7OiarCnQzQrXYkOsnxFU vzvSmkblQKXbhJUrOQb8xP7/J8yOgjCZYQudcBoar2SXmmPuZYnmd+JKhXanpgMM0mpl DOe//hRu27MkIE2hD2CiWP+k1NBRPoT2x8FFXuUCjkJmcPKiR90AqTsqPGFnEvSTf6J8 w9Zk6Rk39gseQkYEFntYVKAeqU0CEM1oSf0T3dAKmMibkizgaZnDjW8r46tnUd4jBSLv Fng/mzIwgZguBM297y9P6VmUtVHycbjNnXf53Cc+YSkozMFK2S1r8/YbuIexXeAY+G0X r0FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5PfdcaHbK409/PjJykKyVzJZf3xmCOMU8c25nhLHBxY=; b=hOJJIU3Z2fyc9dvUAbzGsqjDsBlhRX5dkhf0RRcYp59fTfl61L8QBeZokxzcTtswrq k5byS2TTWsjmoVqih9NW7N74762ehgan/MrhpSPF9R0yiSZK0HWE0P1cyyEckREBuONu 89XcLNtUhzoXfVz36ysxFbtDd6xg4MQwKnByERutNbeYIRBZjuNqvFUd4btyXpcxUdwI MD2vXnQ33ZyzdhGqHqPx/eMlIIv9J6pGlCY0T19D+H4VYCPk659DqWnpjEUENV1Kdlue TcE6ZkRRIkz5EJCT6q8OG1kmRe2jr0Ha02nrDPFD4NoxFpCsHHrMwmK+c9614cyOzEiH NdiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SKcG3AFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik5-20020a170902ab0500b0017f77d19d92si5840104plb.127.2022.10.30.19.59.43; Sun, 30 Oct 2022 19:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SKcG3AFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiJaCgF (ORCPT + 99 others); Sun, 30 Oct 2022 22:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiJaCgE (ORCPT ); Sun, 30 Oct 2022 22:36:04 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16826547; Sun, 30 Oct 2022 19:36:01 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id h12so8449706ljg.9; Sun, 30 Oct 2022 19:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5PfdcaHbK409/PjJykKyVzJZf3xmCOMU8c25nhLHBxY=; b=SKcG3AFVwF4hYcc/EE2IjWL74lIAZlX/a65EZnlWHZ6J6J2KsfbclaguNsoddUdU8m gabJU53NoZpbtSUoZr9zpdUSI6onTf/Ei4SeI13yfLrzZgxHEff57ca/qRw0YqM24hz0 Hw5DHOR+IZQsGyNZVZ1ZAErmlZJmG0WrbblGoyfKb/O5zEYoGRfHjwJDE4bahcoQWv41 5W4Hy1m0kGda0ak9heyZgLckCwQNrA4ORuzyy0MEyBQyt1LrA7hacBaOjKBeo3/w3sfy DFs8jA9fXYASvVtH8f/AJr+p9Qc17lkvPwqCmHUE/hb4qcv/Ivy5tUM9sH7MUUv4yghs FX8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5PfdcaHbK409/PjJykKyVzJZf3xmCOMU8c25nhLHBxY=; b=TTewCiHXo2ScjPAd/ERJCLdqRkKBuGxEiDHPmd9mljCDFqy8JM2RLb2nDzUGqrGon9 H0FSkYOLhc6DbgtwJgq/qRE3L5Wi7yD+PpPxiAMk35tNwh39H29oGw38WmlqJilK6Lsd +jSW66LeQQyo5FX37nhoOkCA0bRedYCXxoOwxub4dLZIV/g9VtIvY6gNvdQJPXsvIakl VY4KdtBGjiWMC2GKe+t2M18JiJML/3eAINKQmyIJ4AtKqVbFzRF4GN3ilf2Lp6jp7Lbf WL8vHZweOCgpK1K2gEqsmYR2EnQpWfZ3y0CK+042xVjw3/1WJE0QlQXqoP1h2xCGXgW4 lP8g== X-Gm-Message-State: ACrzQf1nxX1cS1kUYk+YoxgB9Ou7N1qipf4updlCb35quJKu9d9Ih6+4 Kr3GO3sMdn4qlkrXLLFOWm3cITrm1Mu8lPyRT7k= X-Received: by 2002:a2e:bf23:0:b0:277:f54:f0fe with SMTP id c35-20020a2ebf23000000b002770f54f0femr4333886ljr.440.1667183760269; Sun, 30 Oct 2022 19:36:00 -0700 (PDT) MIME-Version: 1.0 References: <20221029130957.1292060-1-imagedong@tencent.com> <20221029130957.1292060-2-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Mon, 31 Oct 2022 10:35:48 +0800 Message-ID: Subject: Re: [PATCH net-next 1/9] net: skb: introduce try_kfree_skb() To: Eric Dumazet Cc: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, asml.silence@gmail.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 29, 2022 at 11:30 PM Eric Dumazet wrote: > > On Sat, Oct 29, 2022 at 6:11 AM wrote: > > > > From: Menglong Dong > > > > In order to simply the code, introduce try_kfree_skb(), which allow > > SKB_NOT_DROPPED_YET to be passed. When the reason is SKB_NOT_DROPPED_YET, > > consume_skb() will be called to free the skb normally. Otherwise, > > kfree_skb_reason() will be called. > > > > Signed-off-by: Menglong Dong > > --- > > include/linux/skbuff.h | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > > index 59c9fd55699d..f722accc054e 100644 > > --- a/include/linux/skbuff.h > > +++ b/include/linux/skbuff.h > > @@ -1236,6 +1236,15 @@ static inline void consume_skb(struct sk_buff *skb) > > } > > #endif > > > > +static inline void try_kfree_skb(struct sk_buff *skb, > > + enum skb_drop_reason reason) > > +{ > > + if (reason != SKB_NOT_DROPPED_YET) > > + kfree_skb_reason(skb, reason); > > + else > > + consume_skb(skb); > > +} > > + > > My proposal looks better IMO > > https://patchwork.kernel.org/project/netdevbpf/patch/20221028133043.2312984-2-edumazet@google.com/ Hnn...yeah, your idea seems fine, which wont affect the existing code.