stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andi Kleen <andi@firstfloor.org>, David Ahern <dsahern@gmail.com>,
	"Namhyung Kim" <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 3.18 04/25] perf top: Fix window dimensions change handling
Date: Sun, 28 Jan 2018 22:29:43 +0000	[thread overview]
Message-ID: <20180128222931.7781-4-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180128222931.7781-1-alexander.levin@microsoft.com>

From: Jiri Olsa <jolsa@kernel.org>

[ Upstream commit 89d0aeab4252adc2a7ea693637dd21c588bfa2d1 ]

The stdio perf top crashes when we change the terminal
window size. The reason is that we assumed we get the
perf_top pointer as a signal handler argument which is
not the case.

Changing the SIGWINCH handler logic to change global
resize variable, which is checked in the main thread
loop.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ysuzwz77oev1ftgvdscn9bpu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 tools/perf/builtin-top.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0aa7747ff139..8e37334db4fa 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -70,6 +70,7 @@
 #include <linux/types.h>
 
 static volatile int done;
+static volatile int resize;
 
 #define HEADER_LINE_NR  5
 
@@ -79,10 +80,13 @@ static void perf_top__update_print_entries(struct perf_top *top)
 }
 
 static void perf_top__sig_winch(int sig __maybe_unused,
-				siginfo_t *info __maybe_unused, void *arg)
+				siginfo_t *info __maybe_unused, void *arg __maybe_unused)
 {
-	struct perf_top *top = arg;
+	resize = 1;
+}
 
+static void perf_top__resize(struct perf_top *top)
+{
 	get_term_dimensions(&top->winsize);
 	perf_top__update_print_entries(top);
 }
@@ -461,7 +465,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
 					.sa_sigaction = perf_top__sig_winch,
 					.sa_flags     = SA_SIGINFO,
 				};
-				perf_top__sig_winch(SIGWINCH, NULL, top);
+				perf_top__resize(top);
 				sigaction(SIGWINCH, &act, NULL);
 			} else {
 				signal(SIGWINCH, SIG_DFL);
@@ -997,6 +1001,11 @@ static int __cmd_top(struct perf_top *top)
 
 		if (hits == top->samples)
 			ret = perf_evlist__poll(top->evlist, 100);
+
+		if (resize) {
+			perf_top__resize(top);
+			resize = 0;
+		}
 	}
 
 	ret = 0;
-- 
2.11.0

  parent reply	other threads:[~2018-01-28 22:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28 22:29 [PATCH AUTOSEL for 3.18 01/25] usb: build drivers/usb/common/ when USB_SUPPORT is set Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 02/25] ARM: AM33xx: PRM: Remove am33xx_pwrdm_read_prev_pwrst function Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 03/25] ARM: dts: am4372: Correct the interrupts_properties of McASP Sasha Levin
2018-01-28 22:29 ` Sasha Levin [this message]
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 05/25] perf bench numa: Fixup discontiguous/sparse numa nodes Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 06/25] media: s5k6aa: describe some function parameters Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 07/25] scripts/kernel-doc: Don't fail with status != 0 if error encountered with -none Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 08/25] m68k: add missing SOFTIRQENTRY_TEXT linker section Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 09/25] powerpc/perf: Fix oops when grouping different pmu events Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 10/25] s390/dasd: prevent prefix I/O error Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 11/25] gianfar: fix a flooded alignment reports because of padding issue Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 12/25] net_sched: red: Avoid devision by zero Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 13/25] net_sched: red: Avoid illegal values Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 14/25] dccp: CVE-2017-8824: use-after-free in DCCP code Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 15/25] btrfs: Fix possible off-by-one in btrfs_search_path_in_tree Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 16/25] 509: fix printing uninitialized stack memory when OID is empty Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 17/25] netfilter: nfnetlink_cthelper: Add missing permission checks Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 18/25] netfilter: xt_osf: " Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 20/25] xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 19/25] spi: sun4i: disable clocks in the remove function Sasha Levin
2018-01-28 22:29 ` [PATCH AUTOSEL for 3.18 21/25] dmaengine: jz4740: disable/unprepare clk if probe fails Sasha Levin
2018-01-28 22:30 ` [PATCH AUTOSEL for 3.18 23/25] x86/mm/kmmio: Fix mmiotrace for page unaligned addresses Sasha Levin
2018-01-28 22:30 ` [PATCH AUTOSEL for 3.18 24/25] xen: XEN_ACPI_PROCESSOR is Dom0-only Sasha Levin
2018-01-28 22:30 ` [PATCH AUTOSEL for 3.18 25/25] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Sasha Levin

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=20180128222931.7781-4-alexander.levin@microsoft.com \
    --to=alexander.levin@microsoft.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wangnan0@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;
as well as URLs for NNTP newsgroup(s).