All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Züpke" <alexander.zuepke@hs-rm.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] QEMU ARM SMP: IPI delivery delayed until next main loop event // how to improve IPI latency?
Date: Mon, 15 Jun 2015 17:05:23 +0200	[thread overview]
Message-ID: <557EE9B3.1030606@hs-rm.de> (raw)
In-Reply-To: <CAFEAcA_W6KtcnEAb+K_wcqXn8QZs968ziNEF2c+qqP-YAKqeYw@mail.gmail.com>

Am 15.06.2015 um 16:51 schrieb Peter Maydell:
> On 15 June 2015 at 15:44, Alex Züpke <alexander.zuepke@hs-rm.de> wrote:
>> Am 12.06.2015 um 20:03 schrieb Peter Maydell:
>>> Probably the best approach would be to have something in
>>> arm_cpu_set_irq() which says "if we are CPU X and we've
>>> just caused an interrupt to be set for CPU Y, then we
>>> should ourselves yield back to the main loop".
>>>
>>> Something like this, maybe, though I have done no more testing
>>> than checking it doesn't actively break kernel booting :-)
>>
>>
>> Thanks! One more check for "level" is needed to get it work:
> 
> What happens without that? It's reasonable to have it,
> but extra cpu_exit()s shouldn't cause a problem beyond
> being a bit inefficient...

The emulation get's stuck, for whatever reason I don't understand.
I checked if something similar is done on other architectures and found 
that the level check is missing, see for example cpu_request_exit() in hw/ppc/prep.c:
  static void cpu_request_exit(void *opaque, int irq, int level)
  {
      CPUState *cpu = current_cpu;

      if (cpu && level) {
          cpu_exit(cpu);
      }
  }

But probably this is used for something completely unrelated.

> It would be interesting to know if this helps Linux as well
> as your custom OS. (I don't know whether a "CPU #0 polls"
> approach is bad on hardware too; the other option would be
> to have CPU #1 IPI back in the other direction if 0 needed
> to wait for a response.)
> 
> -- PMM

IIRC, Linux TLB shootdown on x86 once used such a scheme, but I don't know if they changed it.

I'd say that an IPI+poll pattern is used quite often in the tricky parts of a kernel, like kernel debugging.



Here's a simple IPI tester sending IPIs from CPU #0 to CPU #1 in an endless loop.
The IPIs are delayed until the timer interrupt triggers the main loop.

http://www.cs.hs-rm.de/~zuepke/qemu/ipi.elf
3174 bytes, md5sum 8d73890a60cd9b24a4f9139509b580e2

Run testcase:
$ qemu-system-arm -M vexpress-a15 -smp 2 -kernel ipi.elf -nographic

The testcase prints the following on the serial console without the patch:

  +------- CPU 0 came up
  |+------ CPU 0 initialization completed
  || +---- CPU 0 timer interrupt, 1 HZ
  || |
  vv v
  0!1T.T.T.T.T.T.T.
    ^ ^
    | |
    | +-- CPU 1 received an IPI
    +---- CPU 1 came up


Expected testcase output with patch:

  0!1T..............<hundreds of dots>.................T...............

So: more dots == more IPIs handled between two timer interrupts "T" ...



Best regards
Alex

  reply	other threads:[~2015-06-15 15:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 16:38 [Qemu-devel] QEMU ARM SMP: IPI delivery delayed until next main loop event // how to improve IPI latency? Alex Züpke
2015-06-12 18:03 ` Peter Maydell
2015-06-15 14:44   ` Alex Züpke
2015-06-15 14:51     ` Peter Maydell
2015-06-15 15:05       ` Alex Züpke [this message]
2015-06-15 18:41         ` Peter Maydell
2015-06-15 18:58         ` Peter Maydell
2015-06-15 20:03           ` Alex Zuepke
2015-06-16 10:33             ` Peter Maydell
2015-06-16 10:59               ` Peter Maydell
2015-06-16 11:11                 ` Alex Züpke
2015-06-16 11:53                   ` Peter Maydell
2015-06-16 12:21                     ` Alex Züpke
2015-06-19 15:53                     ` Peter Maydell
2015-06-23  7:31                       ` Frederic Konrad
2015-06-23  8:09                         ` Peter Maydell
2015-06-23  8:33                           ` Frederic Konrad
2015-06-23 18:15                         ` Peter Maydell
2015-06-25 17:13                           ` Peter Maydell
2015-06-15 15:04 ` Peter Maydell
2015-06-15 15:07   ` Alex Züpke
2015-06-15 15:18     ` Peter Maydell
2015-06-15 15:36       ` Alex Züpke
2015-06-15 15:49         ` Peter Maydell
2015-06-15 16:12           ` Alex Züpke
2015-06-15 21:39           ` Peter Crosthwaite
2015-06-19 16:57 ` Paolo Bonzini
2015-06-19 17:25   ` Peter Maydell

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=557EE9B3.1030606@hs-rm.de \
    --to=alexander.zuepke@hs-rm.de \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.