From: Robert Jarzmik <robert.jarzmik@intel.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "Berthier\, Emmanuel" <emmanuel.berthier@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>,
"Jarzmik\, Robert" <robert.jarzmik@intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] [LBR] Dump LBRs on Exception
Date: Sat, 06 Dec 2014 11:31:19 +0100 [thread overview]
Message-ID: <87fvctnk7c.fsf@intel.com> (raw)
In-Reply-To: <CALCETrWr=6BnQ7r4KYDVJzeNPO-pxk9wRmkkLy+mM1T_85Y=jw@mail.gmail.com> (Andy Lutomirski's message of "Thu, 4 Dec 2014 10:09:53 -0800")
Andy Lutomirski <luto@amacapital.net> writes:
> I don't really care about the number of instructions.
Right, a couple of test/jz/jnz is negligible in the exception path, that's what
I also think.
> But there are still all the nasty cases:
>
> - Context switch during exception processing (both in the C handler
> and in the retint code).
> - PMI during exception processing.
> - Exception while perf is poking at LBR msrs.
Yes.
Wasn't that what Thomas's suggestion on the per-cpu variable was solving ?
Ie:
DEFINE_PER_CPU(unsigned long, lbr_dump_state) = LBR_OOPS_DISABLED;
...
We would have a "LBR resource" variable to track who owns the LBR :
- nobody : LBR_UNCLAIMED
- the exception handler : LBR_EXCEPTION_DEBUG_USAGE
- activated with a runtime variable or config
- impossible to activate if perf has hold of it
- the perf code : LBR_PERF_USAGE
- activated through perf infrastructure
- impossible to activated if exception handler has hold of it
Now this solves the perf/exception concurrency on the LBR registers. If there is
a rescheduling during the exception, or a PMI, can that have an impact ?
- case 1: nobody is handling LBR
=> no impact, expception handlers won't touch LBR
- case 2: perf is handling LBR
=> no imppact, exception handler won't touch LBR
- case 3: exception handlers are handling LBR
- case 3a: simple user exception
-> exception entry
-> is kernel exception == false => bypass LBR handling
-> exception handling
- case 3b: simple kernel exception
-> exception entry
-> test lbr_dump_state == EXCEPTION_OWNED => true => STOP LBR
-> no reschedule, no PMI
-> exception handling
-> test lbr_dump_state == EXCEPTION_OWNED => true => START LBR
- case 3c: kernel exception with PMI
-> exception entry
-> test lbr_dump_state == EXCEPTION_OWNED => true => STOP LBR
-> PMI
can't touch LBR, as lbr_dump_state == EXCEPTION_OWNED
-> exception handling
-> test lbr_dump_state == EXCEPTION_OWNED => true => START LBR
- case 3d: kernel exception with a reschedule inside
-> exception entry
-> test lbr_dump_state == EXCEPTION_OWNED => true => STOP LBR
-> exception handling
-> context_switch()
-> perf cannot touch LBR, nobody can
-> test lbr_dump_state == EXCEPTION_OWNED => true => START LBR
I might be very wrong in the description as I'm not that sharp on x86, but is
there a flaw in the above cases ?
If not, a couple of tests and Thomas's per-cpu variable can solve the issue,
while keeping the exception handler code simple as Emmanual has proposed (given
the additionnal test inclusion - which will be designed to not pollute the LBR),
and having a small impact on perf to solve the resource acquire issue.
Cheers.
--
Robert
next prev parent reply other threads:[~2014-12-06 10:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 17:03 [PATCH] [LBR] Dump LBRs on Oops Emmanuel Berthier
2014-11-22 0:50 ` Thomas Gleixner
2014-11-26 10:56 ` Berthier, Emmanuel
2014-11-26 13:08 ` Thomas Gleixner
2014-11-26 14:17 ` Berthier, Emmanuel
2014-11-26 14:46 ` Thomas Gleixner
2014-11-26 15:43 ` Berthier, Emmanuel
2014-11-27 14:40 ` [PATCH v2] [LBR] Dump LBRs on Exception Emmanuel Berthier
2014-11-27 21:22 ` Thomas Gleixner
2014-11-27 21:56 ` Andy Lutomirski
2014-11-28 8:44 ` Berthier, Emmanuel
2014-11-28 15:15 ` Andy Lutomirski
2014-12-02 19:09 ` Berthier, Emmanuel
2014-12-02 19:33 ` Andy Lutomirski
2014-12-02 19:56 ` Thomas Gleixner
2014-12-02 20:12 ` Andy Lutomirski
2014-12-03 18:25 ` Berthier, Emmanuel
2014-12-03 19:29 ` Andy Lutomirski
2014-12-04 16:01 ` Berthier, Emmanuel
2014-12-04 18:09 ` Andy Lutomirski
2014-12-05 13:14 ` Berthier, Emmanuel
2014-12-06 10:31 ` Robert Jarzmik [this message]
[not found] ` <CALCETrXhfzd9Fkikvm5qj0LWgWtDzgdpY_0EC3ChwyyGZksTMw@mail.gmail.com>
2014-12-07 18:40 ` Robert Jarzmik
2014-12-07 19:10 ` Andy Lutomirski
2014-12-12 17:30 ` Berthier, Emmanuel
2014-12-12 17:54 ` Andy Lutomirski
2014-11-28 10:28 ` Berthier, Emmanuel
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=87fvctnk7c.fsf@intel.com \
--to=robert.jarzmik@intel.com \
--cc=emmanuel.berthier@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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.