public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: andi@firstfloor.org, mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][RFC] Adding information of counts processes acquired how many spinlocks to schedstat
Date: Wed, 1 Jul 2009 11:48:56 +0200	[thread overview]
Message-ID: <20090701094856.GO6760@one.firstfloor.org> (raw)
In-Reply-To: <20090701.174226.419764642024067218.mitake@dcl.info.waseda.ac.jp>

On Wed, Jul 01, 2009 at 05:42:26PM +0900, Hitoshi Mitake wrote:
> From: Andi Kleen <andi@firstfloor.org>
> Subject: Re: [PATCH][RFC] Adding information of counts processes acquired how many spinlocks to schedstat
> Date: Wed, 01 Jul 2009 09:38:04 +0200
> 
> > Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> writes:
> > 
> > > Hi,
> > >
> > > I wrote a test patch which add information of counts processes acquired how many spinlocks to schedstat.
> > > After applied this patch, /proc/<PID>/sched will change like this,
> > 
> > The problem is that spinlocks are very common and schedstats is enabled commonly
> > in production kernels. You would need to demonstrate that such a change doesn't
> > have significant performance impact. For me it looks like it has.
> 
> I agree with your opinion about performance impact.
> I thought this will make no problem,
> because schedstat is categorized as "Kernel hacking" section.
> But according to you, many production kernels enable it

Yes it's used by some performance management tools.

It might be still appropiate with a separate CONFIG option,
assuming the metric is actually useful (which is somewhat
questionable)

BTW I did spinlock counter statistics in the past with systemtap
(they're quite easy to do with it without any code changes), but I didn't find
them very useful to be honest.

> > Also I'm not sure exactly what good such a metric is. Do you have 
> > a concrete use case?
> > 
> 
> I want to know about behavior of Apache.

Spinlocks are mainly interesting when they use up CPU time.
This typically happens when they bounce cache lines or are
contended. On the other hand on modern CPUs "local only"
spinlocks that are not contended are quite cheap and 
not very interesting to optimize. For useful optimization
you need to distingush all these cases, and your 
simple counter doesn't help with that.

So I would suggest you just take a look at any of the 
standard kernel profilers (oprofile etc.) or at lockstat

> And spinlocks may cause terrible performance problem when Linux is running on VM.

Assuming a modern CPU the "uncontended lock spinlock" case shouldn't
be particularly expensive in VMs either.

> 
> > The normal way to check for lock contention or lock bouncingis to
> > simply profile cycles or time and see if there is a lot of CPU time in
> > locks.
> 
> According to Ingo's advice, I'll try to add lock counter to perfcounter.

Well that would have the same problem if that perfcounter is enabled.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

      parent reply	other threads:[~2009-07-01  9:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-01  6:21 [PATCH][RFC] Adding information of counts processes acquired how many spinlocks to schedstat Hitoshi Mitake
2009-07-01  7:31 ` Ingo Molnar
2009-07-01  8:21   ` Hitoshi Mitake
2009-07-01 13:45   ` Frederic Weisbecker
2009-07-01 13:50     ` Ingo Molnar
2009-07-01 14:17       ` mitake
2009-07-01  7:38 ` Andi Kleen
2009-07-01  8:42   ` Hitoshi Mitake
2009-07-01  9:07     ` Ingo Molnar
2009-07-01  9:42       ` Hitoshi Mitake
2009-07-01 11:06         ` Ingo Molnar
2009-07-01 12:53           ` Hitoshi Mitake
2009-07-01 15:44             ` Frederic Weisbecker
2009-07-06  5:20               ` mitake
2009-07-06  8:51                 ` Peter Zijlstra
2009-07-06 11:54                   ` Andi Kleen
2009-07-10 12:45                     ` mitake
2009-07-10 12:52                       ` Peter Zijlstra
2009-07-10 13:43                         ` Ingo Molnar
2009-07-10 13:46                           ` Frederic Weisbecker
2009-07-10 13:50                             ` Ingo Molnar
2009-07-10 13:56                               ` Peter Zijlstra
2009-07-12  7:23                         ` Hitoshi Mitake
2009-07-12 13:24                           ` Peter Zijlstra
2009-07-13  6:06                             ` Hitoshi Mitake
2009-07-13  8:51                               ` Ingo Molnar
2009-07-14  0:48                                 ` Hitoshi Mitake
2009-07-18 13:25                                   ` Ingo Molnar
2009-07-01 12:40       ` Andi Kleen
2009-07-01 13:50       ` [PATCH][RFC] Adding information of counts processes acquired how many spinlocks to schedstat II Andi Kleen
2009-07-01  9:48     ` Andi Kleen [this message]

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=20090701094856.GO6760@one.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mitake@dcl.info.waseda.ac.jp \
    /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