Received: by 10.223.185.116 with SMTP id b49csp1137773wrg; Fri, 23 Feb 2018 12:36:05 -0800 (PST) X-Google-Smtp-Source: AH8x225fX9xJ6nVbmVITb1uIrOo3UkgMERbwTSYPHNwb7qa4MNzYRljWXw/fKa8gsLWNLPjmK4Qd X-Received: by 10.98.32.28 with SMTP id g28mr2952034pfg.182.1519418165716; Fri, 23 Feb 2018 12:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418165; cv=none; d=google.com; s=arc-20160816; b=ycGmmfR05BmwF6Hse4Sj55sdEFsSH9cJS/dzs2Gwg4NRhD+cl+k6Aei6iv5A/YF/yG KcgfSrWf+RFAeCtkagKYoZM4FEpKoMTPQU5t+yLr23kXOXQ0n2+J+ayZmhM6mtG9823G oQ5y3ageDL4UN29483pw+MXLtbCSwhljUXzhwY5M+2vnZhlvSGSIJviTYtrCLaUKWIP0 cMYkw/SWndTus2HaPaFUEdDObADset4YWXS8sezquabwTBkfDwmb0pWvIhlu7faneqIp UeTNuDPxgbXgvZPMqvVLGdvtw6X/6K2iTbf1WUVMzZuBELbiC2hzqJqfXDVic0YCduCR h2uw== 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=zDmFS06FrhE4u9pa9w2Msm4/xe/jiGowtP2Y6pXck3g=; b=DUW0nZB/1ABYGE4byVSUbOwRa87cz3sBZAg5taxzJYIqQOF5yTMW/n87Xym7hkSYVe llPP362WMLKHY5HVI7WJEinYZ6oh9Sn5Xh0f+/kyBQp6B09h5fIWZw7V66WMm9xUUXxZ fxMfdnwlCCIXbtuux9eIvjJPdIO6DfpoMDgv/vbyB8bdbApvH2QX+DtYLjWRtxp7ZO+J fBpEmpS2KrQ/zooqjL/amQHIozUMwil2iJqkq8fjoRWNSgoT8luCBWG8rniFYyDBnvlw 7u+YBh3TqW9yZtiBIdMoH7YqijHsl+k64Ze3/gV+zIE0VQOS5MqVQh4ZZTkM5Uz7mMDk ohbg== 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 x24si1924965pgv.124.2018.02.23.12.35.51; Fri, 23 Feb 2018 12:36:05 -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 S1754018AbeBWUfQ (ORCPT + 99 others); Fri, 23 Feb 2018 15:35:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37130 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753685AbeBWSfA (ORCPT ); Fri, 23 Feb 2018 13:35:00 -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 81B011275; Fri, 23 Feb 2018 18:34:59 +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.4 035/193] perf top: Fix window dimensions change handling Date: Fri, 23 Feb 2018 19:24:28 +0100 Message-Id: <20180223170331.576368507@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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 @@ -70,6 +70,7 @@ #include static volatile int done; +static volatile int resize; #define HEADER_LINE_NR 5 @@ -79,10 +80,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); } @@ -466,7 +470,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); @@ -1023,6 +1027,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;