Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2294509rwo; Sun, 23 Jul 2023 11:50:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlGuhSnNZTtFJJVdGC2fBly7v8uXkciZ8NxGFabJOeFJ6pUDvUktaHlRJ6EBrmnshiU7UFth X-Received: by 2002:a17:906:30cf:b0:987:fe18:1c56 with SMTP id b15-20020a17090630cf00b00987fe181c56mr7778250ejb.47.1690138216356; Sun, 23 Jul 2023 11:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690138216; cv=none; d=google.com; s=arc-20160816; b=iXmJw480mjk4gaqc8DQ49Bfb1LQPg1V/ufV14kG8ARUDbqKKKk8A4Ub2iKiOT2f90y uvTkR+q+u7d73pCeWBB7Q3R47ZbxoXIAV3v8z6S7cSukzNSLYVOWkHp1dgHpyDc1ARjl NZ0uNO/G/f46VFpXYVtDMi8HasZcOZb80Ox67JkQt8NJSU4pj2KvDvgYeAb9Uf62WmSx +hp9b9p8j1ZGPK8kyd6leMjCLYjHcGt/AwfNrE2E0E91y5JQ38v5TcUQ7XgbNM/OkJOj PH9TwMQw6kFP85gi11+06hn8Cewhv1pWS02bg14FmthdGaWTeZH2slF2tkj7B6QL93jr IOJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=I9RSoe//b4ycHDRnGCvMAXsUqlibqpvp2uBp438sHeY=; fh=tkhqiWCMjg7XpNpRXP/zJbLbSuo2QZ+OmiWxFMRA2I8=; b=A+fy2GeVcboqo7PUyF7KlpfP5t/nWuM5+05Ilgfx1Jx4Vq0LSJwJhIXonLV3Q6ToRA Qcjd1qwvCHZF/iewsaXiQNLzHZaJifGdh/csdlJuLBnoH6JFcsuNzRyT0Z//ilB4CxXp 4YcpIp4nPA8x9Pfz1J7DWkf9cOGYIGodlxIe+b9X32TaOEjJ+Oq77tSUEe90657pQXO8 ulZOV9S24cd6TL9+c+EURojKCe3obZExV76AwOo0UrgOMM/cWQfGweuWlGujYwGnvpO2 0JLd0IWHpmmqyJ8da7q+45LKjs01zS3p3MIVzLK7516zozWfLf+2LxcWCXRaFCJC+/ac hZCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=e4TXkkcW; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="iy0OHW/i"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a17090643c800b009929d998ab4si5158458ejn.738.2023.07.23.11.49.52; Sun, 23 Jul 2023 11:50:16 -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=@arndb.de header.s=fm2 header.b=e4TXkkcW; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="iy0OHW/i"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjGWScX (ORCPT + 99 others); Sun, 23 Jul 2023 14:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjGWScV (ORCPT ); Sun, 23 Jul 2023 14:32:21 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C70DDE64; Sun, 23 Jul 2023 11:32:19 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 4441832000CC; Sun, 23 Jul 2023 14:32:15 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Sun, 23 Jul 2023 14:32:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1690137134; x=1690223534; bh=I9RSoe//b4ycHDRnGCvMAXsUqlibqpvp2uB p438sHeY=; b=e4TXkkcWbWz6yBNLaJC1OByZ7wyGB8ZHjBdnVMXzTiNJmQFP+j3 1HKYnTGdJYJfyCW7/15WLXb2svArER93X0VuUOb9qAHdv/drPmPxc5Qierlqpp0D L9NY1Lf7Z1LxM9KHZhxJ7tOu9OQgtu3CeCQ/SxgXt+WJDPNiUIrkg/J6/wpTGicS sjuVtpQe2Bz4+h8As3EkmczUmupk3FJDgo+SHGTsRc3vOFOlmINa5npQi07V6Jwk mts22k4D3mbC6IUfearoRVJOs/bXkh1rnqig6GLAsT/JcAvzRwi7/MqWnF9sKdtD 8RxObdz+b3tKScBOSOeS72kDAWuwsoCFzuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1690137134; x=1690223534; bh=I9RSoe//b4ycHDRnGCvMAXsUqlibqpvp2uB p438sHeY=; b=iy0OHW/iPBafJ4HFPialW/SWLCnNtA/tdmRjvT0zA9jNUKGAHXN C/Ci/OAOvcpFtVD/G9joAblG5ZDOkOqCoopZpf69xS/wupE5aSNGIJI8DYY2slOg xB9PUP2jXddP8gZGAjvZdLTPEExNjq92DzbvMfdu/cpk/lARTTkLePS+1/V90AMv jqGJ7iO02CXV8dmxoMAGqy3vCiSRkrDqP6vItp+RQuVNOncCcl+eCqpcmYY/ZZ59 PwDy4fwVnaTfMDZ9GnvjsgjJEhVWV3Mf/xWqIRfq01rfARAYMZZFBhPUrHOLbs5z me38osYz1ExqPVCM9a7gjDm5SK0sI1JxXPQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrheeigdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeegfeejhedvledvffeijeeijeeivddvhfeliedvleevheejleetgedukedt gfejveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id EFC76B60089; Sun, 23 Jul 2023 14:32:13 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20230722074753.568696-1-arnd@kernel.org> Date: Sun, 23 Jul 2023 20:31:47 +0200 From: "Arnd Bergmann" To: "Alexei Starovoitov" , "Yafang Shao" Cc: "Arnd Bergmann" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Hou Tao" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "John Fastabend" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "Kumar Kartikeya Dwivedi" , bpf , LKML Subject: Re: [PATCH] bpf: force inc_active()/dec_active() to be inline functions Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 Sun, Jul 23, 2023, at 18:46, Alexei Starovoitov wrote: > On Sun, Jul 23, 2023 at 7:25=E2=80=AFAM Yafang Shao wrote: >> On Sat, Jul 22, 2023 at 3:48=E2=80=AFPM Arnd Bergmann wrote: >> > From: Arnd Bergmann >> > >> > Splitting these out into separate helper functions means that we >> > actually pass an uninitialized variable into another function call >> > if dec_active() happens to not be inlined, and CONFIG_PREEMPT_RT >> > is disabled: >> >> Do you mean that the compiler can remove the flags automatically when >> dec_active() is inlined, but can't remove it automatically when >> dec_active() is not inlined ? My educated guess is that it's fine when neither of them are inlined, since then gcc can assume that 'flags' gets initialized by inc_active(), and it's fine when both are inlined since dead code elimination then gets rid of both the initialization and the use. The only broken case should be when inc_active() is inlined and gcc can tell that there is never an initialization, but=20 dec_active() is not inlined, so gcc assumes it is actually used. >> If so, why can't we improve the compiler ? > > Agree. > Sounds like a compiler bug. I don't know what you might want to change in the compiler to avoid this. Compilers are free to decide which functions to inline in the absence of noinline or always_inline flags. One difference between gcc and clang is that gcc tries to be smart about warnings by using information from inlining to produce better warnings, while clang never uses information across function boundaries for generated warnings, so it won't find this one, but also would ignore an unconditional use of the uninitialized variable.=20 >> If we have to change the kernel, what about the change below? > > To workaround the compiler bug we can simply init flag=3D0 to silence > the warn, but even that is silly. Passing flag=3D0 into irqrestore is = buggy. Maybe inc_active() could return the flags instead of modifying the stack variable? that would also result in slightly better code when it's not inlined. Arnd