linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Eric B Munson <emunson@mgebm.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Greg KH <gregkh@linuxfoundation.org>
Subject: [PATCH 21/91] powerpc/oprofile: Handle events that raise an exception without overflowing
Date: Sun, 05 Feb 2012 23:10:10 +0100	[thread overview]
Message-ID: <20120205220950.344285644@pcw.home.local> (raw)
In-Reply-To: <0635750f5f06ed2ca212b91fcb5c4483@local>

2.6.27-longterm review patch.  If anyone has any objections, please let us know.

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

commit ad5d5292f16c6c1d7d3e257c4c7407594286b97e upstream.

Commit 0837e3242c73566fc1c0196b4ec61779c25ffc93 fixes a situation on POWER7
where events can roll back if a specualtive event doesn't actually complete.
This can raise a performance monitor exception.  We need to catch this to ensure
that we reset the PMC.  In all cases the PMC will be less than 256 cycles from
overflow.

This patch lifts Anton's fix for the problem in perf and applies it to oprofile
as well.

Signed-off-by: Eric B Munson <emunson@mgebm.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 arch/powerpc/oprofile/op_model_power4.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

Index: longterm-2.6.27/arch/powerpc/oprofile/op_model_power4.c
===================================================================
--- longterm-2.6.27.orig/arch/powerpc/oprofile/op_model_power4.c	2012-02-05 22:34:34.372915404 +0100
+++ longterm-2.6.27/arch/powerpc/oprofile/op_model_power4.c	2012-02-05 22:34:37.870914576 +0100
@@ -254,6 +254,28 @@
 	return is_kernel;
 }
 
