Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1743883rwb; Fri, 19 Aug 2022 08:41:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fsudg+ME1h39JaHeBBDP8HQvXWOyFSQgqAwA3Tx0PkjvFasXaIgG+YgRgTnr2+pIBjPd2 X-Received: by 2002:a17:90b:3e8b:b0:1f5:2a52:9148 with SMTP id rj11-20020a17090b3e8b00b001f52a529148mr8848369pjb.175.1660923678774; Fri, 19 Aug 2022 08:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923678; cv=none; d=google.com; s=arc-20160816; b=crWCwnCYyAGFmz8GCFCsiqMqw+d7Toa4sr21Ue7bgcJ0T8wHJlS0Oc4TSQnNi8BIUq DduXSg0oV2OcnmR8agbkgZiAHivgX1GFQsAoD2du0s3OXzOMUaZ0lyq60ugIuKRH4GCJ H8XNONFeYZRa7rf690/7BPFFyYKv1pQNTkbBOrJn+QIu+aDGslx5RkxUnnGz1bx6QqBy 4OyA24O5iXe7mxNmSo+wcVbPEhuT+xlibX0d5XKEX0XPqSUVQNNV2zs7n3uJ2tkiZxI2 k79EpEq6lx8p2tLkFGDh4ytZ1zPHe4AKwJqC9cAZBYgUtO7K+4Gi7E8TRCOhUe2hzIsa q5Jg== 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=YFMuK07MAl90VNNqj+UWyRTdyy2yEe0aAWnn80xZ4hU=; b=AFO6ghPGPKXuDYWpM+UHRM4GGNRpiK/p3g4LqHZa/enf+dcAa6FS5zlqWQZRJrtHkE 5dD0N2XP1sJ3vlZvLrvdJoVw5xy7WwC8G73ZumJ3hKQ07yLHlVZqbbbbJe92SpGUzMU4 GwEyBmjYOXT18p91u/CsmuDBlbKyndVL6ophj55Ue4viB5KqgXeX4akiCwMz5uoPteWZ YsQ2kO8P5Nz5QWLk1kijia4QP3oIUMUq5wT2Y3iaEVxN84jEtW0cpgnL8BLPhcAADaMN bfjUk6/cF6tgLOfmvADupLk+m0GCKNDE4aA/J3KLHPckQNj3h3Q67W1fSy21pzKyQXQW uH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="JDgj3pb/"; 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 lw18-20020a17090b181200b001fad41b00e0si3949925pjb.83.2022.08.19.08.41.07; Fri, 19 Aug 2022 08:41:18 -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="JDgj3pb/"; 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 S1349541AbiHSPRS (ORCPT + 99 others); Fri, 19 Aug 2022 11:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348832AbiHSPRR (ORCPT ); Fri, 19 Aug 2022 11:17:17 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FBD0FAC5A; Fri, 19 Aug 2022 08:17:16 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id y127so1630144pfy.5; Fri, 19 Aug 2022 08:17:16 -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; bh=YFMuK07MAl90VNNqj+UWyRTdyy2yEe0aAWnn80xZ4hU=; b=JDgj3pb/g+V5bIF7JGajRHFNgtDvCci3zYOBCFl6+1bAAUorPTTOh5Vni++0pnHsRj nuKvseA1W73dEp5EAs8lERkOTnSBd9lug1/lzKbFPr3CDJgxJAeEszNNkMVhAO/WdZcY avTg4XnnJUZWxAIOg+Lg+V6LRDJOeBG/gAFp5NY4hr0JBcyIYOOfi4roW4bxNFBMuadu jMzLzjvxWku44ALsNamO1gEjzonca8nmEQ6FG98pbepvPnY6yzkXonDgKYLbubrYLAC2 3AhAtGyXy3sS4QV+3foAXj4p/Qd1ZW44QnIn1q6ceAfjoPDMyxGSyJIAXSDVv0aljXen 4DbA== 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; bh=YFMuK07MAl90VNNqj+UWyRTdyy2yEe0aAWnn80xZ4hU=; b=PoZWbvjwm65Q5xoTO9ncGsvYrroy1SOiF0twCI02LAcnDBoYCy9zHJJWw2TNfAgjMd GBLEegXoRU50mwNSIKnbLI0ekQSaSFyzxpEjwuIUAiqau56/5PYJiolKn7yETHkn6aO/ 6kPmjkENv/gjwaY9yTuCfh+rMFAIlYzAqR73M8m6LsdiiZIf1VDChAGTnlKv6o50Mt1b kdXQJw/WmarHDRfHGmW9qOXR6BC2A6+L3Ja9OQBDk081KKjPMep9O+jU5ZyjhX5mKOzl TidmZvn6/BZyaZEvTk1KqPoR70BTCh3UDvNcy3goxeLUvKeiETnXl9gPFvL4BWTdkw5c 1itg== X-Gm-Message-State: ACgBeo1FDFRqXXntbkVeaf31DTTqOmb+O70VNGQDjPb2I2N3L+OzRkde bgOv2vh2jz1tk8LW9sdWn2r3wz8Tzu8FE3i+v6I= X-Received: by 2002:a63:2148:0:b0:427:17f6:7c05 with SMTP id s8-20020a632148000000b0042717f67c05mr6668275pgm.200.1660922235800; Fri, 19 Aug 2022 08:17:15 -0700 (PDT) MIME-Version: 1.0 References: <20220816032846.2579217-1-imagedong@tencent.com> <20220818100946.6ad96b06@kernel.org> In-Reply-To: <20220818100946.6ad96b06@kernel.org> From: Menglong Dong Date: Fri, 19 Aug 2022 23:17:04 +0800 Message-ID: Subject: Re: [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc To: Jakub Kicinski Cc: miguel.ojeda.sandonis@gmail.com, ojeda@kernel.org, ndesaulniers@google.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, asml.silence@gmail.com, imagedong@tencent.com, luiz.von.dentz@intel.com, vasily.averin@linux.dev, jk@codeconstruct.com.au, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kernel test robot 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,T_SCC_BODY_TEXT_LINE 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 Fri, Aug 19, 2022 at 1:09 AM Jakub Kicinski wrote: > > On Tue, 16 Aug 2022 11:28:46 +0800 menglong8.dong@gmail.com wrote: > > From: Menglong Dong > > [...] > > Sorry for a late and possibly off-topic chime in, is the compiler > splitting it because it thinks that skb_unref() is going to return > true? I don't think that's the likely case, so maybe we're better > off wrapping that skb_unref() in unlikely()? I think your thought is totally right, considering the instruction that I disassembled: ffffffff819fea20 : ffffffff819fea20: e8 cb 2c 40 00 call ffffffff81e016f0 <__fentry__> ffffffff819fea25: 48 85 ff test %rdi,%rdi ffffffff819fea28: 74 25 je ffffffff819fea4f ffffffff819fea2a: 8b 87 d4 00 00 00 mov 0xd4(%rdi),%eax /* this is just the instruction that compiled from skb_unref() */ ffffffff819fea30: 83 f8 01 cmp $0x1,%eax ffffffff819fea33: 75 0b jne ffffffff819fea40 ffffffff819fea35: 55 push %rbp ffffffff819fea36: 48 89 e5 mov %rsp,%rbp ffffffff819fea39: e8 42 ff ff ff call ffffffff819fe980 ffffffff819fea3e: 5d pop %rbp ffffffff819fea3f: c3 ret ffffffff819fea40: f0 ff 8f d4 00 00 00 lock decl 0xd4(%rdi) ffffffff819fea47: 0f 88 e5 44 27 00 js ffffffff81c72f32 <__noinstr_text_end+0x255d> ffffffff819fea4d: 74 e6 je ffffffff819fea35 ffffffff819fea4f: c3 ret The compiler just splits the code after skb_unref() to another. After I warp the skb_unref() in unlinkly(), this function is not splitted any more. Yeah, I think we can make skb_unref() wrapped by unlikely() by the way. Thanks! Menglong Dong