Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp44924rwb; Tue, 25 Jul 2023 11:39:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlFKIS75J2hv+pJ1JEkWEiYTJcI8AW2fNOzokp6v2QSKoI8Y3zoRsIRlOSb1fX5kS7wyk04b X-Received: by 2002:a05:6a00:c95:b0:67a:6af6:5171 with SMTP id a21-20020a056a000c9500b0067a6af65171mr36961pfv.13.1690310381960; Tue, 25 Jul 2023 11:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690310381; cv=none; d=google.com; s=arc-20160816; b=Ftt2nX+fhA8cy0NBQMSQViIwp+YxEtlooqEfquYRhSrkP8MXI0xBxhYwx+JfdWvYWW C3bf01lxZVWY7WjwwsNhf5mUav6hDHNZfiGC6ctUsl9SQfOPgw4lf0KWbcdTFmVQ452+ qQuM5iMVIX32AM1Nrm9YoPXerAjikP5NydmbA3zA8+vL3Rmrr5YmAHc6SNkOQIO+OKRJ DVOiuHJGX4Zlg3ixgTrNucmpFDLX1znbKvZ6W8vyvx2scUSEJ8ZwOKv7T48DCPmZUBEw re+R7qS1lD8nqYo+GBAyNnaUgvsG0XYAlPmxqpwgIlWKydky2p8xB68jKtF6JsQDzIOL 3erA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iaqRX3//yycdBRgF192yYxUc3zXSOhtqD/ETouzUIao=; fh=xwE7nXUiXgseIpKmzVtpSdp1NJED4wgNIs5K9CJNiiM=; b=MoNtXTFadRla35seDd5zxeZXuFSgAZXr5MmN34FefESl1vV5cq6QlIfkD2l058S1np kwZIYy95NiklICDjyP5gb1wpQLnfojT+jQafG4mqXEGU1wFT54MJvQczhas5rDCq1ahD 8beTtVvU3vgYI4U9RIpNdYrSSMRu6LgAmY3tbqMDJvfXv7soFfcwaw3Kj0nTBo3C/pgF OGDrPv602VWACLIc9LVnAUogefVmu4jd6XYQwd1tF7lUzrNXauB1aeZUdU9YgnDPlW7m emmucjaXXIkib6pd3UAX4d7M5S2kO33Ff+/ulRZvgveLAtJmd5XrQaOMtCDPbgvpy5b3 EYkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UprsR88v; 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 f8-20020a056a001ac800b006825b4fae9dsi11387670pfv.166.2023.07.25.11.39.29; Tue, 25 Jul 2023 11:39:41 -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=20221208 header.b=UprsR88v; 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 S229825AbjGYSQL (ORCPT + 99 others); Tue, 25 Jul 2023 14:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjGYSQK (ORCPT ); Tue, 25 Jul 2023 14:16:10 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38371BF8; Tue, 25 Jul 2023 11:16:06 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2b734aea34aso85316141fa.0; Tue, 25 Jul 2023 11:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690308965; x=1690913765; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iaqRX3//yycdBRgF192yYxUc3zXSOhtqD/ETouzUIao=; b=UprsR88vr0GLaBEm8nrwJ1OiSXzsQassFUvc+KgsrGzJlEj+854tG5CVxNN+qHThKV 1XwqZq1COTTyAsvreFr4cRX8MiP2RsvB7BEipMumNR74sGJj3Y+SiGMBaThAasLUDOCb F6WbwSYN3z9P21xMrmlTHciaftTz9xlE2n/7V5P1TzANKbz2TLkcaMABIJq8IGkeK18E +wLa/BnNOs3phVXQ2EtjqMAyAM1DX18xJFdTtWsO+c7is3R/rAr8ze2D2vcqtQtO406K Q29WH+XGb80WkL4x94K298uyANFlWApzsENgWSUdi4mR1qzgTz3XU50b2poc/Ip+5m/Z oeCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690308965; x=1690913765; h=content-transfer-encoding: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=iaqRX3//yycdBRgF192yYxUc3zXSOhtqD/ETouzUIao=; b=Jqh0/bbB+kK0X0OTmIuE5Kk4xTFO4kkNFUNPVFpqX1n85jiZW72B/io5JzonrDSsEb FjUkkeTie0w44j6Zel0k2RoLQzpQBIZkGJ4WvZtRvFQ8rOVlRC0bRBYmWe0Tb6/cCP63 EFjpZkHn2wELht/5aQqpQ+AOFTWSQyKFTgpuK9OsDSNFT2ME6lolcDIlE6xvE3NmxyHn Y/6RA4RvXo6+pQ51x1eWn2TuJzGR3ez/MBMiAhTQhNYuTkFhbfIMFr0qd1SpbRSlEdDu B9XJIxBVjafw0RsEaWUAavHfrqnqer/EOhPl+UKo4utyT+GhPK7qNyqZD5TzaEsG5DGb z/nQ== X-Gm-Message-State: ABy/qLY9i9MeRjXsqAojHQ6tQi6W9MP3ZyjKsW3Vp/gXfahiRL4HperH 6cCzZqD15VTHMFLGVyuJirx7FtmWymCRKTBo1JM= X-Received: by 2002:a2e:9ad2:0:b0:2b5:9d78:213e with SMTP id p18-20020a2e9ad2000000b002b59d78213emr10958148ljj.22.1690308964744; Tue, 25 Jul 2023 11:16:04 -0700 (PDT) MIME-Version: 1.0 References: <20230722074753.568696-1-arnd@kernel.org> <679d8d63-ce92-4294-8620-e98c82365b2c@app.fastmail.com> <39444a4e-70da-4d17-a40a-b51e05236d23@app.fastmail.com> <3e202277-fe74-4105-93ec-b646efaaa956@app.fastmail.com> In-Reply-To: <3e202277-fe74-4105-93ec-b646efaaa956@app.fastmail.com> From: Alexei Starovoitov Date: Tue, 25 Jul 2023 11:15:53 -0700 Message-ID: Subject: Re: [PATCH] bpf: force inc_active()/dec_active() to be inline functions To: Arnd Bergmann Cc: Arnd Bergmann , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, URIBL_BLOCKED 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 1:41=E2=80=AFPM Arnd Bergmann wrote= : > > 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. I think: static void dec_active(struct bpf_mem_cache *c, unsigned long *flags) is cleaner. Could you send a patch?