linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Klaus Theurich <klaus.theurich@de.ibm.com>,
	Thomas Richter <tmricht@linux.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Hendrik Brueckner <brueckner@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 4.19 20/91] perf annotate: Fix s390 gap between kernel end and module start
Date: Wed, 14 Aug 2019 19:00:43 +0200	[thread overview]
Message-ID: <20190814165750.587317981@linuxfoundation.org> (raw)
In-Reply-To: <20190814165748.991235624@linuxfoundation.org>

From: Thomas Richter <tmricht@linux.ibm.com>

commit b9c0a64901d5bdec6eafd38d1dc8fa0e2974fccb upstream.

During execution of command 'perf top' the error message:

   Not enough memory for annotating '__irf_end' symbol!)

is emitted from this call sequence:
  __cmd_top
    perf_top__mmap_read
      perf_top__mmap_read_idx
        perf_event__process_sample
          hist_entry_iter__add
            hist_iter__top_callback
              perf_top__record_precise_ip
                hist_entry__inc_addr_samples
                  symbol__inc_addr_samples
                    symbol__get_annotation
                      symbol__alloc_hist

In this function the size of symbol __irf_end is calculated. The size of
a symbol is the difference between its start and end address.

When the symbol was read the first time, its start and end was set to:

   symbol__new: __irf_end 0xe954d0-0xe954d0

which is correct and maps with /proc/kallsyms:

   root@s8360046:~/linux-4.15.0/tools/perf# fgrep _irf_end /proc/kallsyms
   0000000000e954d0 t __irf_end
   root@s8360046:~/linux-4.15.0/tools/perf#

In function symbol__alloc_hist() the end of symbol __irf_end is

  symbol__alloc_hist sym:__irf_end start:0xe954d0 end:0x3ff80045a8

which is identical with the first module entry in /proc/kallsyms

This results in a symbol size of __irf_req for histogram analyses of
70334140059072 bytes and a malloc() for this requested size fails.

The root cause of this is function
  __dso__load_kallsyms()
  +-> symbols__fixup_end()

Function symbols__fixup_end() enlarges the last symbol in the kallsyms
map:

   # fgrep __irf_end /proc/kallsyms
   0000000000e954d0 t __irf_end
   #

to the start address of the first module:
   # cat /proc/kallsyms | sort  | egrep ' [tT] '
   ....
   0000000000e952d0 T __security_initcall_end
   0000000000e954d0 T __initramfs_size
   0000000000e954d0 t __irf_end
   000003ff800045a8 T fc_get_event_number       [scsi_transport_fc]
   000003ff800045d0 t store_fc_vport_disable    [scsi_transport_fc]
   000003ff800046a8 T scsi_is_fc_rport  [scsi_transport_fc]
   000003ff800046d0 t fc_target_setup   [scsi_transport_fc]

On s390 the kernel is located around memory address 0x200, 0x10000 or
0x100000, depending on linux version. Modules however start some- where
around 0x3ff xxxx xxxx.

This is different than x86 and produces a large gap for which histogram
allocation fails.

Fix this by detecting the kernel's last symbol and do no adjustment for
it. Introduce a weak function and handle s390 specifics.

Reported-by: Klaus Theurich <klaus.theurich@de.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20190724122703.3996-2-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 tools/perf/arch/s390/util/machine.c |   17 +++++++++++++++++
 tools/perf/util/symbol.c            |    7 ++++++-
 tools/perf/util/symbol.h            |    1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

--- a/tools/perf/arch/s390/util/machine.c
+++ b/tools/perf/arch/s390/util/machine.c
@@ -6,6 +6,7 @@
 #include "machine.h"
 #include "api/fs/fs.h"
 #include "debug.h"
