linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: modify inline asm constraints in __cmpxchg_double()
@ 2018-10-15  8:48 Juergen Gross
  2018-10-16  6:25 ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-10-15  8:48 UTC (permalink / raw)
  To: linux-kernel, x86; +Cc: hpa, tglx, mingo, bp, Juergen Gross

Some gcc versions seem to have problems with the constraints in
__cmpxchg_double() as they suddenly issue a build error when random
parts of sources calling __cmpxchg_double() are modified, like e.g.
slub.c. This has been observed on Debian systems only so far.

Using "0" instead of "a" in the input constraints has the same
semantics while avoiding that build error.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
I should note that I have observed gcc hangs instead sometimes. Not
taking any patches modifying users of __cmpxchg_double() due to a gcc
bug which seems to be distro-specific is a bad move IMO.

I'd rather make it clear from build behavior that this is a bug in gcc
by letting the build hang instead of throwing error warnings not in any
way related to changes in the code.

The gcc bug is filed under:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908154
---
 arch/x86/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index a55d79b233d3..b3b4d61a8969 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -245,7 +245,7 @@ extern void __add_wrong_size(void)
 	asm volatile(pfx "cmpxchg%c4b %2; sete %0"			\
 		     : "=a" (__ret), "+d" (__old2),			\
 		       "+m" (*(p1)), "+m" (*(p2))			\
-		     : "i" (2 * sizeof(long)), "a" (__old1),		\
+		     : "i" (2 * sizeof(long)), "0" (__old1),		\
 		       "b" (__new1), "c" (__new2));			\
 	__ret;								\
 })
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: modify inline asm constraints in __cmpxchg_double()
  2018-10-15  8:48 [PATCH] x86: modify inline asm constraints in __cmpxchg_double() Juergen Gross
@ 2018-10-16  6:25 ` Ingo Molnar
  2018-10-16  7:43   ` Juergen Gross
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2018-10-16  6:25 UTC (permalink / raw)
  To: Juergen Gross; +Cc: linux-kernel, x86, hpa, tglx, mingo, bp


* Juergen Gross <jgross@suse.com> wrote:

> Some gcc versions seem to have problems with the constraints in
> __cmpxchg_double() as they suddenly issue a build error when random
> parts of sources calling __cmpxchg_double() are modified, like e.g.
> slub.c. This has been observed on Debian systems only so far.
> 
> Using "0" instead of "a" in the input constraints has the same
> semantics while avoiding that build error.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> I should note that I have observed gcc hangs instead sometimes. Not
> taking any patches modifying users of __cmpxchg_double() due to a gcc
> bug which seems to be distro-specific is a bad move IMO.
> 
> I'd rather make it clear from build behavior that this is a bug in gcc
> by letting the build hang instead of throwing error warnings not in any
> way related to changes in the code.
> 
> The gcc bug is filed under:
> 
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908154
> ---
>  arch/x86/include/asm/cmpxchg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
> index a55d79b233d3..b3b4d61a8969 100644
> --- a/arch/x86/include/asm/cmpxchg.h
> +++ b/arch/x86/include/asm/cmpxchg.h
> @@ -245,7 +245,7 @@ extern void __add_wrong_size(void)
>  	asm volatile(pfx "cmpxchg%c4b %2; sete %0"			\
>  		     : "=a" (__ret), "+d" (__old2),			\
>  		       "+m" (*(p1)), "+m" (*(p2))			\
> -		     : "i" (2 * sizeof(long)), "a" (__old1),		\
> +		     : "i" (2 * sizeof(long)), "0" (__old1),		\
>  		       "b" (__new1), "c" (__new2));			\

This got changed to +a in -tip:

  c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()

Mind sending a patch on top of -tip?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: modify inline asm constraints in __cmpxchg_double()
  2018-10-16  6:25 ` Ingo Molnar
@ 2018-10-16  7:43   ` Juergen Gross
  2018-10-16  8:01     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-10-16  7:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, x86, hpa, tglx, mingo, bp

