From: Edward Liaw via ltp <ltp@lists.linux.it>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: kernel-team@android.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] syscalls/signal06: add volatile to loop variable
Date: Wed, 27 Jul 2022 14:37:26 -0700 [thread overview]
Message-ID: <CAG4es9Wn+wZRu6xr-FgZ=pTq4ReGdrmsmGYO4ZXvKj8ee3QH8w@mail.gmail.com> (raw)
In-Reply-To: <YtaFddMFjVPMTpme@rei>
Hey Cyril, sorry for the late reply, I was on vacation.
On Tue, Jul 19, 2022 at 3:19 AM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > On Android compiled with clang, the loop variable will be optimized out
> > unless it is tagged with volatile.
>
> Looking at the code it looks strange that it's optimized out since we
> use the value for the loop as:
>
> loop = 0;
>
> D = VALUE;
> while (D == VALUE && loop < LOOPS) {
> asm(...);
> loop++;
> }
>
> And the D variable is properly marked as volatile so it's not like the
> loop can be expected to iterate preciselly LOOPS iterations.
>
> It looks to me like the compiler actually forgets about the volatility
> of D for some reason and then assumes that the loop does LOOPS
> iterations.
I'm not totally sure how the compiler is working in this case.
What I saw with Android is that it fails with:
signal06 0 TINFO : loop = 2076174312
signal06 1 TFAIL :
external/ltp/testcases/kernel/syscalls/signal/signal06.c:87: Bug
Reproduced!
It makes one iteration, then loop is set to a random large int and the
loop terminates. Printing the value of loop inside the for loop
actually caused it to iterate 30000 times and succeed.
Compared to a successful run, which looks like:
signal06 0 TINFO : loop = 30000
signal06 1 TPASS : signal06 call succeeded
Thanks,
Edward
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-07-27 21:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 17:39 [LTP] [PATCH v1] syscalls/signal06: add volatile to loop variable Edward Liaw via ltp
2022-07-13 12:48 ` Petr Vorel
2022-07-19 10:20 ` Cyril Hrubis
2022-07-27 21:37 ` Edward Liaw via ltp [this message]
2022-08-11 15:24 ` Edward Liaw via ltp
2022-08-11 15:33 ` Cyril Hrubis
2022-08-16 12:43 ` Petr Vorel
2022-08-16 23:00 ` Edward Liaw via ltp
2022-08-17 9:12 ` Petr Vorel
2022-08-17 15:04 ` Edward Liaw via ltp
2022-08-18 21:18 ` Edward Liaw via ltp
2022-08-19 8:12 ` Petr Vorel
2022-08-19 8:41 ` Cyril Hrubis
2022-08-19 9:02 ` Cyril Hrubis
2022-08-19 9:14 ` Joerg Vehlow
2022-08-19 9:21 ` Cyril Hrubis
2022-08-19 10:40 ` Petr Vorel
2022-08-19 18:13 ` Edward Liaw via ltp
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='CAG4es9Wn+wZRu6xr-FgZ=pTq4ReGdrmsmGYO4ZXvKj8ee3QH8w@mail.gmail.com' \
--to=ltp@lists.linux.it \
--cc=chrubis@suse.cz \
--cc=edliaw@google.com \
--cc=kernel-team@android.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;
as well as URLs for NNTP newsgroup(s).