+#include "symbol.h"
 
 int arch__fix_module_text_start(u64 *start, const char *name)
 {
@@ -21,3 +22,19 @@ int arch__fix_module_text_start(u64 *sta
 
 	return 0;
 }
+
+/* On s390 kernel text segment start is located at very low memory addresses,
+ * for example 0x10000. Modules are located at very high memory addresses,
+ * for example 0x3ff xxxx xxxx. The gap between end of kernel text segment
+ * and beginning of first module's text segment is very big.
+ * Therefore do not fill this gap and do not assign it to the kernel dso map.
+ */
+void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
+{
+	if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
+		/* Last kernel symbol mapped to end of page */
+		p->end = roundup(p->end, page_size);
+	else
+		p->end = c->start;
+	pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
+}
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -86,6 +86,11 @@ static int prefix_underscores_count(cons
 	return tail - str;
 }
 
+void __weak arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
+{
+	p->end = c->start;
+}
+
 const char * __weak arch__normalize_symbol_name(const char *name)
 {
 	return name;
@@ -212,7 +217,7 @@ void symbols__fixup_end(struct rb_root *
 		curr = rb_entry(nd, struct symbol, rb_node);
 
 		if (prev->end == prev->start && prev->end != curr->start)
-			prev->end = curr->start;
+			arch__symbols__fixup_end(prev, curr);
 	}
 
 	/* Last entry */
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -349,6 +349,7 @@ const char *arch__normalize_symbol_name(
 #define SYMBOL_A 0
 #define SYMBOL_B 1
 
+void arch__symbols__fixup_end(struct symbol *p, struct symbol *c);
 int arch__compare_symbol_names(const char *namea, const char *nameb);
 int arch__compare_symbol_names_n(const char *namea, const char *nameb,
 				 unsigned int n);



  parent reply	other threads:[~2019-08-14 17:09 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 17:00 [PATCH 4.19 00/91] 4.19.67-stable review Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 01/91] iio: cros_ec_accel_legacy: Fix incorrect channel setting Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 02/91] iio: adc: max9611: Fix misuse of GENMASK macro Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 03/91] staging: gasket: apex: fix copy-paste typo Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 04/91] staging: android: ion: Bail out upon SIGKILL when allocating memory Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 05/91] crypto: ccp - Fix oops by properly managing allocated structures Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 06/91] crypto: ccp - Add support for valid authsize values less than 16 Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 07/91] crypto: ccp - Ignore tag length when decrypting GCM ciphertext Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 08/91] usb: usbfs: fix double-free of usb memory upon submiturb error Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 09/91] usb: iowarrior: fix deadlock on disconnect Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 10/91] sound: fix a memory leak bug Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 11/91] mmc: cavium: Set the correct dma max segment size for mmc_host Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 12/91] mmc: cavium: Add the missing dma unmap when the dma has finished Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 13/91] loop: set PF_MEMALLOC_NOIO for the worker thread Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 14/91] Input: usbtouchscreen - initialize PM mutex before using it Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 15/91] Input: elantech - enable SMBus on new (2018+) systems Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 16/91] Input: synaptics - enable RMI mode for HP Spectre X360 Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 17/91] x86/mm: Check for pfn instead of page in vmalloc_sync_one() Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 18/91] x86/mm: Sync also unmappings in vmalloc_sync_all() Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 19/91] mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() Greg Kroah-Hartman
