DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: "Morten Brørup" <mb@smartsharesystems.com>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
	"David Marchand" <david.marchand@redhat.com>
Cc: dev@dpdk.org, Luka Jankovic <luka.jankovic@ericsson.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [PATCH] bitops: fix issue in parallel atomic tests
Date: Sun, 13 Oct 2024 17:19:56 +0200	[thread overview]
Message-ID: <56e72271-2e4c-4ea4-b7b4-e7662202116c@lysator.liu.se> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F7CD@smartserver.smartshare.dk>

On 2024-10-13 15:37, Morten Brørup wrote:
>> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com]
>> Sent: Sunday, 13 October 2024 13.57
>>
>> The macros generating the parallel test for atomic test-and-
>> [set|clear|flip] functions used a 64-bit reference word when assuring
>> no neighbouring bits were modified, even when generating code for the
>> 32-bit version of the test.
>>
>> This issue causes spurious test failures on GCC 12.2.0 (the default
>> compiler on for example Debian 12 "bookworm"), when optimization level
>> 2 or higher are used.
>>
>> The test failures do not occur with GCC 11, 12.3 and 13.2.
>>
>> To the author, this looks like a promotion-related compiler bug in GCC
>> 12.2.
> 
> I am curious about the compiler bug...
> 
> Did the bug occur when the most significant bit was set, so it sign related?
> 

It seems to happen a lot more often than 1/32 times. Also, all involved 
types are unsigned.

If you set the optimization level to "1" (i.e., 
__attribute__((optimize("O"))) on the 
test_bit_atomic_parallel_test_and_modify32 function, the test passes on 
12.2.0.

> Maybe this will reveal something:
> 
> TEST_ASSERT(expected_word == word,
>    "Untouched bits have changed value, %" PRIx ## size
>    " should be %" PRIx64,
>    word, expected_word);
> 

Confusingly enough, the failing assertion is the one prior that assertion.

>>
>> Fixes: 35326b61aecb ("bitops: add atomic bit operations in new API")
>>
>> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
>> ---
> 
> I took a deep look into this.
> 
> Regardless of what the compiler bug is,
> 
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
> 

Thanks.

I'm far from sure it's a compiler bug. Just look at the base rate: how 
often does the code you just wrote fail because of a bug in your code, 
and how often is the root cause to be found in the compiler or the 
standard libraries.



  reply	other threads:[~2024-10-13 15:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-13 11:57 Mattias Rönnblom
2024-10-13 13:37 ` Morten Brørup
2024-10-13 15:19   ` Mattias Rönnblom [this message]
2024-10-13 15:36     ` Morten Brørup
2024-10-14 14:16       ` David Marchand
2024-10-14 14:33         ` Mattias Rönnblom
2024-10-14 14:14 ` David Marchand

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=56e72271-2e4c-4ea4-b7b4-e7662202116c@lysator.liu.se \
    --to=hofors@lysator.liu.se \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=luka.jankovic@ericsson.com \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).