<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/ring_buffer.c, branch v2.6.30</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.30</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.30'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2009-04-01T12:47:53Z</updated>
<entry>
<title>ring-buffer: do not remove reader page from list on ring buffer free</title>
<updated>2009-04-01T12:47:53Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-30T18:03:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2e572895bf3203e881356a4039ab0fa428ed2639'/>
<id>urn:sha1:2e572895bf3203e881356a4039ab0fa428ed2639</id>
<content type='text'>
Impact: prevent possible memory leak

The reader page of the ring buffer is special. Although it points
into the ring buffer, it is not part of the actual buffer. It is
a page used by the reader to swap with a page in the ring buffer.
Once the swap is made, the new reader page is again outside the
buffer.

Even though the reader page points into the buffer, it is really
pointing to residual data. Note, this data is used by the reader.

              reader page
                  |
                  v
       (prev)   +---+    (next)
     +----------|   |----------+
     |          +---+          |
     v                         v
   +---+        +---+        +---+
--&gt;|   |-------&gt;|   |-------&gt;|   |---&gt;
&lt;--|   |&lt;-------|   |&lt;-------|   |&lt;---
   +---+        +---+        +---+

     ^            ^            ^
      \           |            /
       ------- Buffer---------

If we perform a list_del_init() on the reader page we will actually remove
the last page the reader swapped with and not the reader page itself.
This will cause that page to not be freed, and thus is a memory leak.

Luckily, the only user of the ring buffer so far is ftrace. And ftrace
will not free its ring buffer after it allocates it. There is no current
possible memory leak. But once there are other users, or if ftrace
dynamically creates and frees its ring buffer, then this would be a
memory leak.

This patch fixes the leak for future cases.

Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>Merge branches 'tracing/docs', 'tracing/filters', 'tracing/ftrace', 'tracing/kprobes', 'tracing/blktrace-v2' and 'tracing/textedit' into tracing/core-v2</title>
<updated>2009-03-31T15:46:40Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@elte.hu</email>
</author>
<published>2009-03-31T15:46:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8b54e45b0005875f59cb8b1c44d429a161d5f245'/>
<id>urn:sha1:8b54e45b0005875f59cb8b1c44d429a161d5f245</id>
<content type='text'>
</content>
</entry>
<entry>
<title>tracing: add ring_buffer_event_discard() to ring buffer</title>
<updated>2009-03-22T17:38:25Z</updated>
<author>
<name>Tom Zanussi</name>
<email>tzanussi@gmail.com</email>
</author>
<published>2009-03-22T08:30:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2d622719f1572ef31e0616444a515eba3094d050'/>
<id>urn:sha1:2d622719f1572ef31e0616444a515eba3094d050</id>
<content type='text'>
This patch overloads RINGBUF_TYPE_PADDING to provide a way to discard
events from the ring buffer, for the event-filtering mechanism
introduced in a subsequent patch.

I did the initial version but thanks to Steven Rostedt for adding
the parts that actually made it work. ;-)

Signed-off-by: Tom Zanussi &lt;tzanussi@gmail.com&gt;
Acked-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>tracing/ring-buffer: don't annotate rb_cpu_notify with __cpuinit</title>
<updated>2009-03-21T09:54:10Z</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2009-03-21T03:33:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=09c9e84d474d917d9de5b9011ed2064b03a19677'/>
<id>urn:sha1:09c9e84d474d917d9de5b9011ed2064b03a19677</id>
<content type='text'>
Impact: remove a section warning

CONFIG_DEBUG_SECTION_MISMATCH raises the following warning on -tip:

  WARNING: kernel/trace/built-in.o(.text+0x5bc5): Section mismatch in
  reference from the function ring_buffer_alloc() to the function
  .cpuinit.text:rb_cpu_notify()
  The function ring_buffer_alloc() references
  the function __cpuinit rb_cpu_notify().

