qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Spyridakis <a.spyridakis@virtualopensystems.com>
To: Andrew Jones <drjones@redhat.com>
Cc: mttcg@greensocs.com,
	Alexander Spyridakis <a.spyridakis@virtualopensystems.com>,
	Claudio Fontana <claudio.fontana@huawei.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Jani Kokkonen <jani.kokkonen@huawei.com>,
	"tech@virtualopensystems.com" <tech@virtualopensystems.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] atomic-test: Add spinlock test case
Date: Mon, 11 May 2015 12:41:51 +0200	[thread overview]
Message-ID: <CAJRNFKJ5OPr4+qY2ayQ7o9i8joiG_dupf5Rb0C+ExQdd1vY=Ug@mail.gmail.com> (raw)
In-Reply-To: <20150511101740.GA2923@localhost.localdomain>

Hi Andrew,

On 11 May 2015 at 12:17, Andrew Jones <drjones@redhat.com> wrote:
> > +
> > +void atomic_lock(int *lock_var)
> > +{
> > +    while (__sync_lock_test_and_set(lock_var, 1));
> > +}
> > +
> > +void atomic_unlock(int *lock_var)
> > +{
> > +    __sync_lock_release(lock_var);
> > +}
>
> Do these builtins actually do anything without enabling the
> MMU first?

>From my experience while testing on ARM, without the builtins
atomicity will fail, with our without enabling the MMU.

> > +
> > +void test_spinlock()
> > +{
> > +    int i, errors = 0;
> > +    int cpu = get_cpuid();
> > +
> > +    for (i = 0; i < LOOP_SIZE; i++) {
> > +        LOCK(&global_lock);
> > +
> > +        if (global_a == (cpu + 1) % 2) {
> > +            global_a = 1;
> > +            global_b = 0;
> > +        } else {
> > +            global_a = 0;
> > +            global_b = 1;
> > +        }
> > +
> > +        if (global_a == global_b) {
> > +            errors++;
> > +        }
> > +        UNLOCK(&global_lock);
> > +    }
> > +
> > +    printf("CPU%d: Done - Errors: %d\n", cpu, errors);
> > +}
> > +
> >  void main(void)
> >  {
> > -    printf("CPU %d on\n", get_cpuid());
> > +    if (!get_cpuid()) {
> > +            printf("Starting test\n");
> > +    }
> > +
> > +    test_spinlock();
> >      power_off();
> >  }
>
> You could have saved a ton of time by just putting these 50
> lines into a new kvm-unit-tests test. If you need the mmu
> disabled for some reason, then we can add an mmu_disable()
> to the API.
>
> drew

The main idea is to start with something very minimal and
straightforward for a standalone test similar to the QEMU's multiboot,
since the target is to mainly trigger race conditions and test
multithreaded TCG.

Thanks.

  reply	other threads:[~2015-05-11 10:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 11:31 [Qemu-devel] [PATCH RFC 0/2] virt bare-metal payload infrastructure with atomic test case Alexander Spyridakis
2015-05-07 11:31 ` [Qemu-devel] [PATCH RFC 1/2] atomic-test: Implement ARM and AARCH64 basic bare-metal infrastructure Alexander Spyridakis
2015-05-07 11:31 ` [Qemu-devel] [PATCH 2/2] atomic-test: Add spinlock test case Alexander Spyridakis
2015-05-11 10:17   ` Andrew Jones
2015-05-11 10:41     ` Alexander Spyridakis [this message]
2015-05-07 12:55 ` [Qemu-devel] [PATCH RFC 0/2] virt bare-metal payload infrastructure with atomic " Paolo Bonzini
2015-05-11 10:58   ` Alexander Spyridakis

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='CAJRNFKJ5OPr4+qY2ayQ7o9i8joiG_dupf5Rb0C+ExQdd1vY=Ug@mail.gmail.com' \
    --to=a.spyridakis@virtualopensystems.com \
    --cc=claudio.fontana@huawei.com \
    --cc=drjones@redhat.com \
    --cc=jani.kokkonen@huawei.com \
    --cc=mttcg@greensocs.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.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).