2019-08-14 17:00 ` Greg Kroah-Hartman [this message]
2019-08-14 17:00 ` [PATCH 4.19 21/91] perf db-export: Fix thread__exec_comm() Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 22/91] perf record: Fix module size on s390 Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 23/91] x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 24/91] gfs2: gfs2_walk_metadata fix Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 25/91] usb: host: xhci-rcar: Fix timeout in xhci_suspend() Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 26/91] usb: yurex: Fix use-after-free in yurex_delete Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 27/91] usb: typec: tcpm: free log buf memory when remove debug file Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 28/91] usb: typec: tcpm: remove tcpm dir if no children Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 29/91] usb: typec: tcpm: Add NULL check before dereferencing config Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 30/91] usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 31/91] can: rcar_canfd: fix possible IRQ storm on high load Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 32/91] can: peak_usb: fix potential double kfree_skb() Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 33/91] netfilter: nfnetlink: avoid deadlock due to synchronous request_module Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 34/91] vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 35/91] netfilter: Fix rpfilter dropping vrf packets by mistake Greg Kroah-Hartman
2019-08-14 17:00 ` [PATCH 4.19 36/91] netfilter: conntrack: always store window size un-scaled Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 37/91] netfilter: nft_hash: fix symhash with modulus one Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 38/91] scripts/sphinx-pre-install: fix script for RHEL/CentOS Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 39/91] drm/amd/display: Wait for backlight programming completion in set backlight level Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 40/91] drm/amd/display: use encoders engine id to find matched free audio device Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 41/91] drm/amd/display: Fix dc_create failure handling and 666 color depths Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 42/91] drm/amd/display: Only enable audio if speaker allocation exists Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 43/91] drm/amd/display: Increase size of audios array Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 44/91] iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 45/91] nl80211: fix NL80211_HE_MAX_CAPABILITY_LEN Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 46/91] mac80211: dont warn about CW params when not using them Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 47/91] allocate_flower_entry: should check for null deref Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 48/91] hwmon: (nct6775) Fix register address and added missed tolerance for nct6106 Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 49/91] drm: silence variable conn set but not used Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 50/91] cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 51/91] s390/qdio: add sanity checks to the fast-requeue path Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 52/91] ALSA: compress: Fix regression on compressed capture streams Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 53/91] ALSA: compress: Prevent bypasses of set_params Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 54/91] ALSA: compress: Dont allow paritial drain operations on capture streams Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 55/91] ALSA: compress: Be more restrictive about when a drain is allowed Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 56/91] perf tools: Fix proper buffer size for feature processing Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 57/91] perf probe: Avoid calling freeing routine multiple times for same pointer Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 58/91] drbd: dynamically allocate shash descriptor Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 59/91] ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 60/91] nvme: fix multipath crash when ANA is deactivated Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 61/91] ARM: davinci: fix sleep.S build error on ARMv4 Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 62/91] ARM: dts: bcm: bcm47094: add missing #cells for mdio-bus-mux Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 63/91] scsi: megaraid_sas: fix panic on loading firmware crashdump Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 64/91] scsi: ibmvfc: fix WARN_ON during event pool release Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 65/91] scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 66/91] test_firmware: fix a memory leak bug Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 67/91] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 68/91] perf/core: Fix creating kernel counters for PMUs that override event->cpu Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 69/91] s390/dma: provide proper ARCH_ZONE_DMA_BITS value Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 70/91] HID: sony: Fix race condition between rumble and device remove Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 71/91] x86/purgatory: Do not use __builtin_memcpy and __builtin_memset Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 72/91] ALSA: usb-audio: fix a memory leak bug Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 73/91] can: peak_usb: pcan_usb_pro: Fix info-leaks to USB devices Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 74/91] can: peak_usb: pcan_usb_fd: " Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 75/91] hwmon: (nct7802) Fix wrong detection of in4 presence Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 76/91] drm/i915: Fix wrong escape clock divisor init for GLK Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 77/91] ALSA: firewire: fix a memory leak bug Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 78/91] ALSA: hiface: fix multiple memory leak bugs Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 79/91] ALSA: hda - Dont override global PCM hw info flag Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 80/91] ALSA: hda - Workaround for crackled sound on AMD controller (1022:1457) Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 81/91] mac80211: dont WARN on short WMM parameters from AP Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 82/91] dax: dax_layout_busy_page() should not unmap cow pages Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 83/91] SMB3: Fix deadlock in validate negotiate hits reconnect Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 84/91] smb3: send CAP_DFS capability during session setup Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 85/91] NFSv4: Fix an Oops in nfs4_do_setattr Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 86/91] KVM: Fix leak vCPUs VMCS value into other pCPU Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 87/91] mwifiex: fix 802.11n/WPA detection Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 88/91] iwlwifi: dont unmap as page memory that was mapped as single Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 89/91] iwlwifi: mvm: fix an out-of-bound access Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 90/91] iwlwifi: mvm: dont send GEO_TX_POWER_LIMIT on version < 41 Greg Kroah-Hartman
2019-08-14 17:01 ` [PATCH 4.19 91/91] iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support Greg Kroah-Hartman
2019-08-14 21:36 ` [PATCH 4.19 00/91] 4.19.67-stable review kernelci.org bot
2019-08-15  1:29 ` Naresh Kamboju
2019-08-15 13:29 ` Guenter Roeck
2019-08-15 13:58   ` Daniel Díaz
2019-08-15 14:05     ` Guenter Roeck
2019-08-15 19:37     ` Greg Kroah-Hartman
2019-08-15 20:20       ` Guenter Roeck
2019-08-15 20:42         ` Greg Kroah-Hartman
2019-08-15 21:32           ` Guenter Roeck
2019-08-15 22:06             ` Greg Kroah-Hartman
2019-08-15 15:17 ` Guenter Roeck
2019-08-16  2:09 ` shuah
2019-08-16  6:38 ` Kelsey Skunberg
2019-08-16  6:53 ` Jinpu Wang

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=20190814165750.587317981@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=brueckner@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=klaus.theurich@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tmricht@linux.ibm.com \
    /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).