[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <39444a4e-70da-4d17-a40a-b51e05236d23@app.fastmail.com>
Date: Mon, 24 Jul 2023 20:29:59 +0200
From: "Arnd Bergmann" <arnd@...nel.org>
To: "Arnd Bergmann" <arnd@...db.de>,
"Alexei Starovoitov" <alexei.starovoitov@...il.com>
Cc: "Yafang Shao" <laoar.shao@...il.com>,
"Alexei Starovoitov" <ast@...nel.org>,
"Daniel Borkmann" <daniel@...earbox.net>,
"Andrii Nakryiko" <andrii@...nel.org>,
"Hou Tao" <houtao1@...wei.com>,
"Martin KaFai Lau" <martin.lau@...ux.dev>,
"Song Liu" <song@...nel.org>, "Yonghong Song" <yhs@...com>,
"John Fastabend" <john.fastabend@...il.com>,
"KP Singh" <kpsingh@...nel.org>,
"Stanislav Fomichev" <sdf@...gle.com>,
"Hao Luo" <haoluo@...gle.com>, "Jiri Olsa" <jolsa@...nel.org>,
"Kumar Kartikeya Dwivedi" <memxor@...il.com>,
bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpf: force inc_active()/dec_active() to be inline functions
On Mon, Jul 24, 2023, at 20:13, Arnd Bergmann wrote:
>>> 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.
>>>
>>> >> If we have to change the kernel, what about the change below?
>>> >
>>> > To workaround the compiler bug we can simply init flag=0 to silence
>>> > the warn, but even that is silly. Passing flag=0 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.
>>
>> Which gcc are we talking about here that is so buggy?
>
> I think I only tried versions 8 through 13 for this one, but
> can check others as well.
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.
With clang, I only see the warning if I turn dec_active() into
a macro instead of an inline function. This is the expected
behavior in clang.
Arnd
Powered by blists - more mailing lists