<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/events, branch v3.4.95</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/kernel/events?h=v3.4.95</id>
<link rel='self' href='https://git.amat.us/linux/atom/kernel/events?h=v3.4.95'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2014-06-11T19:04:11Z</updated>
<entry>
<title>perf: Fix race in removing an event</title>
<updated>2014-06-11T19:04:11Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2014-05-02T14:56:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=4b2cfc9508d9e509708f85748548e03db696dbcd'/>
<id>urn:sha1:4b2cfc9508d9e509708f85748548e03db696dbcd</id>
<content type='text'>
commit 46ce0fe97a6be7532ce6126bb26ce89fed81528c upstream.

When removing a (sibling) event we do:

	raw_spin_lock_irq(&amp;ctx-&gt;lock);
	perf_group_detach(event);
	raw_spin_unlock_irq(&amp;ctx-&gt;lock);

	&lt;hole&gt;

	perf_remove_from_context(event);
		raw_spin_lock_irq(&amp;ctx-&gt;lock);
		...
		raw_spin_unlock_irq(&amp;ctx-&gt;lock);

Now, assuming the event is a sibling, it will be 'unreachable' for
things like ctx_sched_out() because that iterates the
groups-&gt;siblings, and we just unhooked the sibling.

So, if during &lt;hole&gt; we get ctx_sched_out(), it will miss the event
and not call event_sched_out() on it, leaving it programmed on the
PMU.

The subsequent perf_remove_from_context() call will find the ctx is
inactive and only call list_del_event() to remove the event from all
other lists.

Hereafter we can proceed to free the event; while still programmed!

Close this hole by moving perf_group_detach() inside the same
ctx-&gt;lock region(s) perf_remove_from_context() has.

The condition on inherited events only in __perf_event_exit_task() is
likely complete crap because non-inherited events are part of groups
too and we're tearing down just the same. But leave that for another
patch.

Most-likely-Fixes: e03a9a55b4e ("perf: Change close() semantics for group events")
Reported-by: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Tested-by: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Much-staring-at-traces-by: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Much-staring-at-traces-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Link: http://lkml.kernel.org/r/20140505093124.GN17778@laptop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Limit perf_event_attr::sample_period to 63 bits</title>
<updated>2014-06-11T19:04:11Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2014-05-15T18:23:48Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=183f99ecb6a484c142ae2fc99df3ef5cdadc3985'/>
<id>urn:sha1:183f99ecb6a484c142ae2fc99df3ef5cdadc3985</id>
<content type='text'>
commit 0819b2e30ccb93edf04876237b6205eef84ec8d2 upstream.