On 16/10/2018 08:25, Ingo Molnar wrote:
> 
> * Juergen Gross <jgross@suse.com> wrote:
> 
>> Some gcc versions seem to have problems with the constraints in
>> __cmpxchg_double() as they suddenly issue a build error when random
>> parts of sources calling __cmpxchg_double() are modified, like e.g.
>> slub.c. This has been observed on Debian systems only so far.
>>
>> Using "0" instead of "a" in the input constraints has the same
>> semantics while avoiding that build error.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> I should note that I have observed gcc hangs instead sometimes. Not
>> taking any patches modifying users of __cmpxchg_double() due to a gcc
>> bug which seems to be distro-specific is a bad move IMO.
>>
>> I'd rather make it clear from build behavior that this is a bug in gcc
>> by letting the build hang instead of throwing error warnings not in any
>> way related to changes in the code.
>>
>> The gcc bug is filed under:
>>
>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908154
>> ---
>>  arch/x86/include/asm/cmpxchg.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
>> index a55d79b233d3..b3b4d61a8969 100644
>> --- a/arch/x86/include/asm/cmpxchg.h
>> +++ b/arch/x86/include/asm/cmpxchg.h
>> @@ -245,7 +245,7 @@ extern void __add_wrong_size(void)
>>  	asm volatile(pfx "cmpxchg%c4b %2; sete %0"			\
>>  		     : "=a" (__ret), "+d" (__old2),			\
>>  		       "+m" (*(p1)), "+m" (*(p2))			\
>> -		     : "i" (2 * sizeof(long)), "a" (__old1),		\
>> +		     : "i" (2 * sizeof(long)), "0" (__old1),		\
>>  		       "b" (__new1), "c" (__new2));			\
> 
> This got changed to +a in -tip:
> 
>   c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
> 
> Mind sending a patch on top of -tip?

No, I think you can drop my patch.

c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
has the same effect as my patch: the build failure is replaced by
gcc hanging instead in the critical configuration.


Juergen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: modify inline asm constraints in __cmpxchg_double()
  2018-10-16  7:43   ` Juergen Gross
@ 2018-10-16  8:01     ` Ingo Molnar
  2018-10-17  9:09       ` Juergen Gross
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2018-10-16  8:01 UTC (permalink / raw)
  To: Juergen Gross; +Cc: linux-kernel, x86, hpa, tglx, mingo, bp


* Juergen Gross <jgross@suse.com> wrote:

> On 16/10/2018 08:25, Ingo Molnar wrote:
> > 
> > * Juergen Gross <jgross@suse.com> wrote:
> > 
> >> Some gcc versions seem to have problems with the constraints in
> >> __cmpxchg_double() as they suddenly issue a build error when random
> >> parts of sources calling __cmpxchg_double() are modified, like e.g.
> >> slub.c. This has been observed on Debian systems only so far.
> >>
> >> Using "0" instead of "a" in the input constraints has the same
> >> semantics while avoiding that build error.
> >>
> >> Signed-off-by: Juergen Gross <jgross@suse.com>
> >> ---
> >> I should note that I have observed gcc hangs instead sometimes. Not
> >> taking any patches modifying users of __cmpxchg_double() due to a gcc
> >> bug which seems to be distro-specific is a bad move IMO.
> >>
> >> I'd rather make it clear from build behavior that this is a bug in gcc
> >> by letting the build hang instead of throwing error warnings not in any
> >> way related to changes in the code.
> >>
> >> The gcc bug is filed under:
> >>
> >> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908154
> >> ---
> >>  arch/x86/include/asm/cmpxchg.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
> >> index a55d79b233d3..b3b4d61a8969 100644
> >> --- a/arch/x86/include/asm/cmpxchg.h
> >> +++ b/arch/x86/include/asm/cmpxchg.h
> >> @@ -245,7 +245,7 @@ extern void __add_wrong_size(void)
> >>  	asm volatile(pfx "cmpxchg%c4b %2; sete %0"			\
> >>  		     : "=a" (__ret), "+d" (__old2),			\
> >>  		       "+m" (*(p1)), "+m" (*(p2))			\
> >> -		     : "i" (2 * sizeof(long)), "a" (__old1),		\
> >> +		     : "i" (2 * sizeof(long)), "0" (__old1),		\
> >>  		       "b" (__new1), "c" (__new2));			\
> > 
> > This got changed to +a in -tip:
> > 
> >   c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
> > 
> > Mind sending a patch on top of -tip?
> 
> No, I think you can drop my patch.
> 
> c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
> has the same effect as my patch: the build failure is replaced by
> gcc hanging instead in the critical configuration.

Ok. No sane workaround we can do to avoid the hang I suspect, right?

Should we propagate the fix/enhancement to x86/urgent? It's currently in 
x86/asm for a v4.20 merge.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: modify inline asm constraints in __cmpxchg_double()
  2018-10-16  8:01     ` Ingo Molnar
