From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0108.outbound.protection.outlook.com ([104.47.36.108]:29109 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032496AbeCAPhC (ORCPT ); Thu, 1 Mar 2018 10:37:02 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [added to the 4.1 stable tree] perf top: Fix window dimensions change handling Date: Thu, 1 Mar 2018 15:26:51 +0000 Message-ID: <20180301152116.1486-406-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jiri Olsa This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit b135e5ee1a0e325166c30b16cf5493fea44ede45 ] 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 Tested-by: Arnaldo Carvalho de Melo Tested-by: Ravi Bangoria Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-ysuzwz77oev1ftgvdscn9bpu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- 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 65e138019b99..866b911bcda5 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -69,6 +69,7 @@ #include =20 static volatile int done; +static volatile int resize; =20 #define HEADER_LINE_NR 5 =20 @@ -78,10 +79,13 @@ static void perf_top__update_print_entries(struct perf_= top *top) } =20 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 =3D arg; + resize =3D 1; +} =20 +static void perf_top__resize(struct perf_top *top) +{ get_term_dimensions(&top->winsize); perf_top__update_print_entries(top); } @@ -460,7 +464,7 @@ static bool perf_top__handle_keypress(struct perf_top *= top, int c) .sa_sigaction =3D perf_top__sig_winch, .sa_flags =3D SA_SIGINFO, }; - perf_top__sig_winch(SIGWINCH, NULL, top); + perf_top__resize(top); sigaction(SIGWINCH, &act, NULL); } else { signal(SIGWINCH, SIG_DFL); @@ -998,6 +1002,11 @@ static int __cmd_top(struct perf_top *top) =20 if (hits =3D=3D top->samples) ret =3D perf_evlist__poll(top->evlist, 100); + + if (resize) { + perf_top__resize(top); + resize =3D 0; + } } =20 ret =3D 0; --=20 2.14.1