From patchwork Mon Dec 26 19:35:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 36699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1079837wrt; Mon, 26 Dec 2022 12:30:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9FIaMcvxGcAnNRWMvI6yOzsJ+6ez/89tV/nFIlo7RfCKOEysiuDxjY8LgEcRvOPnEpVMh X-Received: by 2002:a17:90a:ea0a:b0:219:211f:e2ae with SMTP id w10-20020a17090aea0a00b00219211fe2aemr21271354pjy.49.1672086631084; Mon, 26 Dec 2022 12:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672086631; cv=none; d=google.com; s=arc-20160816; b=xGmjIJjwWkdMdbvYnnScZ8O9UWcwA4Eii6bnRu4s6XgUXnzmrVbJzVW5STR75Rhd7o RRLuDUzyXwbkc1lHSbVAtCKaNXtZGzeOqEomIhVL9REoNwZw/+rMFkQ36cHYvJ7+kGU5 TVzWQz99bzfti4I2pGDyrAXjdyk6pyt91wy8G/mSZmDDnzCq73u4sozR30bJNrYa0tdY BxJoQgOxYzW1UeQDWzCEH3M63sfox2q8clk4TABV83n9gYrCmhtHzURnqiXj6X99eJzT 5+82WrdVhRQaB5Qnai8p/qXXP7Rn8ZclK757NMWN7vuPGe7EtnqspDwRKf7i4m+LTxrY QGdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:content-disposition:mime-version :message-id:subject:cc:from:date:dkim-signature; bh=pUEowHY4n2CDR3N6bDbrQdl6iwl4KklMHhlxTU9RD5w=; b=AMBz9mbip074kci1Tp6N8M0RWqJhQVRqsHIcBMadpDO9FI5vRLsBMHilCqoTBkKt9h jAXWTP+dh9OkqXx0t/YdNlfJBQikKUos/UFtXEYQOH4NciCTJOTg1B6oUfsA+LGoUKKZ x/EkAYx5u2sdqPF08fg5oiWgE41R/QDGO2Ur9ltA4AVLAcNjZvg7fTMKIiuhLzdXkf0x ski78bTyFMhXI9VtqtJGuarFM9LdiD6xzmvTFyRx4ulbEX4j67FrI7oMDqSJ/zR+oBu5 9EkjKIWRF6Hqq5mufnUC8kD6EiqHBozf0l7eimsKZoCCjTG/vKZbS8mOA6pzPyzY7GDp 3bAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202211 header.b=IMq3gPRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a65490d000000b0046fef65f738si12586708pgs.793.2022.12.26.12.30.06; Mon, 26 Dec 2022 12:30:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202211 header.b=IMq3gPRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232117AbiLZTfZ (ORCPT + 99 others); Mon, 26 Dec 2022 14:35:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiLZTfX (ORCPT ); Mon, 26 Dec 2022 14:35:23 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FB6BCF0; Mon, 26 Dec 2022 11:35:22 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id EDB658F8; Mon, 26 Dec 2022 20:35:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1672083319; bh=fw89pnRCbIpQCMHd/3eD8CcHp04GmjjsFw8VwI7QeA0=; h=Date:From:Cc:Subject:From; b=IMq3gPRk6tjzNbhiKOXnmL9YRHmxX1O7Rz/yVpCC8kI1uJ0V0ZwpU/imraPjpFf4z aMCyWShy4gjzp9EWS1H+5Dil9QG3DDujLx6h8fgtI1AFcNt2OmxzCgGChRNcSDHOAC csy2QBKQEbdFfuHedJSLM6SBg02Fiqj6rRL9PzncupmQ4LP7By34lJL4RPx8Fecu2T MeQ5ZFJJu9XOHqcn30b8vyShQ03K4ZQ09Pb0Kx2qrEnPMLijorO7kkwAI7qjrIWpCh hxSr3s6juZKUlb5gWaDUTk2SQc1kkQ11W896vJKZxdIq5+9lC4vO99ffYEgaXGY7v2 k/s526PoO93qg== Date: Mon, 26 Dec 2022 20:35:17 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , yaowenbin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf tui: don't ignore job control Message-ID: <20221226193517.qynxfceqgzvr4qwu@tarta.nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20220429 X-Spam-Status: No, score=2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, FROM_SUSPICIOUS_NTLD_FP,MISSING_HEADERS,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS,T_PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753309911322368615?= X-GMAIL-MSGID: =?utf-8?q?1753309911322368615?= In its infinite wisdom, by default, SLang sets susp undef, and this can only be un-done by calling SLtty_set_suspend_state(true). After every SLang_init_tty(). Additionally, no provisions are made for maintaining the teletype attributes across suspend/continue (outside of curses emulation mode(?!), which provides full support, naturally), so we need to save and restore the flags ourselves. We need to also re-draw the screen, and raising SIGWINCH, shockingly, Just Works. The correct solution would be to Not Use SLang, but as a stop-gap, this makes TUI perf report usable. Signed-off-by: Ahelenia ZiemiaƄska --- tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 2 ++ tools/perf/ui/browsers/scripts.c | 1 + tools/perf/ui/tui/setup.c | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index c03fa76c02ff..6a4ffbf66c7f 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -942,6 +942,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, /* reset abort key so that it can get Ctrl-C as a key */ SLang_reset_tty(); SLang_init_tty(0, 0, 0); + SLtty_set_suspend_state(true); return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts); } diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index b72ee6822222..2479e6d42e7c 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -3010,6 +3010,7 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h /* reset abort key so that it can get Ctrl-C as a key */ SLang_reset_tty(); SLang_init_tty(0, 0, 0); + SLtty_set_suspend_state(true); if (min_pcnt) browser->min_pcnt = min_pcnt; @@ -3682,6 +3683,7 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, /* reset abort key so that it can get Ctrl-C as a key */ SLang_reset_tty(); SLang_init_tty(0, 0, 0); + SLtty_set_suspend_state(true); memset(&action, 0, sizeof(action)); diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 47d2c7a8cbe1..50d45054ed6c 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -166,6 +166,7 @@ void run_script(char *cmd) printf("\033[c\033[H\033[J"); fflush(stdout); SLang_init_tty(0, 0, 0); + SLtty_set_suspend_state(true); SLsmg_refresh(); } diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index a3b8c397c24d..4211a161458a 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #ifdef HAVE_BACKTRACE_SUPPORT @@ -122,6 +123,21 @@ static void ui__signal(int sig) exit(0); } +static void ui__sigcont(int sig) +{ + static struct termios tty; + + if (sig == SIGTSTP) { + while (tcgetattr(SLang_TT_Read_FD, &tty) == -1 && errno == EINTR) + ; + raise(SIGSTOP); + } else { + while (tcsetattr(SLang_TT_Read_FD, TCSADRAIN, &tty) == -1 && errno == EINTR) + ; + raise(SIGWINCH); + } +} + int ui__init(void) { int err; @@ -136,6 +152,7 @@ int ui__init(void) err = SLang_init_tty(-1, 0, 0); if (err < 0) goto out; + SLtty_set_suspend_state(true); err = SLkp_init(); if (err < 0) { @@ -150,6 +167,8 @@ int ui__init(void) signal(SIGINT, ui__signal); signal(SIGQUIT, ui__signal); signal(SIGTERM, ui__signal); + signal(SIGTSTP, ui__sigcont); + signal(SIGCONT, ui__sigcont); perf_error__register(&perf_tui_eops);