From: "Suresh E. Warrier" <warrier@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: lklml <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 2/2] More precise timestamps for nested writes
Date: Wed, 15 Apr 2015 11:53:38 -0500 [thread overview]
Message-ID: <552E9792.8010709@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150415091626.GF17717@twins.programming.kicks-ass.net>
On 04/15/2015 04:16 AM, Peter Zijlstra wrote:
> On Mon, Apr 13, 2015 at 09:38:01PM -0500, Suresh E. Warrier wrote:
>
>> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
>> index c9b3005..0a2d862 100644
>> --- a/kernel/trace/ring_buffer.c
>> +++ b/kernel/trace/ring_buffer.c
>> @@ -482,6 +482,7 @@ struct ring_buffer_per_cpu {
>> unsigned long read_bytes;
>> u64 write_stamp;
>> u64 read_stamp;
>> + u64 last_stamp;
>> /* ring buffer pages to update, > 0 to add, < 0 to remove */
>> int nr_pages_to_update;
>> struct list_head new_pages; /* new pages to add */
>
> So what is wrong with something like:
>
> u64 rb_get_delta(struct ring_buffer_per_cpu *cpu_buffer)
> {
> u64 last, now;
>
> for (;;) {
> last = cpu_buffer->last_stamp;
> now = cpu_buffer->buffer->clock();
>
> if (cmpxchg_local(&cpu_buffer->last_stamp, last, now) == last)
> break;
>
> cpu_relax();
> }
>
> return now - last;
> }
>
> Of course, LL/SC on power stinks, but on most archs this is actually
> fairly fast.
>
I am not sure it will help. The delta we assign to the current
event has to be the difference of the "actual" timestamps of the
last event in the buffer and the current event. If we can't be sure
of the delta, we can let it be zero which is the current behavior
for nested writes.
Thus, one way to fix my patch to handle NMIs is to recheck the
last_stamp after the event has been reserved in the buffer. If it
has changed since we computed the delta, we can simply reset the
delta to zero. This should only happen if an NMI occurs within the
short critical section and it also does a trace.
-suresh
prev parent reply other threads:[~2015-04-15 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1428459449-10664-1-git-send-email-warrier@linux.vnet.ibm.com>
2015-04-14 2:29 ` [PATCH 0/2] ring-buffer: More precise timestamps for nested writes Suresh E. Warrier
2015-04-14 2:31 ` [PATCH 1/2] ring-buffer: Introduce precise nested timestamp sysfs attribute Suresh E. Warrier
2015-04-14 2:38 ` [PATCH 2/2] More precise timestamps for nested writes Suresh E. Warrier
2015-04-14 17:13 ` Peter Zijlstra
2015-04-15 0:33 ` Suresh E. Warrier
2015-04-15 8:45 ` Peter Zijlstra
2015-04-15 9:16 ` Peter Zijlstra
2015-04-15 16:53 ` Suresh E. Warrier [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=552E9792.8010709@linux.vnet.ibm.com \
--to=warrier@linux.vnet.ibm.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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