From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ian Rogers <irogers@google.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Sandipan Das <sandipan.das@amd.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
German Gomez <german.gomez@arm.com>,
James Clark <james.clark@arm.com>, Nick Terrell <terrelln@fb.com>,
Sean Christopherson <seanjc@google.com>,
Changbin Du <changbin.du@huawei.com>,
liuwenyu <liuwenyu7@huawei.com>,
Yang Jihong <yangjihong1@huawei.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Miguel Ojeda <ojeda@kernel.org>, Song Liu <song@kernel.org>,
Leo Yan <leo.yan@linaro.org>, Kajol Jain <kjain@linux.ibm.com>,
Andi Kleen <ak@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Yanteng Si <siyanteng@loongson.cn>,
Liam Howlett <liam.howlett@oracle.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuai Xue <xueshuai@linux.alibaba.com>
Subject: [PATCH 5.10 51/82] Revert "perf hist: Add missing puts to hist__account_cycles"
Date: Fri, 15 Nov 2024 07:38:28 +0100 [thread overview]
Message-ID: <20241115063727.397985268@linuxfoundation.org> (raw)
In-Reply-To: <20241115063725.561151311@linuxfoundation.org>
5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuai Xue <xueshuai@linux.alibaba.com>
Revert "perf hist: Add missing puts to hist__account_cycles"
This reverts commit a83fc293acd5c5050a4828eced4a71d2b2fffdd3.
On x86 platform, kernel v5.10.228, perf-report command aborts due to "free():
invalid pointer" when perf-record command is run with taken branch stack
sampling enabled. This regression can be reproduced with the following steps:
- sudo perf record -b
- sudo perf report
The root cause is that bi[i].to.ms.maps does not always point to thread->maps,
which is a buffer dynamically allocated by maps_new(). Instead, it may point to
&machine->kmaps, while kmaps is not a pointer but a variable. The original
upstream commit c1149037f65b ("perf hist: Add missing puts to
hist__account_cycles") worked well because machine->kmaps had been refactored to
a pointer by the previous commit 1a97cee604dc ("perf maps: Use a pointer for
kmaps").
To this end, just revert commit a83fc293acd5c5050a4828eced4a71d2b2fffdd3.
It is worth noting that the memory leak issue, which the reverted patch intended
to fix, has been solved by commit cf96b8e45a9b ("perf session: Add missing
evlist__delete when deleting a session"). The root cause is that the evlist is
not being deleted on exit in perf-report, perf-script, and perf-data.
Consequently, the reference count of the thread increased by thread__get() in
hist_entry__init() is not decremented in hist_entry__delete(). As a result,
thread->maps is not properly freed.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: James Clark <james.clark@arm.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: liuwenyu <liuwenyu7@huawei.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org # 5.10.228
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/perf/util/hist.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -2624,6 +2624,8 @@ void hist__account_cycles(struct branch_
/* If we have branch cycles always annotate them. */
if (bs && bs->nr && entries[0].flags.cycles) {
+ int i;
+
bi = sample__resolve_bstack(sample, al);
if (bi) {
struct addr_map_symbol *prev = NULL;
@@ -2638,7 +2640,7 @@ void hist__account_cycles(struct branch_
* Note that perf stores branches reversed from
* program order!
*/
- for (int i = bs->nr - 1; i >= 0; i--) {
+ for (i = bs->nr - 1; i >= 0; i--) {
addr_map_symbol__account_cycles(&bi[i].from,
nonany_branch_mode ? NULL : prev,
bi[i].flags.cycles);
@@ -2647,12 +2649,6 @@ void hist__account_cycles(struct branch_
if (total_cycles)
*total_cycles += bi[i].flags.cycles;
}
- for (unsigned int i = 0; i < bs->nr; i++) {
- map__put(bi[i].to.ms.map);
- maps__put(bi[i].to.ms.maps);
- map__put(bi[i].from.ms.map);
- maps__put(bi[i].from.ms.maps);
- }
free(bi);
}
}
next prev parent reply other threads:[~2024-11-15 6:57 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 6:37 [PATCH 5.10 00/82] 5.10.230-rc1 review Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 01/82] arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-sapphire-excavator Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 02/82] arm64: dts: rockchip: Remove hdmis 2nd interrupt on rk3328 Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 03/82] arm64: dts: rockchip: Fix bluetooth properties on Rock960 boards Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 04/82] arm64: dts: rockchip: Remove #cooling-cells from fan on Theobroma lion Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 05/82] arm64: dts: rockchip: Fix LED triggers on rk3308-roc-cc Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 06/82] arm64: dts: imx8mp: correct sdhc ipg clk Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 07/82] ARM: dts: rockchip: fix rk3036 acodec node Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 08/82] ARM: dts: rockchip: drop grf reference from rk3036 hdmi Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 09/82] ARM: dts: rockchip: Fix the spi controller on rk3036 Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 10/82] ARM: dts: rockchip: Fix the realtek audio codec on rk3036-kylin Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 11/82] HID: core: zero-initialize the report buffer Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 12/82] security/keys: fix slab-out-of-bounds in key_task_permission Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 13/82] net: enetc: set MAC address to the VF net_device Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 14/82] sctp: properly validate chunk size in sctp_sf_ootb() Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 15/82] can: c_can: fix {rx,tx}_errors statistics Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 16/82] net: hns3: fix kernel crash when uninstalling driver Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 17/82] net: phy: export phy_error and phy_trigger_machine Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 18/82] net: phy: ti: implement generic .handle_interrupt() callback Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 19/82] net: phy: ti: add PHY_RST_AFTER_CLK_EN flag Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 20/82] net: arc: fix the device for dma_map_single/dma_unmap_single Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 21/82] Revert "ALSA: hda/conexant: Mute speakers at suspend / shutdown" Greg Kroah-Hartman
2024-11-15 6:37 ` [PATCH 5.10 22/82] media: stb0899_algo: initialize cfr before using it Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 23/82] media: dvbdev: prevent the risk of out of memory access Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 24/82] media: dvb_frontend: dont play tricks with underflow values Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 25/82] media: adv7604: prevent underflow condition when reporting colorspace Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 26/82] scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 27/82] ALSA: firewire-lib: fix return value on fail in amdtp_tscm_init() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 28/82] ASoC: stm32: spdifrx: fix dma channel release in stm32_spdifrx_remove Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 29/82] media: s5p-jpeg: prevent buffer overflows Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 30/82] media: cx24116: prevent overflows on SNR calculus Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 31/82] media: pulse8-cec: fix data timestamp at pulse8_setup() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 32/82] media: v4l2-tpg: prevent the risk of a division by zero Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 33/82] pwm: imx-tpm: Use correct MODULO value for EPWM mode Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 34/82] drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 35/82] drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 36/82] dm cache: correct the number of origin blocks to match the target length Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 37/82] dm cache: fix out-of-bounds access to the dirty bitset when resizing Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 38/82] dm cache: optimize dirty bit checking with find_next_bit " Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 39/82] dm cache: fix potential out-of-bounds access on the first resume Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 40/82] dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 41/82] io_uring: rename kiocb_end_write() local helper Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 42/82] fs: create kiocb_{start,end}_write() helpers Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 43/82] io_uring: use " Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 44/82] io_uring/rw: fix missing NOWAIT check for O_DIRECT start write Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 45/82] nfs: Fix KMSAN warning in decode_getfattr_attrs() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 46/82] btrfs: reinitialize delayed ref list after deleting it from the list Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 47/82] splice: dont generate zero-len segement bvecs Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 48/82] spi: Fix deadlock when adding SPI controllers on SPI buses Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 49/82] spi: fix use-after-free of the add_lock mutex Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 50/82] net: bridge: xmit: make sure we have at least eth header len bytes Greg Kroah-Hartman
2024-11-15 6:38 ` Greg Kroah-Hartman [this message]
2024-11-15 6:38 ` [PATCH 5.10 52/82] perf session: Add missing evlist__delete when deleting a session Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 53/82] net: do not delay dst_entries_add() in dst_release() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 54/82] media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 55/82] fs/proc: fix compile warning about variable vmcore_mmap_ops Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 56/82] usb: musb: sunxi: Fix accessing an released usb phy Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 57/82] usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 58/82] USB: serial: io_edgeport: fix use after free in debug printk Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 59/82] USB: serial: qcserial: add support for Sierra Wireless EM86xx Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 60/82] USB: serial: option: add Fibocom FG132 0x0112 composition Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 61/82] USB: serial: option: add Quectel RG650V Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 62/82] irqchip/gic-v3: Force propagation of the active state with a read-back Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 63/82] ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 64/82] ALSA: usb-audio: Support jack detection on Dell dock Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 65/82] ALSA: usb-audio: Add quirks for Dell WD19 dock Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 66/82] hv_sock: Initializing vsk->trans to NULL to prevent a dangling pointer Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 67/82] vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 68/82] ALSA: usb-audio: Add endianness annotations Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 69/82] net: phy: ti: take into account all possible interrupt sources Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 70/82] 9p: Avoid creating multiple slab caches with the same name Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 71/82] HID: multitouch: Add quirk for HONOR MagicBook Art 14 touchpad Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 72/82] bpf: use kvzmalloc to allocate BPF verifier environment Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 73/82] crypto: marvell/cesa - Disable hash algorithms Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 74/82] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 75/82] powerpc/powernv: Free name on error in opal_event_init() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 76/82] vDPA/ifcvf: Fix pci_read_config_byte() return code handling Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 77/82] fs: Fix uninitialized value issue in from_kuid and from_kgid Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 78/82] net: usb: qmi_wwan: add Fibocom FG132 0x0112 composition Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 79/82] md/raid10: improve code of mrdev in raid10_sync_request Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 80/82] io_uring: fix possible deadlock in io_register_iowq_max_workers() Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 81/82] mm: krealloc: Fix MTE false alarm in __do_krealloc Greg Kroah-Hartman
2024-11-15 6:38 ` [PATCH 5.10 82/82] 9p: fix slab cache name creation for real Greg Kroah-Hartman
2024-11-15 9:58 ` [PATCH 5.10 00/82] 5.10.230-rc1 review Dominique Martinet
2024-11-15 18:08 ` Jon Hunter
2024-11-15 18:59 ` Florian Fainelli
2024-11-15 21:27 ` Mark Brown
2024-11-16 12:51 ` Naresh Kamboju
2024-11-17 13:28 ` Pavel Machek
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=20241115063727.397985268@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=changbin.du@huawei.com \
--cc=german.gomez@arm.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=kprateek.nayak@amd.com \
--cc=leo.yan@linaro.org \
--cc=liam.howlett@oracle.com \
--cc=liuwenyu7@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=sandipan.das@amd.com \
--cc=seanjc@google.com \
--cc=siyanteng@loongson.cn \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=terrelln@fb.com \
--cc=xueshuai@linux.alibaba.com \
--cc=yangjihong1@huawei.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