2020-03-31 08:56:54

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the akpm-current tree

Hi all,

After merging the akpm-current tree, today's linux-next build (i386
defconfig) produced this warning:

mm/hugetlb.c: In function 'huge_pte_offset':
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
mm/hugetlb.c:5361:14: note: declared here
5361 | pud_t *pud, pud_entry;
| ^~~~~~~~~
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
mm/hugetlb.c:5360:14: note: declared here
5360 | p4d_t *p4d, p4d_entry;
| ^~~~~~~~~

Introduced by commit

826ddc88e2cf ("mm/hugetlb: fix a addressing exception caused by huge_pte_offset")

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2020-04-01 23:12:31

by Andrew Morton

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Tue, 31 Mar 2020 19:56:12 +1100 Stephen Rothwell <[email protected]> wrote:

> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (i386
> defconfig) produced this warning:
>
> mm/hugetlb.c: In function 'huge_pte_offset':
> cc1: warning: function may return address of local variable [-Wreturn-local-addr]
> mm/hugetlb.c:5361:14: note: declared here
> 5361 | pud_t *pud, pud_entry;
> | ^~~~~~~~~
> cc1: warning: function may return address of local variable [-Wreturn-local-addr]
> mm/hugetlb.c:5360:14: note: declared here
> 5360 | p4d_t *p4d, p4d_entry;
> | ^~~~~~~~~
>
> Introduced by commit
>
> 826ddc88e2cf ("mm/hugetlb: fix a addressing exception caused by huge_pte_offset")

I can reproduce this (i386 defconfig, gcc-7.2.0).

I can see no way in which this makes any sense. Hopefully it's a gcc
bug but it's hard to see how it could have messed up this fairly simple
code.

2020-04-01 23:13:01

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Wed, Apr 01, 2020 at 03:58:31PM -0700, Andrew Morton wrote:
> On Tue, 31 Mar 2020 19:56:12 +1100 Stephen Rothwell <[email protected]> wrote:
>
> > Hi all,
> >
> > After merging the akpm-current tree, today's linux-next build (i386
> > defconfig) produced this warning:
> >
> > mm/hugetlb.c: In function 'huge_pte_offset':
> > cc1: warning: function may return address of local variable [-Wreturn-local-addr]
> > mm/hugetlb.c:5361:14: note: declared here
> > 5361 | pud_t *pud, pud_entry;
> > | ^~~~~~~~~
> > cc1: warning: function may return address of local variable [-Wreturn-local-addr]
> > mm/hugetlb.c:5360:14: note: declared here
> > 5360 | p4d_t *p4d, p4d_entry;
> > | ^~~~~~~~~
> >
> > Introduced by commit
> >
> > 826ddc88e2cf ("mm/hugetlb: fix a addressing exception caused by huge_pte_offset")
>
> I can reproduce this (i386 defconfig, gcc-7.2.0).
>
> I can see no way in which this makes any sense. Hopefully it's a gcc
> bug but it's hard to see how it could have messed up this fairly simple
> code.

It is a code bug, there was a little thread about this. It happens
because the address of a stack variable is passed into the pXX_offset
functions which return that address when the page levels are folded.

I recommend to drop this patch until it is adjusted..

Jason

2020-04-01 23:20:48

by Mike Kravetz

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On 4/1/20 4:00 PM, Jason Gunthorpe wrote:
> On Wed, Apr 01, 2020 at 03:58:31PM -0700, Andrew Morton wrote:
>> On Tue, 31 Mar 2020 19:56:12 +1100 Stephen Rothwell <[email protected]> wrote:
>>
>>> Hi all,
>>>
>>> After merging the akpm-current tree, today's linux-next build (i386
>>> defconfig) produced this warning:
>>>
>>> mm/hugetlb.c: In function 'huge_pte_offset':
>>> cc1: warning: function may return address of local variable [-Wreturn-local-addr]
>>> mm/hugetlb.c:5361:14: note: declared here
>>> 5361 | pud_t *pud, pud_entry;
>>> | ^~~~~~~~~
>>> cc1: warning: function may return address of local variable [-Wreturn-local-addr]
>>> mm/hugetlb.c:5360:14: note: declared here
>>> 5360 | p4d_t *p4d, p4d_entry;
>>> | ^~~~~~~~~
>>>
>>> Introduced by commit
>>>
>>> 826ddc88e2cf ("mm/hugetlb: fix a addressing exception caused by huge_pte_offset")
>>
>> I can reproduce this (i386 defconfig, gcc-7.2.0).
>>
>> I can see no way in which this makes any sense. Hopefully it's a gcc
>> bug but it's hard to see how it could have messed up this fairly simple
>> code.
>
> It is a code bug, there was a little thread about this. It happens
> because the address of a stack variable is passed into the pXX_offset
> functions which return that address when the page levels are folded.
>
> I recommend to drop this patch until it is adjusted..

Yes, this patch causes at least the BUG here,

https://lore.kernel.org/linux-mm/CA+G9fYsJgZhhWLMzUxu_ZQ+THdCcJmFbHQ2ETA_YPP8M6yxOYA@mail.gmail.com/

--
Mike Kravetz