Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp528043lqo; Thu, 16 May 2024 13:15:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5Az3nFJxGoSU6vEVyhkByVG9tOUvBOlSFJ+CXHfyNKD6s/KX5inS13xZHOAP4Jir6jO9dRjR1Rc2GUd+O0PyTkLBt10TiIZWSbpxQRg== X-Google-Smtp-Source: AGHT+IHjM2n8K4NYXQlEeEp8CpUXSy4TCS/so9uQRdX/PJSACYj9455rK+U0cZEQMeopYi2oLzPp X-Received: by 2002:a81:d806:0:b0:607:d285:4d7a with SMTP id 00721157ae682-622affea04dmr179926017b3.52.1715890546280; Thu, 16 May 2024 13:15:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715890546; cv=pass; d=google.com; s=arc-20160816; b=tQiqVQKmJhMBt2C4qrURdYuQS5sOL/6TZ0Cx+YWKuYdwDFYO5rpdaDUPFY6I5rEh97 qraWNvOxyEvMOrtbPI54FlG4unql0whBnkY39h/L3hMemW0gA4VRqoZXN0Vw2tAbyjBY MrTEumApCznHzNM/yeO7toSnd7hzzl9AsGdSCfNo47rCf/LoemoPWEXRDdoUyA7Rde8R Of/Wu7sTahA2cqnP2Pl/7/xYZBp6g8DfkSOcMVn4RlR0cL/tayj9hssLo76CdiKcz5UD EbpwU6weW9il8Nu1Djy2vEF4T11QvD/bFrwyYriF6H8IGAiL9i0rJopCJ/8uClNcVdq8 uXEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=eMwj4gir20V16kzbSN+f5cWTPG9oHd0AnWI9F1gYeHw=; fh=W90R/0+aWXdILGlvfRU5DkHyV4W2zlYmBGT10prD3Nc=; b=N1yfwYwrf5I4wxz4aOxSieKA0vE5ZCsvpHY7Q1XraR96Omh19E+QxYairjpzseR22e RFypDsyd1ZQe/HtSGRl6ToB6qh//N0RcWTN4I9bNr1FGa7SHiKR70nnnHzqf43Rhm+xY g1MhCdK2l23yuw5cU6SOBF5tfepBOGuH7DXZGJdorkJPaN7Hf4WPxxgH124+jtoHTY6V 1iZeo0lGguC0eISFlbW7Ds+MCYAH11xk4q6kD0s+cnnPqcdGuTKTbUnIzvkrSnXfMwOy KX3Ik34ZgVRP22TzVVmEReolEPK0RveUOOJen7RSb29+r0mqsfCqpqVC/CE82Odpa/Sj f3bA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oi7lDsma; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df549ca73si173823611cf.3.2024.05.16.13.15.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 13:15:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oi7lDsma; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E01991C21123 for ; Thu, 16 May 2024 20:15:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4846157A6B; Thu, 16 May 2024 20:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oi7lDsma" Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 487E514D719 for ; Thu, 16 May 2024 20:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715890537; cv=none; b=nUlwtQ6e7Sb9i0pQtfbAd30QIO0l92YLoiatUjfUER0L4CCYI6Pc+ZYOT65MAQXhK7PqsdQhUYt9KAuLHxTlmDaa79eM69sfWQWDH+mddh6T47XT+jNM2NeBnmW3MmpzHYkPZtqmk6h3ja9zimRkLx38z2NPP+108BvZfynXpTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715890537; c=relaxed/simple; bh=Qt7XCwY8p/9Zk/BtJHJFIPCntxonj2BQEpo1pQ9p04w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fmlAxirOwpiyxyHZeLiFtCYxX19kvmJ2eSBRj56iX+pe/okffwRU4bVxjosnZ4v0gs7BmEY9mm7eRy55/ppzCMgNOS+G4wapOr+K/LEhaNVjRF6E68JcphcB+7Zul5tLMZ/Hd+i1AbdoBOH2QkKHmNHPvf27Q3vkRx10lTFkx3w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oi7lDsma; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-43dfe020675so126861cf.0 for ; Thu, 16 May 2024 13:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715890535; x=1716495335; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eMwj4gir20V16kzbSN+f5cWTPG9oHd0AnWI9F1gYeHw=; b=oi7lDsmaG+TvtHANdh6GIWkVzRk641YCN/m9B7XIOZreuL/hp/2lMxUcQyP+LDPNyZ 20XIsPC0kAXMXVSayf9cMZz9rmvdRYe+M6H8LfoC5HzCaDqd1dOsa39VdDdiFHK1wk3E mN4RxonF9lePq/0n8xbHyK1J+PS7ZWcAIvHgwUC1IJ73uEaSTA/XXB7Y/9lwGtun8Qge MmLqZavRTbBJoVg0HsxiK60h/QAErgjXI/ClvnOqnVabfsd5ejDbItGtbirg5i/qzoh9 wb9fkijfld9S6Xm6G9Jz5LWIJwrgm0V8dFcRmvmnrIlq4kty7iKhQxSo2v9+9LXzPB1I iUBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715890535; x=1716495335; 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=eMwj4gir20V16kzbSN+f5cWTPG9oHd0AnWI9F1gYeHw=; b=I8P2t2RZ/2pvvVM3yJ0KerEjtCmTc6qtqKgOxk2AD8eXU88p7umqRzh+b32hW/zxIi dxWhiEi5nbyz2Xm5744mV8fajARCxDFmsM6yB1hAFfu55x7PTmsNoikrYJ4RBJb4wNra SpEfSPZ1pIZCyEiJD+cbdLMGmoW9roBndlDLsLohZydEdRS5JeHMzmfcB10ifO1EI+Lx fnNUKFzxmgGdHKnzzE0Bp8CL7sFAqIr8vQaoCEIfwlyASp0Wnx69YooQZ4CZDscErsCv UvNHaHu3NhwX/jSc8JFG25f1HzJA8ylan+yelk+RtsmbmHCqCKapX75yfXvsTvwKEe4f Gh8A== X-Forwarded-Encrypted: i=1; AJvYcCXLv0QfqF60wdRQUtQZk1tgAS0RrZWLqmhFbW8YdnFnzMUZ6z1RojcgcgGoAN6qOWahxYCg7LqONVtkvQuoGLVYTFpGPvRwzuJd2G2A X-Gm-Message-State: AOJu0Yy2SvPzg0SZwSbKuQ6RFO01SdYVLa4u3HTO5lzrM/660ms0z29l EFbKlNzye97YGGdwoIui4o/c6Clj7FCcLglTDj55/3sVaLys/Hx/jrk++1J9DVQT0pmepBNzpCe 6VNfJwM1pMhcdzr8p9JFBSAX4HxQ5IOVRUaDf X-Received: by 2002:a05:622a:838b:b0:43a:aa3f:917a with SMTP id d75a77b69052e-43e442e044cmr382311cf.27.1715890535057; Thu, 16 May 2024 13:15:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240516131544.2885917-1-leitao@debian.org> In-Reply-To: <20240516131544.2885917-1-leitao@debian.org> From: Ian Rogers Date: Thu, 16 May 2024 13:15:23 -0700 Message-ID: Subject: Re: [PATCH v3] perf list: Fix the --no-desc option To: Breno Leitao Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , leit@meta.com, "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2024 at 6:18=E2=80=AFAM Breno Leitao wr= ote: > > Currently, the --no-desc option in perf list isn't functioning as > intended. > > This issue arises from the overwriting of struct option->desc with the > opposite value of struct option->long_desc. Consequently, whatever > parse_options() returns at struct option->desc gets overridden later, > rendering the --desc or --no-desc arguments ineffective. > > To resolve this, set ->desc as true by default and allow parse_options() > to adjust it accordingly. This adjustment will fix the --no-desc > option while preserving the functionality of the other parameters. > > Signed-off-by: Breno Leitao > --- > Changelog: > > v3: > * Applied the same logic to default_print_metric() and > json_print_event() functions, as identified by Ian Rogers. I don't think we should change the json behavior. We're generating a dictionary and the consumer of the dictionary isn't obligated to read all of it. I tested the non-json output and it all looks good. Thanks, Ian > v2: > * Do not print desc if long_desc is being printed, as identified > by Ian Rogers. > > --- > tools/perf/builtin-list.c | 34 +++++++++++++++------------------- > 1 file changed, 15 insertions(+), 19 deletions(-) > > diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c > index 02bf608d585e..8a0e123587f3 100644 > --- a/tools/perf/builtin-list.c > +++ b/tools/perf/builtin-list.c > @@ -149,7 +149,11 @@ static void default_print_event(void *ps, const char= *pmu_name, const char *topi > } else > fputc('\n', fp); > > - if (desc && print_state->desc) { > + if (long_desc && print_state->long_desc) { > + fprintf(fp, "%*s", 8, "["); > + wordwrap(fp, long_desc, 8, pager_get_columns(), 0); > + fprintf(fp, "]\n"); > + } else if (desc && print_state->desc) { > char *desc_with_unit =3D NULL; > int desc_len =3D -1; > > @@ -165,12 +169,6 @@ static void default_print_event(void *ps, const char= *pmu_name, const char *topi > fprintf(fp, "]\n"); > free(desc_with_unit); > } > - long_desc =3D long_desc ?: desc; > - if (long_desc && print_state->long_desc) { > - fprintf(fp, "%*s", 8, "["); > - wordwrap(fp, long_desc, 8, pager_get_columns(), 0); > - fprintf(fp, "]\n"); > - } > > if (print_state->detailed && encoding_desc) { > fprintf(fp, "%*s", 8, ""); > @@ -243,15 +241,14 @@ static void default_print_metric(void *ps, > } > fprintf(fp, " %s\n", name); > > - if (desc && print_state->desc) { > - fprintf(fp, "%*s", 8, "["); > - wordwrap(fp, desc, 8, pager_get_columns(), 0); > - fprintf(fp, "]\n"); > - } > if (long_desc && print_state->long_desc) { > fprintf(fp, "%*s", 8, "["); > wordwrap(fp, long_desc, 8, pager_get_columns(), 0); > fprintf(fp, "]\n"); > + } else if (desc && print_state->desc) { > + fprintf(fp, "%*s", 8, "["); > + wordwrap(fp, desc, 8, pager_get_columns(), 0); > + fprintf(fp, "]\n"); > } > if (expr && print_state->detailed) { > fprintf(fp, "%*s", 8, "["); > @@ -395,17 +392,16 @@ static void json_print_event(void *ps, const char *= pmu_name, const char *topic, > deprecated ? "1" : "0"); > need_sep =3D true; > } > - if (desc) { > - fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \= "%S\"", > - need_sep ? ",\n" : "", > - desc); > - need_sep =3D true; > - } > if (long_desc) { > fix_escape_fprintf(fp, &buf, "%s\t\"PublicDescription\": = \"%S\"", > need_sep ? ",\n" : "", > long_desc); > need_sep =3D true; > + } else if (desc) { > + fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \= "%S\"", > + need_sep ? ",\n" : "", > + desc); > + need_sep =3D true; > } > if (encoding_desc) { > fix_escape_fprintf(fp, &buf, "%s\t\"Encoding\": \"%S\"", > @@ -491,6 +487,7 @@ int cmd_list(int argc, const char **argv) > int i, ret =3D 0; > struct print_state default_ps =3D { > .fp =3D stdout, > + .desc =3D true, > }; > struct print_state json_ps =3D { > .fp =3D stdout, > @@ -563,7 +560,6 @@ int cmd_list(int argc, const char **argv) > }; > ps =3D &json_ps; > } else { > - default_ps.desc =3D !default_ps.long_desc; > default_ps.last_topic =3D strdup(""); > assert(default_ps.last_topic); > default_ps.visited_metrics =3D strlist__new(NULL, NULL); > -- > 2.43.0 >