Received: by 10.223.185.116 with SMTP id b49csp1073680wrg; Fri, 23 Feb 2018 11:26:23 -0800 (PST) X-Google-Smtp-Source: AH8x225UlBxINWAxIvNP1tCC1Hkw6YUcU4tHFSfCs8mFrSHSGkbkofQli8UZzir5lDBWFVEq9zS/ X-Received: by 10.101.97.139 with SMTP id c11mr2247556pgv.431.1519413983630; Fri, 23 Feb 2018 11:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519413983; cv=none; d=google.com; s=arc-20160816; b=OrSTPoErnORaKjRCujlmjb5tKQRKuuXWeUMZle4VirpPHZjtjqH0xxVVxgl47VFeGd IIICU70jpA2xjN+4egqvyTpJ5qCCEn+HCe03sDMOzFFIbV+LgUyxCBDWzVfDoHYT0tw/ hNdSR79AJ2Wwc2Ktlx8tFHgY1Kvp0GuPgK5M7hUKluVSEoqs8XA4/HapBVp3+8/QP/I6 +CEbtDlNVxGv5CB80L4ReAWZezsqhJzXLRMFhn7tK0n2pNtlndQz0fG9fXWJReEDEfco mMxAPWeKWNZT2LD4mHWBlnKiwFkzuxGC4fB8E9yR17c/QfErVKaCvYMYy5uFnYRwzPx8 oK5g== 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=QIahH20hYtvJTZvPX/KmzsQovkpPJmHO7DqpZrpzswI=; b=YTyE6JbuupFU3K/xxjOBPYzJ7mFwd1JSOu9R/0zSzjoY3jpvfYEfVB1IZId1BAE3AJ ShT6bObmNPRYoGDNwuA7d8WyQUxCuRRDxgPKKL3Og8pP+Qv7L5YSDx4zX64rZ2Q5N/xq 65uCkj2lQYVhAVE821F+VgEAcotgWbaRES5SV0Ort1BWyiZcE4ICNwc4YNA/FKf3vvAM xVQaG4+Ec7P9J5bSRL40x57B8fPwyY5JCxqG3FO+U5Nahfi7yqKH7shB/vukWe99x7tu Eeam4f7c1AdePyJcwFg2jgjqnlhJMIF62srm22m/gGEj46onZJd8skDIYRqac61vJtpv dDgA== 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 r2-v6si2184829pli.625.2018.02.23.11.26.09; Fri, 23 Feb 2018 11:26:23 -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 S1754507AbeBWTZd (ORCPT + 99 others); Fri, 23 Feb 2018 14:25:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47120 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935228AbeBWSwv (ORCPT ); Fri, 23 Feb 2018 13:52:51 -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 D50521005; Fri, 23 Feb 2018 18:52:50 +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.14 073/159] perf top: Fix window dimensions change handling Date: Fri, 23 Feb 2018 19:26:21 +0100 Message-Id: <20180223170752.443474351@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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.14-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 @@ -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_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); } @@ -477,7 +481,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); @@ -1022,6 +1026,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;