mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function
       [not found]                 ` <1283351527.2356.22.camel@gandalf.stny.rr.com>
@ 2010-09-01 16:49                   ` Steven Rostedt
  2010-09-01 17:16                     ` John W. Linville
  2010-09-01 17:30                     ` Ingo Molnar
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2010-09-01 16:49 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Neil Brown, John W. Linville, ksummit-2010-discuss


Ingo,

Please pull the latest tip/perf/core tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/perf/core


Steven Rostedt (1):
      ring-buffer: Place duplicate expression into a single function

----
 kernel/trace/ring_buffer.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---------------------------
commit f6195aa09e618d712f52bf4fa33b5293820eb93d
Author: Steven Rostedt <srostedt@redhat.com>
Date:   Wed Sep 1 12:23:12 2010 -0400

    ring-buffer: Place duplicate expression into a single function
    
    While discussing the strictness of the 80 character limit on the
    Kernel Summit Discussion mailing list, I showed examples that I
    broke that limit slightly with some algorithms. In discussing with
    John Linville, what looked better, I realized that two of the
    80 char breaking culprits were an identical expression.
    
    As a clean up, this patch moves the identical expression into its
    own helper function and that is used instead. As a side effect,
    the offending code is now under the 80 character limit. :-)
    
    This clean up code also changes the expression from
    
    	(A - B) - C  to  A - (B + C)
    
    This makes the code look a little nicer too.
    
    Cc: John W. Linville <linville@tuxdriver.com>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 19cccc3..ef27017 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2606,6 +2606,19 @@ void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu)
 }
 EXPORT_SYMBOL_GPL(ring_buffer_record_enable_cpu);
 
+/*
+ * The total entries in the ring buffer is the running counter
+ * of entries entered into the ring buffer, minus the sum of
+ * the entries read from the ring buffer and the number of
+ * entries that were overwritten.
+ */
+static inline unsigned long
+rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
+{
+	return local_read(&cpu_buffer->entries) -
+		(local_read(&cpu_buffer->overrun) + cpu_buffer->read);
+}
+
 /**
  * ring_buffer_entries_cpu - get the number of entries in a cpu buffer
  * @buffer: The ring buffer
@@ -2614,16 +2627,13 @@ EXPORT_SYMBOL_GPL(ring_buffer_record_enable_cpu);
 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu)
 {
 	struct ring_buffer_per_cpu *cpu_buffer;
-	unsigned long ret;
 
 	if (!cpumask_test_cpu(cpu, buffer->cpumask))
 		return 0;
 
 	cpu_buffer = buffer->buffers[cpu];
-	ret = (local_read(&cpu_buffer->entries) - local_read(&cpu_buffer->overrun))
-		- cpu_buffer->read;
 
-	return ret;
+	return rb_num_of_entries(cpu_buffer);
 }
 EXPORT_SYMBOL_GPL(ring_buffer_entries_cpu);
 
@@ -2684,8 +2694,7 @@ unsigned long ring_buffer_entries(struct ring_buffer *buffer)
 	/* if you care about this being correct, lock the buffer */
 	for_each_buffer_cpu(buffer, cpu) {
 		cpu_buffer = buffer->buffers[cpu];
-		entries += (local_read(&cpu_buffer->entries) -
-			    local_read(&cpu_buffer->overrun)) - cpu_buffer->read;
+		entries += rb_num_of_entries(cpu_buffer);
 	}
 
 	return entries;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function
  2010-09-01 16:49                   ` [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function Steven Rostedt
@ 2010-09-01 17:16                     ` John W. Linville
  2010-09-01 17:30                     ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: John W. Linville @ 2010-09-01 17:16 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Ingo Molnar, Neil Brown, ksummit-2010-discuss

On Wed, Sep 01, 2010 at 12:49:52PM -0400, Steven Rostedt wrote:
> 
> Ingo,
> 
> Please pull the latest tip/perf/core tree, which can be found at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/perf/core
> 
> 
> Steven Rostedt (1):
>       ring-buffer: Place duplicate expression into a single function
> 
> ----
>  kernel/trace/ring_buffer.c |   21 +++++++++++++++------
>  1 files changed, 15 insertions(+), 6 deletions(-)
> ---------------------------
> commit f6195aa09e618d712f52bf4fa33b5293820eb93d
> Author: Steven Rostedt <srostedt@redhat.com>
> Date:   Wed Sep 1 12:23:12 2010 -0400
> 
>     ring-buffer: Place duplicate expression into a single function
>     
>     While discussing the strictness of the 80 character limit on the
>     Kernel Summit Discussion mailing list, I showed examples that I
>     broke that limit slightly with some algorithms. In discussing with
>     John Linville, what looked better, I realized that two of the
>     80 char breaking culprits were an identical expression.
>     
>     As a clean up, this patch moves the identical expression into its
>     own helper function and that is used instead. As a side effect,
>     the offending code is now under the 80 character limit. :-)
>     
>     This clean up code also changes the expression from
>     
>     	(A - B) - C  to  A - (B + C)
>     
>     This makes the code look a little nicer too.
>     
>     Cc: John W. Linville <linville@tuxdriver.com>
>     Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

ACK :-)

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function
  2010-09-01 16:49                   ` [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function Steven Rostedt
  2010-09-01 17:16                     ` John W. Linville
@ 2010-09-01 17:30                     ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2010-09-01 17:30 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Neil Brown, John W. Linville, ksummit-2010-discuss


* Steven Rostedt <rostedt@goodmis.org> wrote:

> 
> Ingo,
> 
> Please pull the latest tip/perf/core tree, which can be found at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/perf/core
> 
> 
> Steven Rostedt (1):
>       ring-buffer: Place duplicate expression into a single function
> 
> ----
>  kernel/trace/ring_buffer.c |   21 +++++++++++++++------
>  1 files changed, 15 insertions(+), 6 deletions(-)

Pulled, thanks Steve!

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-01 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20100825052123.GA5237@linux.vnet.ibm.com>
     [not found] ` <AANLkTinCaKNXadoTtOvBhO3K5mOyzHi=ZJw4guWWB1W6@mail.gmail.com>
     [not found]   ` <20100826210328.4ccd5aaf@notabene>
     [not found]     ` <1283220647.1377.69.camel@gandalf.stny.rr.com>
     [not found]       ` <20100831132708.GA2484@tuxdriver.com>
     [not found]         ` <1283263428.2945.83.camel@powerslave>
     [not found]           ` <20100901080715.5834450d@notabene>
     [not found]             ` <1283295699.1377.732.camel@gandalf.stny.rr.com>
     [not found]               ` <20100901133653.GB2486@tuxdriver.com>
     [not found]                 ` <1283351527.2356.22.camel@gandalf.stny.rr.com>
2010-09-01 16:49                   ` [PATCH][GIT PULL] ring-buffer: Place duplicate expression into a single function Steven Rostedt
2010-09-01 17:16                     ` John W. Linville
2010-09-01 17:30                     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®