Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3614731rwo; Mon, 24 Jul 2023 13:56:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9iKhlQLUhWrNtbUBibmH8XH0wBG72hl3LFBe8RPeuuTYC/sAdIY1WKWqe/+ORdd3N+Cnu X-Received: by 2002:a05:6a20:1388:b0:137:3803:33c with SMTP id hn8-20020a056a20138800b001373803033cmr7826833pzc.54.1690232187184; Mon, 24 Jul 2023 13:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690232187; cv=none; d=google.com; s=arc-20160816; b=ux50MXIpcs4xzDsCcaGW/h7LqJqhCPpmrFz/WzgPVCQ/9jcQYi6QXgtjoxIr0yHUSt LFfpOsQj0iVt69mUVualWeeQi0UcwcxYC209zIhvZd7E7kux3vB/bNVdIuY0QN0q0j4O d9o8/3IhvZX0QQCiDZbR8bdVTgn+rETZNpP2AL8AJg774SxEhLkrXMChHORC3JVk7SIi f/6THpgbXqzD9uxIyuNvvmToVkHWY9bl+ygPlX0hgNGDJiJvzgzriFsKb7E98zzB6ZGh hJDHTXeT9HswJC0gWK73/rLwJsfnlk+Jkm0cGqEMQJlX7BKa0/r3ewhx0Apm+gt+tmxw d+bw== 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=cGGxbA6raeMBuCb9imH1rSv60YX9qXFYj7o6D1uCY4c=; fh=z0nfab/dpyfkvfQgbAjKCs8v8o1hpKLupXxuEtCjTJQ=; b=BThZC53N0dke3fxhZf0pYxQZCStysWuYDXvH3TXWZL9QSWmvP7FkjgTBcZh4ik3h+I f8mV+72Pgy1S2mwV8oazPBDWee3EbEx4t5Ezs0pd+4SVU1EjkOxtkCae1CAxUzmbgNX6 jSV3jDHNUSdIK8CnIfwEmCypRgdFEtub67mCe4w3AeyxC/YUPMm0N6AbYSEBYgUKwuP8 eiqzw3hOpfbSIPiADE2mCvatOYGnP9vJh2PEwgG70fUL+1FkdajsLP31NdXCpTiGvmib a0DKKtTwt0xJ7MSOJ2GI6sydHln2IjfeU7UBi+ZtLCS4NF19+kNL/vTprqs2D8/2vAFe azxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=g3FtoeKg; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=jkd3GSri; 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 cv5-20020a056a0044c500b0066a4fe6ad9dsi9577664pfb.70.2023.07.24.13.56.15; Mon, 24 Jul 2023 13:56:27 -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=g3FtoeKg; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=jkd3GSri; 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 S229582AbjGXUly (ORCPT + 99 others); Mon, 24 Jul 2023 16:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjGXUlw (ORCPT ); Mon, 24 Jul 2023 16:41:52 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B537EA; Mon, 24 Jul 2023 13:41:51 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 588135C01DA; Mon, 24 Jul 2023 16:41:47 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Mon, 24 Jul 2023 16:41:47 -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= 1690231307; x=1690317707; bh=cGGxbA6raeMBuCb9imH1rSv60YX9qXFYj7o 6D1uCY4c=; b=g3FtoeKgOdtntVGG/JV4HNVZSpWgXqvLofzUtmvTemj5q+qfFf1 XBqX4WKwS5mhTSI6sACrZjvcSzLE9O8KUtne5fkqljlPGgQTVlnJMwtIej1myfdG mRGA7y8NTOG9JVwIE2gKM8j+h/Tyuu8xzVcsQrT1/WJuvyhilTBzj5wMhba8CKWF xyg06c26F909LnY0n9p1DJBPSgoG1JEiTmY2YYOzdEXSJl7FrckuTWkzkE4ZRLNQ 7SNRVR1dG/GmvXJyxGwI5EA0byrC/lHev+v+TbttYjOr3tRrTJsmrs1S8z9I3qxH 13sBWcDPpu5gXu1oPOsRK+wEF/k8uITQytQ== 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= 1690231307; x=1690317707; bh=cGGxbA6raeMBuCb9imH1rSv60YX9qXFYj7o 6D1uCY4c=; b=jkd3GSriZUDFpiwrKgxlbSDTMUb1JV4wMrjsYcovZqJdQcy+2o8 fnIOLZ5F/IyF9yiPa3kGgcGF0hVgN7gYoAMc7C0uujVMw9gQkAq91npWlsewv0tQ JBeobd0KO28t51ru6nqpYYEnXQuI0pGjjQtFLzBOsNjMckArIBpF1V0ML0PNiRmz ufC+XURKFFPCPSzBnPg8SHeEkyqx7zcxLZqaxuC+DsVHoJ1ULGBJFxJcHjaG32iX bvb1O6GsINSkXTeZpb2inkU6h1m1DtguGgViUK4n6dQ/8O/y4lC35dXyRW/lP4+d agb2tJcOidZR3cSPUbLcJE0JPNVaBB4rfiA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrheekgdduhedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeelfefgueeviefgudduueefueffkeelleeijeelkefgudfgueelledtuddu ieegvdenucffohhmrghinhepghhouggsohhlthdrohhrghenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9E6B9B6008D; Mon, 24 Jul 2023 16:41:46 -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: <3e202277-fe74-4105-93ec-b646efaaa956@app.fastmail.com> In-Reply-To: References: <20230722074753.568696-1-arnd@kernel.org> <679d8d63-ce92-4294-8620-e98c82365b2c@app.fastmail.com> <39444a4e-70da-4d17-a40a-b51e05236d23@app.fastmail.com> Date: Mon, 24 Jul 2023 22:41:26 +0200 From: "Arnd Bergmann" To: "Alexei Starovoitov" , "Arnd Bergmann" Cc: "Yafang Shao" , "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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,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 Mon, Jul 24, 2023, at 21:15, Alexei Starovoitov wrote: > On Mon, Jul 24, 2023 at 11:30=E2=80=AFAM Arnd Bergmann wrote: >> On Mon, Jul 24, 2023, at 20:13, Arnd Bergmann wrote: >> >> I have a minimized test case at https://godbolt.org/z/hK4ev17fv >> that shows the problem happening with all versions of gcc >> (4.1 through 14.0) if I force the dec_active() function to be >> inline and force inc_active() to be non-inline. > > That's a bit of cheating, but I see your point now. > How about we do: > diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c > index 51d6389e5152..3fa0944cb975 100644 > --- a/kernel/bpf/memalloc.c > +++ b/kernel/bpf/memalloc.c > @@ -183,11 +183,11 @@ static void inc_active(struct bpf_mem_cache *c, > unsigned long *flags) > WARN_ON_ONCE(local_inc_return(&c->active) !=3D 1); > } > > -static void dec_active(struct bpf_mem_cache *c, unsigned long flags) > +static void dec_active(struct bpf_mem_cache *c, unsigned long *flags) > { > local_dec(&c->active); > if (IS_ENABLED(CONFIG_PREEMPT_RT)) > - local_irq_restore(flags); > + local_irq_restore(*flags); > } Sure, that's fine. Between this and the two suggestions I had (__always_inline or passing the flags from inc_active as a return code), I don't have a strong preference, so pick whichever you like. Arnd