Vince reported that using a large sample_period (one with bit 63 set)
results in wreckage since while the sample_period is fundamentally
unsigned (negative periods don't make sense) the way we implement
things very much rely on signed logic.

So limit sample_period to 63 bits to avoid tripping over this.

Reported-by: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Link: http://lkml.kernel.org/n/tip-p25fhunibl4y3qi0zuqmyf4b@git.kernel.org
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Prevent false warning in perf_swevent_add</title>
<updated>2014-06-11T19:04:10Z</updated>
<author>
<name>Jiri Olsa</name>
<email>jolsa@redhat.com</email>
</author>
<published>2014-04-07T09:04:08Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=0d41f6026aa0c15d60e75f8f71f1408c32fe1ba4'/>
<id>urn:sha1:0d41f6026aa0c15d60e75f8f71f1408c32fe1ba4</id>
<content type='text'>
commit 39af6b1678afa5880dda7e375cf3f9d395087f6d upstream.

The perf cpu offline callback takes down all cpu context
events and releases swhash-&gt;swevent_hlist.

This could race with task context software event being just
scheduled on this cpu via perf_swevent_add while cpu hotplug
code already cleaned up event's data.

The race happens in the gap between the cpu notifier code
and the cpu being actually taken down. Note that only cpu
ctx events are terminated in the perf cpu hotplug code.

It's easily reproduced with:
  $ perf record -e faults perf bench sched pipe

while putting one of the cpus offline:
  # echo 0 &gt; /sys/devices/system/cpu/cpu1/online

Console emits following warning:
  WARNING: CPU: 1 PID: 2845 at kernel/events/core.c:5672 perf_swevent_add+0x18d/0x1a0()
  Modules linked in:
  CPU: 1 PID: 2845 Comm: sched-pipe Tainted: G        W    3.14.0+ #256
  Hardware name: Intel Corporation Montevina platform/To be filled by O.E.M., BIOS AMVACRB1.86C.0066.B00.0805070703 05/07/2008
   0000000000000009 ffff880077233ab8 ffffffff81665a23 0000000000200005
   0000000000000000 ffff880077233af8 ffffffff8104732c 0000000000000046
   ffff88007467c800 0000000000000002 ffff88007a9cf2a0 0000000000000001
  Call Trace:
   [&lt;ffffffff81665a23&gt;] dump_stack+0x4f/0x7c
   [&lt;ffffffff8104732c&gt;] warn_slowpath_common+0x8c/0xc0
   [&lt;ffffffff8104737a&gt;] warn_slowpath_null+0x1a/0x20
   [&lt;ffffffff8110fb3d&gt;] perf_swevent_add+0x18d/0x1a0
   [&lt;ffffffff811162ae&gt;] event_sched_in.isra.75+0x9e/0x1f0
   [&lt;ffffffff8111646a&gt;] group_sched_in+0x6a/0x1f0
   [&lt;ffffffff81083dd5&gt;] ? sched_clock_local+0x25/0xa0
   [&lt;ffffffff811167e6&gt;] ctx_sched_in+0x1f6/0x450
   [&lt;ffffffff8111757b&gt;] perf_event_sched_in+0x6b/0xa0
   [&lt;ffffffff81117a4b&gt;] perf_event_context_sched_in+0x7b/0xc0
   [&lt;ffffffff81117ece&gt;] __perf_event_task_sched_in+0x43e/0x460
   [&lt;ffffffff81096f1e&gt;] ? put_lock_stats.isra.18+0xe/0x30
   [&lt;ffffffff8107b3c8&gt;] finish_task_switch+0xb8/0x100
   [&lt;ffffffff8166a7de&gt;] __schedule+0x30e/0xad0
   [&lt;ffffffff81172dd2&gt;] ? pipe_read+0x3e2/0x560
   [&lt;ffffffff8166b45e&gt;] ? preempt_schedule_irq+0x3e/0x70
   [&lt;ffffffff8166b45e&gt;] ? preempt_schedule_irq+0x3e/0x70
   [&lt;ffffffff8166b464&gt;] preempt_schedule_irq+0x44/0x70
   [&lt;ffffffff816707f0&gt;] retint_kernel+0x20/0x30
   [&lt;ffffffff8109e60a&gt;] ? lockdep_sys_exit+0x1a/0x90
   [&lt;ffffffff812a4234&gt;] lockdep_sys_exit_thunk+0x35/0x67
   [&lt;ffffffff81679321&gt;] ? sysret_check+0x5/0x56

Fixing this by tracking the cpu hotplug state and displaying
the WARN only if current cpu is initialized properly.

Cc: Corey Ashford &lt;cjashfor@linux.vnet.ibm.com&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@redhat.com&gt;
Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Link: http://lkml.kernel.org/r/1396861448-10097-1-git-send-email-jolsa@redhat.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Fix error return code</title>
<updated>2014-06-07T23:02:04Z</updated>
<author>
<name>Wei Yongjun</name>
<email>yongjun_wei@trendmicro.com.cn</email>
</author>
<published>2013-04-12T03:05:54Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=926685e95e4d6518110794b77676b3bb7f9c4be0'/>
<id>urn:sha1:926685e95e4d6518110794b77676b3bb7f9c4be0</id>
<content type='text'>
commit c481420248c6730246d2a1b1773d5d7007ae0835 upstream.

Fix to return -ENOMEM in the allocation error case instead of 0
(if pmu_bus_running == 1), as done elsewhere in this function.

Signed-off-by: Wei Yongjun &lt;yongjun_wei@trendmicro.com.cn&gt;
Cc: a.p.zijlstra@chello.nl
Cc: paulus@samba.org
Cc: acme@ghostprotocols.net
Link: http://lkml.kernel.org/r/CAPgLHd8j_fWcgqe%3DKLWjpBj%2B%3Do0Pw6Z-SEq%3DNTPU08c2w1tngQ@mail.gmail.com
[ Tweaked the error code setting placement and the changelog. ]
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Rui Xiang &lt;rui.xiang@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Fix perf ring buffer memory ordering</title>
<updated>2014-06-07T23:02:04Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2013-10-28T12:55:29Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1fbbea7be9248d652fc2bb191e6ec9e823df422c'/>
<id>urn:sha1:1fbbea7be9248d652fc2bb191e6ec9e823df422c</id>
<content type='text'>
commit bf378d341e4873ed928dc3c636252e6895a21f50 upstream.

The PPC64 people noticed a missing memory barrier and crufty old
comments in the perf ring buffer code. So update all the comments and
add the missing barrier.

When the architecture implements local_t using atomic_long_t there
will be double barriers issued; but short of introducing more
conditional barrier primitives this is the best we can do.

Reported-by: Victor Kaplansky &lt;victork@il.ibm.com&gt;
Tested-by: Victor Kaplansky &lt;victork@il.ibm.com&gt;
Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@polymtl.ca&gt;
Cc: michael@ellerman.id.au
Cc: Paul McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: Michael Neuling &lt;mikey@neuling.org&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: anton@samba.org
Cc: benh@kernel.crashing.org
Link: http://lkml.kernel.org/r/20131025173749.GG19466@laptop.lan
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Cc: Rui Xiang &lt;rui.xiang@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>list: introduce list_next_entry() and list_prev_entry()</title>
<updated>2014-06-07T23:01:58Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-11-12T23:10:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=fce85b081c08c1326d9bcab0ff9ea1c85b7e9858'/>
<id>urn:sha1:fce85b081c08c1326d9bcab0ff9ea1c85b7e9858</id>
<content type='text'>
[ Upstream commit 008208c6b26f21c2648c250a09c55e737c02c5f8 ]

Add two trivial helpers list_next_entry() and list_prev_entry(), they
can have a lot of users including list.h itself.  In fact the 1st one is
already defined in events/core.c and bnx2x_sp.c, so the patch simply
moves the definition to list.h.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Eilon Greenstein &lt;eilong@broadcom.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>perf: Fix hotplug splat</title>
<updated>2014-03-11T23:10:02Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2014-02-24T11:06:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f80747a43fc2613b9f5e1ded16f50ef28815652e'/>
<id>urn:sha1:f80747a43fc2613b9f5e1ded16f50ef28815652e</id>
<content type='text'>
commit e3703f8cdfcf39c25c4338c3ad8e68891cca3731 upstream.

Drew Richardson reported that he could make the kernel go *boom* when hotplugging
while having perf events active.

It turned out that when you have a group event, the code in
__perf_event_exit_context() fails to remove the group siblings from
the context.

We then proceed with destroying and freeing the event, and when you
re-plug the CPU and try and add another event to that CPU, things go
*boom* because you've still got dead entries there.

Reported-by: Drew Richardson &lt;drew.richardson@arm.com&gt;
Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Will Deacon &lt;will.deacon@arm.com&gt;
Link: http://lkml.kernel.org/n/tip-k6v5wundvusvcseqj1si0oz0@git.kernel.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Fix perf_cgroup_switch for sw-events</title>
<updated>2013-10-01T16:10:52Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>a.p.zijlstra@chello.nl</email>
</author>
<published>2012-10-02T13:41:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1d48ca6f38fa39298474708abebeffef4ef2cd2d'/>
<id>urn:sha1:1d48ca6f38fa39298474708abebeffef4ef2cd2d</id>
<content type='text'>
commit 95cf59ea72331d0093010543b8951bb43f262cac upstream.

Jiri reported that he could trigger the WARN_ON_ONCE() in
perf_cgroup_switch() using sw-events. This is because sw-events share
a cpuctx with multiple PMUs.

Use the -&gt;unique_pmu pointer to limit the pmu iteration to unique
cpuctx instances.

Reported-and-Tested-by: Jiri Olsa &lt;jolsa@redhat.com&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Link: http://lkml.kernel.org/n/tip-so7wi2zf3jjzrwcutm2mkz0j@git.kernel.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::unique_pmu</title>
<updated>2013-10-01T16:10:52Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>a.p.zijlstra@chello.nl</email>
</author>
<published>2012-10-02T13:38:52Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2cd21fa1b54efaf6b5912ef2833fa474fdcf92b7'/>
<id>urn:sha1:2cd21fa1b54efaf6b5912ef2833fa474fdcf92b7</id>
<content type='text'>
commit 3f1f33206c16c7b3839d71372bc2ac3f305aa802 upstream.

Stephane thought the perf_cpu_context::active_pmu name confusing and
suggested using 'unique_pmu' instead.

This pointer is a pointer to a 'random' pmu sharing the cpuctx
instance, therefore limiting a for_each_pmu loop to those where
cpuctx-&gt;unique_pmu matches the pmu we get a loop over unique cpuctx
instances.

Suggested-by: Stephane Eranian &lt;eranian@google.com&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Link: http://lkml.kernel.org/n/tip-kxyjqpfj2fn9gt7kwu5ag9ks@git.kernel.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>perf: Use css_tryget() to avoid propping up css refcount</title>
<updated>2013-08-11T22:38:43Z</updated>
<author>
<name>Salman Qazi</name>
<email>sqazi@google.com</email>
</author>
<published>2012-06-14T22:31:09Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2d8be9cf0668fab848b9b7740f0725ae9181b703'/>
<id>urn:sha1:2d8be9cf0668fab848b9b7740f0725ae9181b703</id>
<content type='text'>
commit 9c5da09d266ca9b32eb16cf940f8161d949c2fe5 upstream.

An rmdir pushes css's ref count to zero.  However, if the associated
directory is open at the time, the dentry ref count is non-zero.  If
the fd for this directory is then passed into perf_event_open, it
does a css_get().  This bounces the ref count back up from zero.  This
is a problem by itself.  But what makes it turn into a crash is the
fact that we end up doing an extra dput, since we perform a dput
when css_put sees the ref count go down to zero.

css_tryget() does not fall into that trap. So, we use that instead.

Reproduction test-case for the bug:

 #include &lt;unistd.h&gt;
 #include &lt;sys/types.h&gt;
 #include &lt;sys/stat.h&gt;
 #include &lt;fcntl.h&gt;
 #include &lt;linux/unistd.h&gt;
 #include &lt;linux/perf_event.h&gt;
 #include &lt;string.h&gt;
 #include &lt;errno.h&gt;
 #include &lt;stdio.h&gt;

 #define PERF_FLAG_PID_CGROUP    (1U &lt;&lt; 2)

 int perf_event_open(struct perf_event_attr *hw_event_uptr,
                     pid_t pid, int cpu, int group_fd, unsigned long flags) {
         return syscall(__NR_perf_event_open,hw_event_uptr, pid, cpu,
                 group_fd, flags);
 }

 /*
  * Directly poke at the perf_event bug, since it's proving hard to repro
  * depending on where in the kernel tree.  what moved?
  */
 int main(int argc, char **argv)
 {
        int fd;
        struct perf_event_attr attr;
        memset(&amp;attr, 0, sizeof(attr));
        attr.exclude_kernel = 1;
        attr.size = sizeof(attr);
        mkdir("/dev/cgroup/perf_event/blah", 0777);
        fd = open("/dev/cgroup/perf_event/blah", O_RDONLY);
        perror("open");
        rmdir("/dev/cgroup/perf_event/blah");
        sleep(2);
        perf_event_open(&amp;attr, fd, 0, -1,  PERF_FLAG_PID_CGROUP);
        perror("perf_event_open");
        close(fd);
        return 0;
 }

Signed-off-by: Salman Qazi &lt;sqazi@google.com&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Link: http://lkml.kernel.org/r/20120614223108.1025.2503.stgit@dungbeetle.mtv.corp.google.com
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
</feed>