+static bool pmc_overflow(unsigned long val)
+{
+	if ((int)val < 0)
+		return true;
+
+	/*
+	 * Events on POWER7 can roll back if a speculative event doesn't
+	 * eventually complete. Unfortunately in some rare cases they will
+	 * raise a performance monitor exception. We need to catch this to
+	 * ensure we reset the PMC. In all cases the PMC will be 256 or less
+	 * cycles from overflow.
+	 *
+	 * We only do this if the first pass fails to find any overflowing
+	 * PMCs because a user might set a period of less than 256 and we
+	 * don't want to mistakenly reset them.
+	 */
+	if (__is_processor(PV_POWER7) && ((0x80000000 - val) <= 256))
+		return true;
+
+	return false;
+}
+
 static void power4_handle_interrupt(struct pt_regs *regs,
 				    struct op_counter_config *ctr)
 {
@@ -274,7 +296,7 @@
 
 	for (i = 0; i < cur_cpu_spec->num_pmcs; ++i) {
 		val = classic_ctr_read(i);
-		if (val < 0) {
+		if (pmc_overflow(val)) {
 			if (oprofile_running && ctr[i].enabled) {
 				oprofile_add_ext_sample(pc, regs, i, is_kernel);
 				classic_ctr_write(i, reset_value[i]);



  parent reply	other threads:[~2012-02-05 22:47 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0635750f5f06ed2ca212b91fcb5c4483@local>
2012-02-05 22:09 ` [PATCH 00/91] 2.6.27.60-longterm review Willy Tarreau
2012-02-05 22:09 ` [PATCH 01/91] UBIFS: fix master node recovery Willy Tarreau
2012-02-05 22:09 ` [PATCH 02/91] slub: fix panic with DISCONTIGMEM Willy Tarreau
2012-02-06 21:58   ` David Rientjes
2012-02-07  6:13     ` Willy Tarreau
2012-02-05 22:09 ` [PATCH 03/91] set memory ranges in N_NORMAL_MEMORY when onlined Willy Tarreau
2012-02-05 22:09 ` [PATCH 04/91] agp: fix arbitrary kernel memory writes Willy Tarreau
2012-02-05 22:09 ` [PATCH 05/91] agp: fix OOM and buffer overflow Willy Tarreau
2012-02-05 22:09 ` [PATCH 06/91] put stricter guards on queue dead checks Willy Tarreau
2012-02-05 22:09 ` [PATCH 07/91] mmc: sdhci-pci: Fix error case in sdhci_pci_probe_slot() Willy Tarreau
2012-02-05 22:09 ` [PATCH 08/91] mmc: sdhci: Check mrq->cmd in sdhci_tasklet_finish Willy Tarreau
2012-02-05 22:09 ` [PATCH 09/91] mmc: sdhci: Check mrq != NULL " Willy Tarreau
2012-02-05 22:09 ` [PATCH 10/91] af_unix: Only allow recv on connected seqpacket sockets Willy Tarreau
2012-02-05 22:10 ` [PATCH 11/91] ARM: 6891/1: prevent heap corruption in OABI semtimedop Willy Tarreau
2012-02-05 22:10 ` [PATCH 12/91] Open with O_CREAT flag set fails to open existing files on non writable directories Willy Tarreau
2012-02-05 22:10 ` [PATCH 13/91] fs/partitions/ldm.c: fix oops caused by corrupted partition table Willy Tarreau
2012-02-05 22:10 ` [PATCH 14/91] SUNRPC: fix NFS client over TCP hangs due to packet loss (Bug 16494) Willy Tarreau
2012-02-05 22:10 ` [PATCH 15/91] Fix corrupted OSF partition table parsing Willy Tarreau
2012-02-05 22:10 ` [PATCH 16/91] sata_via: Delay on vt6420 when starting ATAPI DMA write Willy Tarreau
2012-02-05 22:10 ` [PATCH 17/91] libata: set queue DMA alignment to sector size for ATAPI too Willy Tarreau
2012-02-05 22:10 ` [PATCH 18/91] usb: musb: core: set has_tt flag Willy Tarreau
2012-02-05 22:10 ` [PATCH 19/91] Validate size of EFI GUID partition entries Willy Tarreau
2012-02-05 22:10 ` [PATCH 20/91] libertas: fix cmdpendingq locking Willy Tarreau
2012-02-05 22:10 ` Willy Tarreau [this message]
2012-02-05 22:10 ` [PATCH 22/91] ext3: Fix fs corruption when make_indexed_dir() fails Willy Tarreau
2012-02-05 22:10 ` [PATCH 23/91] Fix for buffer overflow in ldm_frag_add not sufficient Willy Tarreau
2012-02-05 22:10 ` [PATCH 24/91] seqlock: Dont smp_rmb in seqlock reader spin loop Willy Tarreau
2012-02-05 22:10 ` [PATCH 25/91] x86/amd-iommu: Fix 3 possible endless loops Willy Tarreau
2012-02-05 22:10 ` [PATCH 26/91] md: check ->hot_remove_disk when removing disk Willy Tarreau
2012-02-05 22:10 ` [PATCH 27/91] uvcvideo: Remove buffers from the queues when freeing Willy Tarreau
2012-02-05 22:10 ` [PATCH 28/91] cfq-iosched: fix locking around ioc->ioc_data assignment Willy Tarreau
2012-02-05 22:10 ` [PATCH 29/91] cfq-iosched: fix a rcu warning Willy Tarreau
2012-02-05 22:10 ` [PATCH 30/91] SUNRPC: Fix use of static variable in rpcb_getport_async Willy Tarreau
2012-02-05 22:10 ` [PATCH 31/91] x86: Make Dell Latitude E5420 use reboot=pci Willy Tarreau
2012-02-05 22:10 ` [PATCH 32/91] libsas: remove expander from dev list on error Willy Tarreau
2012-02-05 23:48   ` Luben Tuikov
2012-02-06  0:52     ` Wanlong Gao
2012-02-06  1:14       ` Luben Tuikov
2012-02-06  6:25         ` Willy Tarreau
2012-02-05 22:10 ` [PATCH 33/91] powerpc/kdump: Fix timeout in crash_kexec_wait_realmode Willy Tarreau
2012-02-05 22:10 ` [PATCH 34/91] ext3: Fix oops in ext3_try_to_allocate_with_rsv() Willy Tarreau
2012-02-05 22:10 ` [PATCH 35/91] svcrpc: fix list-corrupting race on nfsd shutdown Willy Tarreau
2012-02-05 22:10 ` [PATCH 36/91] powerpc/pseries/hvconsole: Fix dropped console output Willy Tarreau
2012-02-05 22:10 ` [PATCH 37/91] alpha: fix several security issues Willy Tarreau
2012-02-05 22:10 ` [PATCH 38/91] ALSA: timer - Fix Oops at closing slave timer Willy Tarreau
2012-02-05 22:10 ` [PATCH 39/91] powerpc: Fix device tree claim code Willy Tarreau
2012-02-05 22:10 ` [PATCH 40/91] powerpc: pseries: Fix kexec on machines with more than 4TB of RAM Willy Tarreau
2012-02-05 22:10 ` [PATCH 41/91] xen/smp: Warn user why they keel over - nosmp or noapic and what to use instead Willy Tarreau
2012-02-06 16:50   ` Konrad Rzeszutek Wilk
2012-02-06 18:30     ` Willy Tarreau
2012-02-05 22:10 ` [PATCH 42/91] cifs: fix possible memory corruption in CIFSFindNext Willy Tarreau
2012-02-05 22:10 ` [PATCH 43/91] TPM: Call tpm_transmit with correct size Willy Tarreau
2012-02-05 22:10 ` [PATCH 44/91] TPM: Zero buffer after copying to userspace Willy Tarreau
2012-02-05 22:10 ` [PATCH 45/91] aacraid: reset should disable MSI interrupt Willy Tarreau
2012-02-05 22:10 ` [PATCH 46/91] libsas: fix panic when single phy is disabled on a wide port Willy Tarreau
2012-02-05 22:10 ` [PATCH 47/91] KVM: s390: check cpu_id prior to using it Willy Tarreau
2012-02-05 22:10 ` [PATCH 48/91] carminefb: Fix module parameters permissions Willy Tarreau
2012-02-05 22:10 ` [PATCH 49/91] um: fix ubd cow size Willy Tarreau
2012-02-05 22:10 ` [PATCH 50/91] NLM: Dont hang forever on NLM unlock requests Willy Tarreau
2012-02-05 22:10 ` [PATCH 51/91] Bluetooth: Prevent buffer overflow in l2cap config request Willy Tarreau
2012-02-05 22:10 ` [PATCH 52/91] net_sched: Fix qdisc_notify() Willy Tarreau
2012-02-05 22:10 ` [PATCH 53/91] ext4: fix BUG_ON() in ext4_ext_insert_extent() Willy Tarreau
2012-02-05 22:10 ` [PATCH 54/91] drivers/net/rionet.c: fix ethernet address macros for LE platforms Willy Tarreau
2012-02-05 22:10 ` [PATCH 55/91] Make scsi_free_queue() kill pending SCSI commands Willy Tarreau
2012-02-06  7:28   ` Bart Van Assche
2012-02-06  7:37     ` Willy Tarreau
2012-02-05 22:10 ` [PATCH 56/91] hfs: add sanity check for file name length Willy Tarreau
2012-02-05 22:10 ` [PATCH 57/91] USB: Fix Corruption issue in USB ftdi driver ftdi_sio.c Willy Tarreau
2012-02-05 22:10 ` [PATCH 58/91] oprofile, x86: Fix crash when unloading module (nmi timer mode) Willy Tarreau
2012-02-05 22:10 ` [PATCH 59/91] jbd/jbd2: validate sb->s_first in journal_get_superblock() Willy Tarreau
2012-02-05 22:10 ` [PATCH 60/91] Make TASKSTATS require root access Willy Tarreau
2012-02-05 22:10 ` [PATCH 61/91] hfs: fix hfs_find_init() sb->ext_tree NULL ptr oops Willy Tarreau
2012-02-05 22:10 ` [PATCH 62/91] [PATCH] x86, mm: Add __get_user_pages_fast() Willy Tarreau
2012-02-05 22:10 ` [PATCH 63/91] export __get_user_pages_fast() function Willy Tarreau
2012-02-05 22:10 ` [PATCH 64/91] oprofile, x86: Fix nmi-unsafe callgraph support Willy Tarreau
2012-02-05 22:10 ` [PATCH 65/91] ext4: avoid hangs in ext4_da_should_update_i_disksize() Willy Tarreau
2012-02-05 22:10 ` [PATCH 66/91] offb: Fix setting of the pseudo-palette for >8bpp Willy Tarreau
2012-02-05 22:10 ` [PATCH 67/91] offb: Fix bug in calculating requested vram size Willy Tarreau
2012-02-05 22:10 ` [PATCH 68/91] usb: usb-storage doesnt support dynamic id currently, the patch disables the feature to fix an oops Willy Tarreau
2012-02-05 22:10 ` [PATCH 69/91] SCSI: scsi_dh: check queuedata pointer before proceeding further Willy Tarreau
2012-02-05 22:10 ` [PATCH 70/91] ALSA: ice1724 - Check for ac97 to avoid kernel oops Willy Tarreau
2012-02-05 22:11 ` [PATCH 71/91] UBI: fix nameless volumes handling Willy Tarreau
2012-02-05 22:11 ` [PATCH 72/91] svcrpc: fix double-free on shutdown of nfsd after changing pool mode Willy Tarreau
2012-02-05 22:11 ` [PATCH 73/91] nfsd: Fix oops when parsing a 0 length export Willy Tarreau
2012-02-05 22:11 ` [PATCH 74/91] sym53c8xx: Fix NULL pointer dereference in slave_destroy Willy Tarreau
2012-02-05 22:11 ` [PATCH 75/91] [PATCH] bonding: correctly process non-linear skbs Willy Tarreau
2012-02-05 22:11 ` [PATCH 76/91] bonding: Ensure that we unshare skbs prior to calling pskb_may_pull Willy Tarreau
2012-02-05 22:11 ` [PATCH 77/91] block: add proper state guards to __elv_next_request Willy Tarreau
2012-02-05 22:11 ` [PATCH 78/91] x86, 64-bit: Fix copy_[to/from]_user() checks for the userspace address limit Willy Tarreau
2012-02-05 22:11 ` [PATCH 79/91] SCSI: scsi_lib: fix potential NULL dereference Willy Tarreau
2012-02-05 22:11 ` [PATCH 80/91] MAINTAINERS: stable: Update address Willy Tarreau
2012-02-05 22:11 ` [PATCH 81/91] af_packet: prevent information leak Willy Tarreau
2012-02-05 22:11 ` [PATCH 82/91] Fix time() inconsistencies caused by intermediate xtime_cache values being read Willy Tarreau
2012-02-05 22:11 ` [PATCH 83/91] net/ipv4: Check for mistakenly passed in non-IPv4 address Willy Tarreau
2012-02-05 22:11 ` [PATCH 84/91] x86: Fix mmap random address range Willy Tarreau
2012-02-05 22:11 ` [PATCH 85/91] i8k: Tell gcc that *regs gets clobbered Willy Tarreau
2012-02-05 22:11 ` [PATCH 86/91] Fix gcc 4.5.1 miscompiling drivers/char/i8k.c (again) Willy Tarreau
2012-02-05 22:11 ` [PATCH 87/91] kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0 Willy Tarreau
2012-02-05 22:11 ` [PATCH 88/91] kbuild: Fix passing -Wno-* options to gcc 4.4+ Willy Tarreau
2012-02-05 22:11 ` [PATCH 89/91] i8k: Avoid lahf in 64-bit code Willy Tarreau
2012-02-05 22:11 ` [PATCH 90/91] block: fail SCSI passthrough ioctls on partition devices Willy Tarreau
2012-02-05 22:44   ` Paolo Bonzini
2012-02-05 22:53     ` Willy Tarreau
2012-02-07 10:03       ` Paolo Bonzini
2012-02-07 10:21         ` Willy Tarreau
2012-02-05 22:11 ` [PATCH 91/91] dm: do not forward ioctls from logical volumes to the underlying device Willy Tarreau

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=20120205220950.344285644@pcw.home.local \
    --to=w@1wt.eu \
    --cc=benh@kernel.crashing.org \
    --cc=emunson@mgebm.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).