From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946930AbdKRIoa (ORCPT ); Sat, 18 Nov 2017 03:44:30 -0500 Received: from terminus.zytor.com ([65.50.211.136]:37223 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965335AbdKRIoV (ORCPT ); Sat, 18 Nov 2017 03:44:21 -0500 Date: Sat, 18 Nov 2017 00:41:50 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: adrian.hunter@intel.com, tglx@linutronix.de, wangnan0@huawei.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, acme@redhat.com, jolsa@kernel.org, dsahern@gmail.com, andi@firstfloor.org, ravi.bangoria@linux.vnet.ibm.com, mingo@kernel.org, hpa@zytor.com Reply-To: jolsa@kernel.org, andi@firstfloor.org, dsahern@gmail.com, acme@redhat.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, tglx@linutronix.de, adrian.hunter@intel.com, hpa@zytor.com, mingo@kernel.org, ravi.bangoria@linux.vnet.ibm.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf top: Fix window dimensions change handling Git-Commit-ID: b135e5ee1a0e325166c30b16cf5493fea44ede45 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b135e5ee1a0e325166c30b16cf5493fea44ede45 Gitweb: https://git.kernel.org/tip/b135e5ee1a0e325166c30b16cf5493fea44ede45 Author: Jiri Olsa AuthorDate: Tue, 14 Nov 2017 10:23:39 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 17 Nov 2017 12:16:23 -0300 perf top: Fix window dimensions change handling 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 --- 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 8651912..4cbd3dd 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -77,6 +77,7 @@ #include "sane_ctype.h" static volatile int done; +static volatile int resize; #define HEADER_LINE_NR 5 @@ -86,10 +87,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); } @@ -480,7 +484,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); @@ -1035,6 +1039,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;