From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] Fixing CPU Hotplug for RealView Platforms
Date: Sat, 18 Dec 2010 17:44:47 +0000 [thread overview]
Message-ID: <1292694287.4266.15.camel@jazzbox> (raw)
In-Reply-To: <20101218171039.GK9937@n2100.arm.linux.org.uk>
Hi Russell,
Thanks for looking into this.
On Sat, 2010-12-18 at 17:10 +0000, Russell King - ARM Linux wrote:
> Boot time bringup:
>
[...]
> CPU2 and CPU3 have very similar boot timings, so I'm pretty happy that
> this timing is reliable.
>
Looks sane.
> Hotplug bringup:
>
> Booting: 1000 -> 0ns 0ns (1us per print)
> Restarting: 3976375 -> 3.976375ms
> cross call: 3976625 -> 3.976625ms
> Up: 4003125 -> 4.003125ms
> CPU1: Booted secondary processor
> secondary_init: 4022583 -> 4.022583ms
> writing release: 4040750 -> 4.04075ms
> release done: 4051083 -> 4.051083ms
> released: 46509000 -> 4.6509ms
> Boot returned: 51745708 -> 5.1745708ms
> sync'd: 51745875 -> 5.1745875ms
> CPU1: Unknown IPI message 0x1
> Switched to NOHz mode on CPU #1
> Online: 281251041 -> 281.251041ms
>
> So, it appears to take 4ms to get from just before the call to
> boot_secondary() in __cpu_up() to writing pen_release.
>
> The secondary CPU appears to run from being woken up to writing the
> pen release in about 40us - and then spends about 1ms spinning on
> its lock waiting for the requesting CPU to catch up.
>
> This can be repeated every time without exception when you bring a
> CPU back online.
>
Hmm, this sounds needlessly expensive.
> Looking at that 500us, it seems to be taken up by 'spin_unlock()' in
> boot_secondary:
>
> 00000000 <boot_secondary>:
[...]
> --spin_unlock--
> bc: f57ff05f dmb sy
> c0: e3a02000 mov r2, #0 ; 0x0
> c4: e59f3020 ldr r3, [pc, #32] ; ec <boot_secondary+0xec>
> c8: e5832000 str r2, [r3]
> cc: f57ff04f dsb sy
> d0: e320f004 sev
> ----
One thing that might be worth trying is changing spin_unlock to use
strex [alongside a dummy ldrex]. There could be some QoS logic at L2
which favours exclusive accesses, meaning that the unlock is starved by
the lock. I don't have access to a board at the moment, so this is
purely speculation!
> The CPU being brought online is doing this:
>
> 00000034 <_raw_spin_lock>:
> 34: e1a0c00d mov ip, sp
> 38: e92dd800 push {fp, ip, lr, pc}
> 3c: e24cb004 sub fp, ip, #4 ; 0x4
> 40: e3a03001 mov r3, #1 ; 0x1
> 44: e1902f9f ldrex r2, [r0]
> 48: e3320000 teq r2, #0 ; 0x0
> 4c: 1320f002 wfene
> 50: 01802f93 strexeq r2, r3, [r0]
> 54: 03320000 teqeq r2, #0 ; 0x0
> 58: 1afffff9 bne 44 <_raw_spin_lock+0x10>
> 5c: f57ff05f dmb sy
> 60: e89da800 ldm sp, {fp, sp, pc}
>
> as it's waiting for the lock to be released. So... what could be causing
> the above code in boot_secondary()/__cpu_up() to take 500us when the
> system's running? The dmb, dsb, or sev? Or the SCU trying to sort out
> the str to release the lock?
Another experiment would be to remove the wfe/sev instructions to see if
they're eating cycles. I think a WFE on the A9 disables a bunch of
clocks, so that could be taking time to do.
<shameless plug>
You could try using perf to identify the most expensive instructions in
the functions above (assuming interrupts are enabled).
</shameless plug>
Cheers,
Will
next prev parent reply other threads:[~2010-12-18 17:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-07 16:43 [RFC] Fixing CPU Hotplug for RealView Platforms Will Deacon
2010-12-07 17:18 ` Russell King - ARM Linux
2010-12-07 17:47 ` Will Deacon
2010-12-08 6:03 ` Santosh Shilimkar
2010-12-08 13:20 ` Will Deacon
2010-12-08 20:20 ` Russell King - ARM Linux
2010-12-18 17:10 ` Russell King - ARM Linux
2010-12-18 17:44 ` Will Deacon [this message]
2010-12-18 19:22 ` Russell King - ARM Linux
-- strict thread matches above, loose matches on Subject: below --
2010-12-20 8:16 Vincent Guittot
2011-01-03 10:46 ` Russell King - ARM Linux
2011-01-03 17:39 ` Vincent Guittot
2011-01-03 18:03 ` Russell King - ARM Linux
2011-01-04 8:55 ` Vincent Guittot
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=1292694287.4266.15.camel@jazzbox \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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.