mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Oleg Nesterov <oleg@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: [17/70] perf: Fix task context scheduling
Date: Tue, 19 Apr 2011 13:08:26 -0700	[thread overview]
Message-ID: <20110419201044.974549470@clark.kroah.org> (raw)
In-Reply-To: <20110419201501.GA8865@kroah.com>

2.6.38-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Peter Zijlstra <a.p.zijlstra@chello.nl>

commit ab711fe08297de1485fff0a366e6db8828cafd6a upstream.

Jiri reported:

 |
 | - once an event is created by sys_perf_event_open, task context
 |   is created and it stays even if the event is closed, until the
 |   task is finished ... thats what I see in code and I assume it's
 |   correct
 |
 | - when the task opens event, perf_sched_events jump label is
 |   incremented and following callbacks are started from scheduler
 |
 |         __perf_event_task_sched_in
 |         __perf_event_task_sched_out
 |
 |   These callback *in/out set/unset cpuctx->task_ctx value to the
 |   task context.
 |
 | - close is called on event on CPU 0:
 |         - the task is scheduled on CPU 0
 |         - __perf_event_task_sched_in is called
 |         - cpuctx->task_ctx is set
 |         - perf_sched_events jump label is decremented and == 0
 |         - __perf_event_task_sched_out is not called
 |         - cpuctx->task_ctx on CPU 0 stays set
 |
 | - exit is called on CPU 1:
 |         - the task is scheduled on CPU 1
 |         - perf_event_exit_task is called
 |         - task_ctx_sched_out unsets cpuctx->task_ctx on CPU 1
 |         - put_ctx destroys the context
 |
 | - another call of perf_rotate_context on CPU 0 will use invalid
 |   task_ctx pointer, and eventualy panic.
 |

Cure this the simplest possibly way by partially reverting the
jump_label optimization for the sched_out case.