This is actually harmless. The code in the ring buffer don't build
rb_cpu_notify and other cpu hotplug stuffs when !CONFIG_HOTPLUG_CPU
so we have no risk to reference freed memory here (it would even
be harmless if we unconditionally build it because register_cpu_notifier
would do nothing when !CONFIG_HOTPLUG_CPU.

But since ring_buffer_alloc() can be called everytime, we don't want it
to be annotated with __cpuinit so we drop the __cpuinit from
rb_cpu_notify.

This is not a waste of memory because it is only defined and used on
CONFIG_HOTPLUG_CPU.

Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
LKML-Reference: &lt;1237606416-22268-1-git-send-email-fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>tracing/ring-buffer: fix non cpu hotplug case</title>
<updated>2009-03-19T15:41:08Z</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2009-03-19T13:47:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3bf832ce1fe6988148d392599f34ca0c6a34427d'/>
<id>urn:sha1:3bf832ce1fe6988148d392599f34ca0c6a34427d</id>
<content type='text'>
Impact: fix warning with irqsoff tracer

The ring buffer allocates its buffers on pre-smp time (early_initcall).
It means that, at first, only the boot cpu buffer is allocated and
the ring-buffer cpumask only has the boot cpu set (cpu_online_mask).

Later, the secondary cpu will show up and the ring-buffer will be notified
about this event: the appropriate buffer will be allocated and the cpumask
will be updated.

Unfortunately, if !CONFIG_CPU_HOTPLUG, the ring-buffer will not be
notified about the secondary cpus, meaning that the cpumask will have
only the cpu boot set, and only one cpu buffer allocated.

We fix that by using cpu_possible_mask if !CONFIG_CPU_HOTPLUG.

This patch fixes the following warning with irqsoff tracer running:

[  169.317794] WARNING: at kernel/trace/trace.c:466 update_max_tr_single+0xcc/0xf3()
[  169.318002] Hardware name: AMILO Li 2727
[  169.318002] Modules linked in:
[  169.318002] Pid: 5624, comm: bash Not tainted 2.6.29-rc8-tip-02636-g6aafa6c #11
[  169.318002] Call Trace:
[  169.318002]  [&lt;ffffffff81036182&gt;] warn_slowpath+0xea/0x13d
[  169.318002]  [&lt;ffffffff8100b9d6&gt;] ? ftrace_call+0x5/0x2b
[  169.318002]  [&lt;ffffffff8100b9d6&gt;] ? ftrace_call+0x5/0x2b
[  169.318002]  [&lt;ffffffff8100b9d1&gt;] ? ftrace_call+0x0/0x2b
[  169.318002]  [&lt;ffffffff8101ef10&gt;] ? ftrace_modify_code+0xa9/0x108
[  169.318002]  [&lt;ffffffff8106e27f&gt;] ? trace_hardirqs_off+0x25/0x27
[  169.318002]  [&lt;ffffffff8149afe7&gt;] ? _spin_unlock_irqrestore+0x1f/0x2d
[  169.318002]  [&lt;ffffffff81064f52&gt;] ? ring_buffer_reset_cpu+0xf6/0xfb
[  169.318002]  [&lt;ffffffff8106637c&gt;] ? ring_buffer_reset+0x36/0x48
[  169.318002]  [&lt;ffffffff8106aeda&gt;] update_max_tr_single+0xcc/0xf3
[  169.318002]  [&lt;ffffffff8100bc17&gt;] ? sysret_check+0x22/0x5d
[  169.318002]  [&lt;ffffffff8106e3ea&gt;] stop_critical_timing+0x142/0x204
[  169.318002]  [&lt;ffffffff8106e4cf&gt;] trace_hardirqs_on_caller+0x23/0x25
[  169.318002]  [&lt;ffffffff8149ac28&gt;] trace_hardirqs_on_thunk+0x3a/0x3c
[  169.318002]  [&lt;ffffffff8100bc17&gt;] ? sysret_check+0x22/0x5d
[  169.318002] ---[ end trace db76cbf775a750cf ]---

Because this tracer may try to swap two cpu ring buffers for an
unregistered cpu on the ring buffer.

This patch might also fix a fair loss of traces due to unallocated buffers
for secondary cpus.

Reported-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Acked-b: Steven Rostedt &lt;rostedt@goodmis.org&gt;
LKML-Reference: &lt;1237470453-5427-1-git-send-email-fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>ring-buffer: add api to allow a tracer to change clock source</title>
<updated>2009-03-18T03:06:31Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-17T21:22:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=37886f6a9f62d22530ffee8d3f9215c8345b6969'/>
<id>urn:sha1:37886f6a9f62d22530ffee8d3f9215c8345b6969</id>
<content type='text'>
This patch adds a new function called ring_buffer_set_clock that
allows a tracer to assign its own clock source to the buffer.

Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
</content>
</entry>
<entry>
<title>ring-buffer: document reader page design</title>
<updated>2009-03-13T02:24:17Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-13T02:24:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5cc985488845ec7227a2c5cfd2fd62cf57fb411a'/>
<id>urn:sha1:5cc985488845ec7227a2c5cfd2fd62cf57fb411a</id>
<content type='text'>
In a private email conversation I explained how the ring buffer
page worked by using silly ASCII art. Ingo suggested that I add
that to the comments of the code.

Here it is.

Requested-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
</content>
</entry>
<entry>
<title>ring-buffer: remove unneeded get_online_cpus</title>
<updated>2009-03-13T01:14:59Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-12T17:13:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8aabee573dff131a085c63de7667eacd94ba4ccb'/>
<id>urn:sha1:8aabee573dff131a085c63de7667eacd94ba4ccb</id>
<content type='text'>
Impact: speed up and remove possible races

The get_online_cpus was added to the ring buffer because the original
design would free the ring buffer on a CPU that was being taken
off line. The final design kept the ring buffer around even when the
CPU was taken off line. This is to allow a user to still read the
information on that ring buffer.

Most of the get_online_cpus are no longer needed since the ring buffer will
not disappear from the use cases.

Reported-by: KOSAKI Motohiro &lt;kosaki.motohiro@jp.fujitsu.com&gt;
Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
</content>
</entry>
<entry>
<title>ring-buffer: use CONFIG_HOTPLUG_CPU not CONFIG_HOTPLUG</title>
<updated>2009-03-13T01:14:59Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-12T15:46:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=59222efe2d184956464abe5b637bc842ff053b93'/>
<id>urn:sha1:59222efe2d184956464abe5b637bc842ff053b93</id>
<content type='text'>
The hotplug code in the ring buffers is for use with CPU hotplug,
not generic hotplug.

Reported-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
</content>
</entry>
<entry>
<title>ring-buffer: only allocate buffers for online cpus</title>
<updated>2009-03-12T02:15:27Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2009-03-12T02:00:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=554f786e284a6ce859d51f62240d615603944c8e'/>
<id>urn:sha1:554f786e284a6ce859d51f62240d615603944c8e</id>
<content type='text'>
Impact: save on memory

Currently, a ring buffer was allocated for each "possible_cpus". On
some systems, this is the same as NR_CPUS. Thus, if a system defined
NR_CPUS = 64 but it only had 1 CPU, we could have possibly 63 useless
ring buffers taking up space. With a default buffer of 3 megs, this
could be quite drastic.

This patch changes the ring buffer code to only allocate ring buffers
for online CPUs.  If a CPU goes off line, we do not free the buffer.
This is because the user may still have trace data in that buffer
that they would like to look at.

Perhaps in the future we could add code to delete a ring buffer if
the CPU is offline and the ring buffer becomes empty.

Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
</content>
</entry>
</feed>
