Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5775089ybf; Thu, 5 Mar 2020 06:50:32 -0800 (PST) X-Google-Smtp-Source: ADFU+vtoiKj3+PY5Ab8DEm+xt+EL1AbAofWWwsDda3eKGEeBTfKpyVUzRmL8Uel4wNdXhZrPzf/h X-Received: by 2002:aca:1b09:: with SMTP id b9mr3672187oib.170.1583419832266; Thu, 05 Mar 2020 06:50:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583419832; cv=none; d=google.com; s=arc-20160816; b=sCXxpqrvNjYarZuRW35tj3Eaos/Dya20DaQ4Ai56XUjCtcN2Gwbbm5wejSbUhyzSPk vfl5+aVf2qGNkeFQczGLcT+KZFzj8emm+03T5+8bULS7TFV1TazthE7owez0uOR4a4nO iQ0JSC5mNpwceIn/7SV25xAW19GMDhnX3bhtM+AXH8ErCCzUusU4S1sn1Swac+xkrexp 2BwhaVLNecgE3p1tHgAb9Tif4eLMrwkQylJKFkOM0gacMwlu5Q7RctZecGPER+v2YwpF gLaTsTqHWT0pmbFd02ZS5CxtJ9pp2RWQlCeSnsp9CdLAczGiQBbFEsiURQFAP/jrnk0/ Sh0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=SwhhEvZC8ISuj8BzMi7OAT03/sqD5YiHVmOJxZpeUc0=; b=sALuujZhYy+mZi6xraPYNaCf059Zy6UwlrdIh6S/pA0r41/jT65vIn+KvrqplEQMdr DClNotf+c9Xcu81s7Hc//2vFSXKn4m7RHfPnjU5HMZuxIvLqYU52Q7E5aewYHHGP7jbp v5cRxo4kUGEuNshlluSThQY47pVWIQd4Qy5v0wGt+w91lRPAPFE3xV3/dy3rCd5ycTDY cFGQg3RjqLAcuSexkpxhIbXTrV5CbCBO4xZ6S6Thk/mqUaje82rT2SjCBeJO3mfKUZUY nq211zuVYdSec6HobOMz6mk/iyEK+vFn3A6CfiM1anVKD0Hi/qnuyshpy0CgwCRJ7tcj eFow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kwn7De6D; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si3317355otk.171.2020.03.05.06.50.19; Thu, 05 Mar 2020 06:50:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kwn7De6D; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726351AbgCEOtt (ORCPT + 99 others); Thu, 5 Mar 2020 09:49:49 -0500 Received: from mail-qv1-f68.google.com ([209.85.219.68]:37229 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgCEOts (ORCPT ); Thu, 5 Mar 2020 09:49:48 -0500 Received: by mail-qv1-f68.google.com with SMTP id c19so2524142qvv.4 for ; Thu, 05 Mar 2020 06:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SwhhEvZC8ISuj8BzMi7OAT03/sqD5YiHVmOJxZpeUc0=; b=kwn7De6DXFSmNPiKMSYDdKClyFam7AxPe9nwxhpxbZjEW/7KPvChLZ2gb8UTEjVX2e E1HtsyJP9sAdp4OrkOz+DIsO4ZQlY52ExmpE4hG16oRhJudMT5BxXkE0HoqqqCwy5Hxp ur6q6pFG+CeJXfUzVZsmV48/SSswlljBs1IzcWiTpjFfigtA3dNaLDrTvOahZbbmNcFb KSauIXXfs8e39qicjbYwuj8U5gVrBTNiHDb9rF9D5/TbIV8Aq3zS6W/4VxJbVGRAc2fh A7wVFA/aoIzC84FatA42q9NvM/B5sU/pKubj/J13t5p1Hg9I+Ph52HVgF3DAGRDCvJ2Q qsmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SwhhEvZC8ISuj8BzMi7OAT03/sqD5YiHVmOJxZpeUc0=; b=icEYT9xO0hLW/3/lETFWlaoYlSpXzBD+FtJmAxWi8cEj15RpPM9eRJtNrMHVv7mUdG TiI/hxttv8w+fmuAkT0hJNOEY4a8eK3I85AeUCJMPo10CvDRdqIqivcSBpcFOlQTUw7C uPbmFzJQoC+ClCAXSqP0uErm5a4Bfuzij1QW0YJQJ2x+xC8xcc0QtIpv9rr4a+M0Lg9G pL3g53H4iRgCvm+Pl95PMLJ6KZiBnMzk3phxmwkBgIgIVcrSw4BQ05sn/MchskVSCpES boXobtgC0jo2d/u6bERhpxWEPAzT5qw6Aj4Na2daBSr45t7OQS9sxra1aofM867OKUof M+7g== X-Gm-Message-State: ANhLgQ1aFDHjmjY5G320s/g2GbbgWKqtcdFiaNM7cTvs6TSjU79sg3p+ PMq1jotbsHdo0pbRSM/QgkI= X-Received: by 2002:ad4:47aa:: with SMTP id a10mr6515928qvz.230.1583419787021; Thu, 05 Mar 2020 06:49:47 -0800 (PST) Received: from quaco.ghostprotocols.net ([179.97.37.151]) by smtp.gmail.com with ESMTPSA id s56sm221196qtk.9.2020.03.05.06.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 06:49:46 -0800 (PST) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id EC0DE403AD; Thu, 5 Mar 2020 11:49:43 -0300 (-03) Date: Thu, 5 Mar 2020 11:49:43 -0300 To: Tommi Rantala Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] perf top: Fix stdio interface input handling with glibc 2.28+ Message-ID: <20200305144943.GA7895@kernel.org> References: <20200305083714.9381-1-tommi.t.rantala@nokia.com> <20200305083714.9381-2-tommi.t.rantala@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200305083714.9381-2-tommi.t.rantala@nokia.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Mar 05, 2020 at 10:37:12AM +0200, Tommi Rantala escreveu: > Since glibc 2.28 when running 'perf top --stdio', input handling no > longer works, but hitting any key always just prints the "Mapped keys" > help text. > > To fix it, call clearerr() in the display_thread() loop to clear any EOF > sticky errors, as instructed in the glibc NEWS file > (https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS): > > * All stdio functions now treat end-of-file as a sticky condition. If you > read from a file until EOF, and then the file is enlarged by another > process, you must call clearerr or another function with the same effect > (e.g. fseek, rewind) before you can read the additional data. This > corrects a longstanding C99 conformance bug. It is most likely to affect > programs that use stdio to read interactive input from a terminal. > (Bug #1190.) Thanks for fixing this, I had stumbled on it at some point, but since I mostly use the TUI interface, it fell thru the cracks. Do you prefer it over the TUI one? Thanks, tested and applied. - Arnaldo > Signed-off-by: Tommi Rantala > --- > tools/perf/builtin-top.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c > index f6dd1a63f159e..d2539b793f9d4 100644 > --- a/tools/perf/builtin-top.c > +++ b/tools/perf/builtin-top.c > @@ -684,7 +684,9 @@ static void *display_thread(void *arg) > delay_msecs = top->delay_secs * MSEC_PER_SEC; > set_term_quiet_input(&save); > /* trash return*/ > - getc(stdin); > + clearerr(stdin); > + if (poll(&stdin_poll, 1, 0) > 0) > + getc(stdin); > > while (!done) { > perf_top__print_sym_table(top); > -- > 2.21.1 > -- - Arnaldo