Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3676726rwl; Tue, 27 Dec 2022 13:06:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXs9VkzP4BEthkmxm969ml7L3aBl5hfmAjESlrbo5xjI6r6HRD30Z6VCafj7kvq1ICxdtxk8 X-Received: by 2002:a17:907:7676:b0:7c1:5b5e:4d86 with SMTP id kk22-20020a170907767600b007c15b5e4d86mr19832126ejc.36.1672175219006; Tue, 27 Dec 2022 13:06:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672175218; cv=none; d=google.com; s=arc-20160816; b=ybNOVRfJMXMNZerXieCQ/9fCrPT4GDMdZ0Oo+guXbwG1psD7SiykHUOiEhkr2xRK0z Y5/5QLO+RdytpdMOp01IWeieQGaZAaQ87JlQRJDRMzQJVJl8AE3qPaiZebliFK7DP/xr 4jdXqr6GyUxQAwmIQtZmVmBRczTHkauVhgus7rpkbTmXlzrRpz0o5ldvwtDAX06S2lGF mlk7+CdKia7kwa4odD9xabi7tJZx3ASb+C+eBUGbPKfnmFm0YQZPWqyC6HmpbgXvkTNL HSyLBRxAwsMAOGlm35kdoaVkqhWBZ/eIYTrckZzjO+YO4U2uK3KSDqq8Fc13bPhitiRZ E+Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=FdIOJjfcG6WW8uVaS7i6/8QZr2Zy91jvGegumycTbs0=; b=yBYc4iioNBxp1rIPf2FHuyKJBpCTA9sDoDZCxvJhEyjVtuue3rynfyiLOdipP3eM+0 G7Y0MbL6HtDf2BrkI8hlzgRseBRFTvFh2OJXiBOHDgekLEPvXSQ9FYRC4YiHpexGvMu7 fOv4hhsbneUMuatlEjXgtHt2Y3kjE0JFZcyxEte91rGuP2AaZ3KIm0PGjbvuRrUeOp8/ SDwc8KTAj2PH4m2Uv9XDfoN0iN/eQ4P030lJlF3BjvIsd3CqP7rgObnzbA2SoMmofMO2 Fu+18WlNYpU0ONZ1nTxHPCrSG6FC+UR0bpJEgRAHJG8pjO+g4U5vLz3YtQuV7FSDrZsD K5hw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js4-20020a17090797c400b007c18a102d75si12780072ejc.556.2022.12.27.13.06.43; Tue, 27 Dec 2022 13:06:58 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbiL0UYW convert rfc822-to-8bit (ORCPT + 66 others); Tue, 27 Dec 2022 15:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiL0UYV (ORCPT ); Tue, 27 Dec 2022 15:24:21 -0500 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B7F3F15; Tue, 27 Dec 2022 12:24:20 -0800 (PST) Received: by mail-il1-f179.google.com with SMTP id j28so7239125ila.9; Tue, 27 Dec 2022 12:24:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZYIWCf/X/Ha6fzlOLJLrAZYz4Dy2m9LBU9hsQfnPLuM=; b=TIskR3Jjj8/kBB0knoI1q5fq9KAbhwDP1tnbdfq+QomShd4+FEip6YP0R4rCEpSRh7 KwqPn4M8/wOL9XfPgLt+GVQOwBahuBWmTx93EW9jxI9Z0ZOYFiUmRsM+DxlNsMOblCn5 X2pIJ6BHxZ9l51OwYh23jam45fUKGmd+jQ1xv9gL33toIQW4JkuvybSXT5uodvrvHNRw Ep8hTAWylgQsTYfvzE5EnsLeBrrm/H2z7cgeI7Vl6OmrLlPPMHrxx5c/Lzm2eE/XekxP fltya2cISo+hcxbigFua7eVBV1udbTr/4O76ce9u8W2Z4oxmlcN8izBJrpfZRloQn2kA 6xeQ== X-Gm-Message-State: AFqh2krm+vzAdLhHErFj1XqhjBbfiarZZxB32kp04s+AlwP3V75K/wyq w4rf1/XxYLaAa7CL5qhLXnE72eXEHyVKqur5DX8= X-Received: by 2002:a92:d811:0:b0:303:7c99:eb78 with SMTP id y17-20020a92d811000000b003037c99eb78mr1832673ilm.88.1672172659361; Tue, 27 Dec 2022 12:24:19 -0800 (PST) MIME-Version: 1.0 References: <20221226193517.qynxfceqgzvr4qwu@tarta.nabijaczleweli.xyz> In-Reply-To: <20221226193517.qynxfceqgzvr4qwu@tarta.nabijaczleweli.xyz> From: Namhyung Kim Date: Tue, 27 Dec 2022 12:24:07 -0800 Message-ID: Subject: Re: [PATCH] perf tui: don't ignore job control To: =?UTF-8?Q?Ahelenia_Ziemia=C5=84ska?= Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , yaowenbin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Dec 26, 2022 at 11:35 AM Ahelenia Ziemiańska wrote: > > 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 Cool, this makes Ctrl-Z and then 'fg' work. But it comes with the color for a selected line depending on the timing. Maybe we can reset the color before going to the background? Thanks, Namhyung > --- > 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); > > -- > 2.30.2