@ 2018-10-17  9:09       ` Juergen Gross
  0 siblings, 0 replies; 5+ messages in thread
From: Juergen Gross @ 2018-10-17  9:09 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, x86, hpa, tglx, mingo, bp

On 16/10/2018 10:01, Ingo Molnar wrote:
> 
> * Juergen Gross <jgross@suse.com> wrote:
> 
>> On 16/10/2018 08:25, Ingo Molnar wrote:
>>>
>>> * Juergen Gross <jgross@suse.com> wrote:
>>>
>>>> Some gcc versions seem to have problems with the constraints in
>>>> __cmpxchg_double() as they suddenly issue a build error when random
>>>> parts of sources calling __cmpxchg_double() are modified, like e.g.
>>>> slub.c. This has been observed on Debian systems only so far.
>>>>
>>>> Using "0" instead of "a" in the input constraints has the same
>>>> semantics while avoiding that build error.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>> ---
>>>> I should note that I have observed gcc hangs instead sometimes. Not
>>>> taking any patches modifying users of __cmpxchg_double() due to a gcc
>>>> bug which seems to be distro-specific is a bad move IMO.
>>>>
>>>> I'd rather make it clear from build behavior that this is a bug in gcc
>>>> by letting the build hang instead of throwing error warnings not in any
>>>> way related to changes in the code.
>>>>
>>>> The gcc bug is filed under:
>>>>
>>>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908154
>>>> ---
>>>>  arch/x86/include/asm/cmpxchg.h | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
>>>> index a55d79b233d3..b3b4d61a8969 100644
>>>> --- a/arch/x86/include/asm/cmpxchg.h
>>>> +++ b/arch/x86/include/asm/cmpxchg.h
>>>> @@ -245,7 +245,7 @@ extern void __add_wrong_size(void)
>>>>  	asm volatile(pfx "cmpxchg%c4b %2; sete %0"			\
>>>>  		     : "=a" (__ret), "+d" (__old2),			\
>>>>  		       "+m" (*(p1)), "+m" (*(p2))			\
>>>> -		     : "i" (2 * sizeof(long)), "a" (__old1),		\
>>>> +		     : "i" (2 * sizeof(long)), "0" (__old1),		\
>>>>  		       "b" (__new1), "c" (__new2));			\
>>>
>>> This got changed to +a in -tip:
>>>
>>>   c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
>>>
>>> Mind sending a patch on top of -tip?
>>
>> No, I think you can drop my patch.
>>
>> c808c09b527c: x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()
>> has the same effect as my patch: the build failure is replaced by
>> gcc hanging instead in the critical configuration.
> 
> Ok. No sane workaround we can do to avoid the hang I suspect, right?

I'm not aware of any.

> Should we propagate the fix/enhancement to x86/urgent? It's currently in 
> x86/asm for a v4.20 merge.

My patch triggering the issue is queued for 4.20, too.

There might be other constellations triggering it, but I haven't
seen any yet.


Juergen

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-17  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-15  8:48 [PATCH] x86: modify inline asm constraints in __cmpxchg_double() Juergen Gross
2018-10-16  6:25 ` Ingo Molnar
2018-10-16  7:43   ` Juergen Gross
2018-10-16  8:01     ` Ingo Molnar
2018-10-17  9:09       ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).