[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1323368035.17673.20.camel@twins>
Date: Thu, 08 Dec 2011 19:13:55 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Stephane Eranian <eranian@...gle.com>
Cc: linux-kernel@...r.kernel.org, mingo@...e.hu, acme@...hat.com,
ming.m.lin@...el.com, andi@...stfloor.org, robert.richter@....com,
ravitillo@....gov, will.deacon@....com, paulus@...ba.org,
benh@...nel.crashing.org, rth@...ddle.net, ralf@...ux-mips.org,
davem@...emloft.net, lethal@...ux-sh.org
Subject: Re: [PATCH 09/12] perf_events: add hook to flush branch_stack on
context switch (v2)
On Thu, 2011-12-08 at 10:04 -0800, Stephane Eranian wrote:
> The whole motivation behind the flush_branch_stack is explained in the
> Changelog of the patch. In summary, we need to flush the LBR (regardless
> of TOS) because in system-wide we need to be able to associate the content
> of the LBR with a specific task. Given that the HW does not capture the PID
> in the LBR buffer, the kernel has to intervene.
That's not regardless of the TOS. If the TOS was a full u64 you wouldn't
need the TID (which would be good, since the hardware has no such
concept).
> Why don't we have this already?
> Because we are capturing at all priv levels. But with this patchset, it becomes
> possible to filter taken branches based on priv levels. Thus, if you only sample
> at the user level and run in system-wide mode, it is more likely you could end
> up with branches belonging to two different tasks in the LBR buffer. But you'd
> have no way of determining this just by looking at the content of the buffer.
> So instead, we need to flush the LBR on context switch to associate a PID
> with them.
Yeah, I get that.
> Because this is an expensive operation, we want to do this only when we
> sample on LBR. That's what the ctx->nr_branch_stack is about. We could
> refine that some more by checking for system-wide events with only
> user priv level on the branch stack. But I did not do that yet.
>
> Does this make more sense now?
It already did. The only thing I wanted to do was get rid of that method
check. Initially I overlooked the fact that its optional, even if you
support the branch stack. My reply from today argued for it, since
installing a dummy method would still have the needless ctx_lock &&
pmu_disable overhead.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists