qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Pavel Dovgalyuk" <dovgaluk@ispras.ru>
To: 'Max Filippov' <jcmvbkbc@gmail.com>,
	'Pavel Dovgaluk' <Pavel.Dovgaluk@ispras.ru>,
	'qemu-devel' <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] regression in timer code?
Date: Wed, 14 Mar 2018 12:07:42 +0300	[thread overview]
Message-ID: <000301d3bb73$e997a8e0$bcc6faa0$@ru> (raw)
In-Reply-To: <CAMo8BfLuAdsdRScY+CgTzd0EBn3_kAFc=ysEwgp3MrM_+42viQ@mail.gmail.com>

> From: Max Filippov [mailto:jcmvbkbc@gmail.com]
> the commit b39e3f34c9de7ead6a11a74aa2de78baf41d81a7
> ("icount: fixed saving/restoring of icount warp timers") has changed
> something that made timers test for target/xtensa unstable.
> Specifically ccount_write case in the tests/tcg/xtensa/test_timer.S
> now fails for me about half of the times it is run. Given that it is run
> under -icount I guess this is a bug. Could you please take a look?
> 
> The minimal test case is available here:
>   http://jcmvbkbc.spb.ru/~dumb/tmp/201803131306/test_timer.tst
> It is run as
>   qemu-system-xtensa -M sim -cpu dc232b -nographic -semihosting
> -icount 7  -kernel ./test_timer.tst

I investigated your test and concluded the following.
First, update_ccount is inaccurate opration because of the division
with the remainder:
    env->sregs[CCOUNT] = env->ccount_base +
        (uint32_t)((now - env->time_base) *
                   env->config->clock_freq_khz / 1000000);

Therefore, the following sequence in the test may give different result depending
of the actual value of "now" variable.
    rsr     a3, ccount
    rsr     a4, ccount
    sub     a4, a4, a3

Consider the code:

test ccount_write
    rsr     a3, ccount
    rsr     a4, ccount
    sub     a4, a4, a3 ; usually 1, but sometimes 2 because of rounding
    movi    a2, 0x12345678
    wsr     a2, ccount
    esync
    rsr     a3, ccount
    sub     a3, a3, a2 ; usually 3 (esync + yield + rsr), but sometimes 4 because of rounding
    slli    a4, a4, 2  ; 4 or 8
    assert  ltu, a3, a4 ; (3 or 4) < (4 or 8) ?
test_end

Therefore in some cases we get a4=4 and a3=4 that forces the test to fail.

Pavel Dovgalyuk

  reply	other threads:[~2018-03-14  9:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 20:09 [Qemu-devel] regression in timer code? Max Filippov
2018-03-14  9:07 ` Pavel Dovgalyuk [this message]
2018-03-14  9:40   ` Max Filippov
2018-03-14  9:53     ` Pavel Dovgalyuk
2018-03-14 10:27       ` Max Filippov
2018-03-15  6:09         ` Pavel Dovgalyuk
2018-03-15  8:02           ` Max Filippov

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='000301d3bb73$e997a8e0$bcc6faa0$@ru' \
    --to=dovgaluk@ispras.ru \
    --cc=Pavel.Dovgaluk@ispras.ru \
    --cc=jcmvbkbc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).