From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Adrian Cox <adrian@humboldt.co.uk>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: Worst case performance of up()
Date: Sat, 25 Nov 2006 07:45:24 +1100 [thread overview]
Message-ID: <1164401124.5653.86.camel@localhost.localdomain> (raw)
In-Reply-To: <1164385262.11292.76.camel@localhost.localdomain>
On Fri, 2006-11-24 at 16:21 +0000, Adrian Cox wrote:
> First the background: I've been investigating poor performance of a
> Firewire capture application, running on a dual-7450 board with a 2.6.17
> kernel. The kernel is based on a slightly earlier version of the
> mpc7448hpc2 board port, using arch/powerpc, which I've not yet updated
> to reflect the changes made when the board support entered the
> mainstream kernel.
>
> The application runs smoothly on a single processor. On the dual
> processor machine, the application sometimes suffers a drop in
> frame-rate, simultaneous with high CPU usage by the Firewire kernel
> thread.
>
> Further investigation reveals that the kernel thread spends most of the
> time in one line: up(&fi->complete_sem) in __queue_complete_req() in
> drivers/iee1394/raw1394.c. It seems that whenever the userspace thread
> calling raw1394_read() is scheduled on the opposite CPU to the kernel
> thread, the kernel thread takes much longer to execute up() - typically
> 10000 times longer.
>
> Does anybody have any ideas what could make up() take so long in this
> circumstance? I'd expect cache transfers to make the operation about 100
> times slower, but this looks like repeated cache ping-pong between the
> two CPUs.
Is it hung in up() (toplevel) or __up (low level) ?
The former is mostly just a atomic_add_return which boils down to :
static __inline__ int atomic_add_return(int a, atomic_t *v)
{
int t;
__asm__ __volatile__(
LWSYNC_ON_SMP
"1: lwarx %0,0,%2 # atomic_add_return\n\
add %0,%1,%0\n"
PPC405_ERR77(0,%2)
" stwcx. %0,0,%2 \n\
bne- 1b"
ISYNC_ON_SMP
: "=&r" (t)
: "r" (a), "r" (&v->counter)
: "cc", "memory");
return t;
}
So yes, on SMP, you get an additional sync and isync in there, though
I'm surprised that you hit a code path where that would make such a big
difference (unless you are really up'ing a zillion times per sec).
Have you tried some oprofile runs to catch the exact instruction where
the cycles appear to be wasted ?
Maybe there is some contention on the reservation (though that would be
a bit strange to have a contention on a up...) or somewhat the semaphore
ends up sharing a cache line with something else. That would cause a
performance problem.
Have you tried moving the semaphore away from whatever other data might
be manipulated at the same time ? In it's own cache line maybe ?
Cheers,
Ben.
next prev parent reply other threads:[~2006-11-24 20:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-24 16:21 Worst case performance of up() Adrian Cox
2006-11-24 20:45 ` Benjamin Herrenschmidt [this message]
2006-11-27 21:02 ` Adrian Cox
2006-12-02 10:35 ` Adrian Cox
2006-12-02 11:15 ` Benjamin Herrenschmidt
2006-12-02 11:54 ` Adrian Cox
2006-12-02 20:52 ` Benjamin Herrenschmidt
2006-12-04 13:43 ` Adrian Cox
2006-12-04 20:25 ` Benjamin Herrenschmidt
2006-12-05 22:00 ` Benjamin Herrenschmidt
2006-12-08 2:33 ` Paul Mackerras
2006-12-08 3:10 ` Benjamin Herrenschmidt
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=1164401124.5653.86.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=adrian@humboldt.co.uk \
--cc=linuxppc-dev@ozlabs.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).