Reported-and-tested-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Oleg Nesterov <oleg@redhat.com>
LKML-Reference: <1301520405.4859.213.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 include/linux/perf_event.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1052,7 +1052,7 @@ void perf_event_task_sched_out(struct ta
 {
 	perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
 
-	COND_STMT(&perf_task_events, __perf_event_task_sched_out(task, next));
+	__perf_event_task_sched_out(task, next);
 }
 
 extern void perf_event_mmap(struct vm_area_struct *vma);



  parent reply	other threads:[~2011-04-19 20:29 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 20:15 [00/70] 2.6.38.4-rc1-stable review Greg KH
2011-04-19 20:08 ` [01/70] vm: fix vm_pgoff wrap in stack expansion Greg KH
2011-04-19 20:08 ` [02/70] drm/radeon/kms: pll tweaks for rv6xx Greg KH
2011-04-19 20:08 ` [03/70] drm/radeon/kms: fix suspend on rv530 asics Greg KH
2011-04-19 20:08 ` [04/70] cifs: always do is_path_accessible check in cifs_mount Greg KH
2011-04-19 20:08 ` [05/70] cifs: check for private_data before trying to put it Greg KH
2011-04-19 20:08 ` [06/70] cifs: set ra_pages in backing_dev_info Greg KH
2011-04-19 20:08 ` [07/70] cifs: wrap received signature check in srv_mutex Greg KH
2011-04-19 20:08 ` [08/70] [media] video: sn9c102: world-wirtable sysfs files Greg KH
2011-04-19 20:08 ` [09/70] UBIFS: restrict world-writable debugfs files Greg KH
2011-04-19 20:08 ` [10/70] ALSA: hda - Fix pin-config of Gigabyte mobo Greg KH
2011-04-19 20:08 ` [11/70] NET: cdc-phonet, handle empty phonet header Greg KH
2011-04-19 20:08 ` [12/70] x86: Fix a bogus unwind annotation in lib/semaphore_32.S Greg KH
2011-04-19 20:08 ` [13/70] [IA64] tioca: Fix assignment from incompatible pointer warnings Greg KH
2011-04-19 20:08 ` [14/70] [IA64] mca.c: Fix cast from integer to pointer warning Greg KH
2011-04-19 20:08 ` [15/70] vm: fix mlock() on stack guard page Greg KH
2011-04-19 20:08 ` [16/70] UBIFS: fix assertion warnings Greg KH
2011-04-19 20:08 ` Greg KH [this message]
2011-04-19 20:08 ` [18/70] bridge: Fix possibly wrong MLD queries ethernet source address Greg KH
2011-04-19 20:08 ` [19/70] fib: add rtnl locking in ip_fib_net_exit Greg KH
2011-04-19 20:08 ` [20/70] gianfar: Fall back to software tcp/udp checksum on older controllers Greg KH
2011-04-19 20:08 ` [21/70] l2tp: fix possible oops on l2tp_eth module unload Greg KH
2011-04-19 20:08 ` [22/70] net ipv6: Fix duplicate /proc/sys/net/ipv6/neigh directory entries Greg KH
2011-04-19 20:08 ` [23/70] net_sched: fix ip_tos2prio Greg KH
2011-04-19 20:08 ` [24/70] pppoe: drop PPPOX_ZOMBIEs in pppoe_flush_dev Greg KH
2011-04-19 20:08 ` [25/70] sctp: Pass __GFP_NOWARN to hash table allocation attempts Greg KH
2011-04-19 20:08 ` [26/70] tcp: avoid cwnd moderation in undo Greg KH
2011-04-19 20:08 ` [27/70] xfrm: Refcount destination entry on xfrm_lookup Greg KH
2011-04-19 20:08 ` [28/70] vlan: should take into account needed_headroom Greg KH
2011-04-19 20:08 ` [29/70] bridge: Reset IPCB when entering IP stack on NF_FORWARD Greg KH
2011-04-19 20:08 ` [30/70] sparc: Fix .size directive for do_int_load Greg KH
2011-04-19 20:08 ` [31/70] sparc32: Fix might-be-used-uninitialized warning in do_sparc_fault() Greg KH
2011-04-19 20:08 ` [32/70] sparc32: Pass task_struct to schedule_tail() in ret_from_fork Greg KH
2011-04-19 20:08 ` [33/70] sparc64: Fix build errors with gcc-4.6.0 Greg KH
2011-04-19 20:08 ` [34/70] futex: Set FLAGS_HAS_TIMEOUT during futex_wait restart setup Greg KH
2011-04-19 20:08 ` [35/70] kstrto*: converting strings to integers done (hopefully) right Greg KH
2011-04-19 20:08 ` [36/70] mm/thp: use conventional format for boolean attributes Greg KH
2011-04-19 20:08 ` [37/70] ramfs: fix memleak on no-mmu arch Greg KH
2011-04-19 20:08 ` [38/70] oom-kill: remove boost_dying_task_prio() Greg KH
2011-04-19 20:08 ` [39/70] MAINTAINERS: update STABLE BRANCH info Greg KH
2011-04-19 20:08 ` [40/70] UBIFS: fix oops when R/O file-system is fsynced Greg KH
2011-04-19 20:08 ` [41/70] x86, AMD: Set ARAT feature on AMD processors Greg KH
2011-04-19 20:08 ` [42/70] x86, amd: Disable GartTlbWlkErr when BIOS forgets it Greg KH
2011-04-19 20:08 ` [43/70] vfs: Fix absolute RCU path walk failures due to uninitialized seq number Greg KH
2011-04-19 20:08 ` [44/70] ARM: 6864/1: hw_breakpoint: clear DBGVCR out of reset Greg KH
2011-04-19 20:08 ` [45/70] i2c-algo-bit: Call pre/post_xfer for bit_test Greg KH
2011-04-19 20:08 ` [46/70] RTC: add missing "return 0" in new alarm func for rtc-bfin.c Greg KH
2011-04-19 20:08 ` [47/70] sched: Fix erroneous all_pinned logic Greg KH
2011-04-19 20:08 ` [48/70] vmscan: all_unreclaimable() use zone->all_unreclaimable as a name Greg KH
2011-04-21  3:40   ` [Stable-review] " Ben Hutchings
2011-04-21  4:24     ` KOSAKI Motohiro
2011-04-21  4:52       ` Ben Hutchings
2011-04-21  6:10         ` KOSAKI Motohiro
2011-04-25  1:50           ` Ben Hutchings
2011-04-19 20:08 ` [49/70] brk: COMPAT_BRK: fix detection of randomized brk Greg KH
2011-04-19 20:08 ` [50/70] usb: musb: temporarily make it bool Greg KH
2011-04-19 20:09 ` [51/70] USB: ftdi_sio: Added IDs for CTI USB Serial Devices Greg KH
2011-04-19 20:09 ` [52/70] USB: ftdi_sio: add PID for OCT DK201 docking station Greg KH
2011-04-19 20:09 ` [53/70] USB: ftdi_sio: add ids for Hameg HO720 and HO730 Greg KH
2011-04-19 20:09 ` [54/70] USB: option: Added support for Samsung GT-B3730/GT-B3710 LTE USB modem Greg KH
2011-04-19 20:09 ` [55/70] next_pidmap: fix overflow condition Greg KH
2011-04-19 20:09 ` [56/70] proc: do proper range check on readdir offset Greg KH
2011-04-19 20:09 ` [57/70] powerpc: Fix oops if scan_dispatch_log is called too early Greg KH
2011-04-19 20:09 ` [58/70] powerpc/perf_event: Skip updating kernel counters if register value shrinks Greg KH
2011-04-19 20:09 ` [59/70] usb: Fix qcserial memory leak on rmmod Greg KH
2011-04-19 20:09 ` [60/70] usb: qcserial avoid pointing to freed memory Greg KH
2011-04-19 20:09 ` [61/70] usb: qcserial add missing errorpath kfrees Greg KH
2011-04-19 20:09 ` [62/70] USB: EHCI: unlink unused QHs when the controller is stopped Greg KH
2011-04-19 20:09 ` [63/70] USB: fix formatting of SuperSpeed endpoints in /proc/bus/usb/devices Greg KH
2011-04-19 20:09 ` [64/70] USB: xhci - fix unsafe macro definitions Greg KH
2011-04-19 20:09 ` [65/70] USB: xhci - fix math in xhci_get_endpoint_interval() Greg KH
2011-04-19 20:09 ` [66/70] USB: xhci - also free streams when resetting devices Greg KH
2011-04-19 20:09 ` [67/70] USB: Fix unplug of device with active streams Greg KH
2011-04-19 20:09 ` [68/70] radeon: Fix KMS CP writeback on big endian machines Greg KH
2011-04-19 20:09 ` [69/70] Bluetooth: Fix HCI_RESET command synchronization Greg KH
2011-04-19 20:09 ` [70/70] perf tool: Fix gcc 4.6.0 issues Greg KH

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=20110419201044.974549470@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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

Powered by JetHome