Received: by 10.223.185.116 with SMTP id b49csp1096783wrg; Fri, 23 Feb 2018 11:53:08 -0800 (PST) X-Google-Smtp-Source: AH8x225oe8K2NIVYzvD6YkYVuTtKjq/9JG4WGufVaXUy4D5szY0mBcQ6An1FJkI/TCwBuv9E8yGc X-Received: by 10.99.126.14 with SMTP id z14mr2307040pgc.429.1519415588261; Fri, 23 Feb 2018 11:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519415588; cv=none; d=google.com; s=arc-20160816; b=MTZEDaVUu6kzfuGog98XAt3L13TzItUb4JvkotoiDLWcgJsYHAf1G7hCPR2lUrZvbE 363Jdaq9bF7gMxBhi6Icg8osfsxzxn465rMNO0Qv6Ic0qwc3436z0hDQtYcL5iNoqYjZ cxaf7ulWSSAvL/qr82NQ8Dr6VWiV9zGikORqWqw8jyh2d1l93+nsT34vRZraNt8jEkNj uYm8GSJX/VnIrqNnxHrOz9TpjCGmbVwjyyngteiY6+2CUTCxhSfmmmeg/QmKnKz63NFR Pahr/GHRc3gNwASKKjWn1sqjEiYNnb+vbn+44MIBnO1vdVJsaynvlYKb280nUs4gOcD2 6BDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sCJxEbmPWHM8ZyhaZOKvJ9v/PnyMc+HUMnMgu3de3Zg=; b=YfVm6wRwjASW8jgXWgI71jhhcStPcZ6SZbnEUzRcvGA53DYkOUc6KmSo0GdMGngTJc yh1G3e8xvW9gfH7nVr1h6uduCD3vtFW8UpFTAqPlJ5afveiQ2TWx+zF0OQIw0IgYwxH0 IbOyr1ZHgRfJ5gkpGprrShaEXRxCxpW6rAz0XvScb/mxI0wNLH/sk6ZT0oG+B3FgrNGx YQt2h/0uBe5zKC+zl5B9d1dGoIMzH3HE5mraeW204gEQrgYhAmxihMdi09+t5WmKEQCO aR8elxvsfQkLHv0IRqlf4hbZ6bnVWeMWOYzUU5hSCIBEK6IPWAm2IWtE4SwklgKBxtYz Cj/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4-v6si2218268pln.655.2018.02.23.11.52.52; Fri, 23 Feb 2018 11:53:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933960AbeBWSqM (ORCPT + 99 others); Fri, 23 Feb 2018 13:46:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43596 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933653AbeBWSqK (ORCPT ); Fri, 23 Feb 2018 13:46:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 410F812C1; Fri, 23 Feb 2018 18:46:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Olsa , Arnaldo Carvalho de Melo , Ravi Bangoria , Adrian Hunter , Andi Kleen , David Ahern , Namhyung Kim , Wang Nan , Sasha Levin Subject: [PATCH 4.9 050/145] perf top: Fix window dimensions change handling Date: Fri, 23 Feb 2018 19:25:56 +0100 Message-Id: <20180223170731.334942400@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa [ 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 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 Signed-off-by: Greg Kroah-Hartman --- tools/perf/builtin-top.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -73,6 +73,7 @@ #include static volatile int done; +static volatile int resize; #define HEADER_LINE_NR 5 @@ -82,10 +83,13 @@ static void perf_top__update_print_entri } 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); } @@ -472,7 +476,7 @@ static bool perf_top__handle_keypress(st .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); @@ -1003,6 +1007,11 @@ static int __cmd_top(struct perf_top *to if (hits == top->samples) ret = perf_evlist__poll(top->evlist, 100); + + if (resize) { + perf_top__resize(top); + resize = 0; + } } ret = 0;