From: "Arnd Bergmann" <arnd@arndb.de>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
"Arnd Bergmann" <arnd@kernel.org>
Cc: "Yafang Shao" <laoar.shao@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Hou Tao" <houtao1@huawei.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@google.com>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: force inc_active()/dec_active() to be inline functions
Date: Mon, 24 Jul 2023 22:41:26 +0200 [thread overview]
Message-ID: <3e202277-fe74-4105-93ec-b646efaaa956@app.fastmail.com> (raw)
In-Reply-To: <CAADnVQ+zdV9+UNV9NeEzY2rWd8qvW3cvHxS9mYwfhnqZOV+9=A@mail.gmail.com>
On Mon, Jul 24, 2023, at 21:15, Alexei Starovoitov wrote:
> On Mon, Jul 24, 2023 at 11:30 AM Arnd Bergmann <arnd@kernel.org> 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) != 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
next prev parent reply other threads:[~2023-07-24 20:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-22 7:47 [PATCH] bpf: force inc_active()/dec_active() to be inline functions Arnd Bergmann
2023-07-23 14:24 ` Yafang Shao
2023-07-23 16:46 ` Alexei Starovoitov
2023-07-23 18:31 ` Arnd Bergmann
2023-07-24 18:00 ` Alexei Starovoitov
2023-07-24 18:13 ` Arnd Bergmann
2023-07-24 18:29 ` Arnd Bergmann
2023-07-24 19:15 ` Alexei Starovoitov
2023-07-24 20:41 ` Arnd Bergmann [this message]
2023-07-25 18:15 ` Alexei Starovoitov
2023-07-25 20:27 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e202277-fe74-4105-93ec-b646efaaa956@app.fastmail.com \
--to=arnd@arndb.de \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=arnd@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=houtao1@huawei.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox