From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 1DE2E200120 for ; Wed, 8 Jan 2025 17:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736358120; cv=none; b=tz5qBown6AEFhE/PbRT3pKvGklV21hdPySZpp6jcX85KNeK0o30LTDUYyG4HzPa9rVuBc5qWaci7+4qHGUZ2GCta+YvkaH/ujgjBgsOv98Ur6JX/jxhMoFZkJBUrBzZ10VwPta3ub/iQlXW/ILaGJqQcEGYfbmRjuL0b6x/A0A0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736358120; c=relaxed/simple; bh=Mn1QK+aoON3rYu+szlpT1sadCQOrFdOpHCzqjYoAJ8w=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=oWYDRE495PwOLB4ir0aqimqrC77QP7ptb7UDodbXEKRzs4bTeUxc3SO5WzQ0OGJSHLNJWv2CMWY6B5tXhTJjsCyyxxx1dC5g1ZNrRNdlzYoGuxR1m8vcLzAy6ijE7ztosgc1UBupg6lRawTtNy/F+npjNVr8Sd0Bae0aR5UwtfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=x/m+PLsD; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="x/m+PLsD" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso7545815e9.0 for ; Wed, 08 Jan 2025 09:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736358116; x=1736962916; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=pH13aNiEqe4dlmRSRlCD6aVixneaHpo8RLuNm26iewo=; b=x/m+PLsDYJRA4wyWw//2JaePiwzKbrPnHS6XbiOOwqV1W8PahcCMjWOLdD28LS5YZ+ a5NtH3hjHm1xjcYLqky08JlfxW9hhjNNRhDPEnsADyGh2ilQxUoWNo6GrwukFPJv0Kxh ySYwVrDKQtOeQlVBSaNnPvLl7q0KOEYP3VnHnZSmdwc2vM9bL2fUozqmS6PnpF0btNw/ nllu0jfVOgesRXPrynCGebd3jmfVjyof3jLhR06pR11Q+d02zgpYnBEauMc00teGkkQS 9l9bhiU96ZToE2G/BZGxeZw0ry83uqWisjrJ5GCDPSBvJFYsJkhOreh//RH0sATBvuL6 qTqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736358116; x=1736962916; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pH13aNiEqe4dlmRSRlCD6aVixneaHpo8RLuNm26iewo=; b=i6hN66hNsorjYkxKbftQuPJLJ7PDn1Wpv0JVf2F3OpQQ1GhZf+u3MkFA0HEMYh0Qpo SD+jcNTHCQtDUZBllMUeiOFZzGI740aXbxZTewDVEkWTREyAmn2EJb2HsA2McCe8NW8L h3wirbBEpwRyPJBeYY4mccFOA9T387+hKdjI3kNyz6IsXjrTS3VsPneQTNZR0aEZU7SP wCJK15T03KcKKV/E33JdwZt6GsyyJwzQ0AR0NXbsAVaJE2nFBdtAOjrYlLbwno+lx0gQ O6uwbRm8G7nvHOYUEYcntdJHiL32GDnuvxHIBQCUynpUQilyu05Q6x4sfZgyX+ylX3jM wlow== X-Forwarded-Encrypted: i=1; AJvYcCVfoZU7yFv9ijK270IbthU3xhkull9ijU/CSLimfw3+nwczE4WxcxJKj/xnsNL23UqI7BI6kIlgZThPxOM=@vger.kernel.org X-Gm-Message-State: AOJu0YzJgqFWmlZCNLJLEeaXArYR/kM6d2L+t1nuPaQ41H4F/DunPrB1 UBfkl+U4spEOqauB8v6cynOQphQwIxhNtJAF5a4aly3Jz8JyjE/nd9C8IavX9TI= X-Gm-Gg: ASbGnctQNPLieh04iyiunw76/LLwJPzkPv8Nt5l0G1o97vg2ThiqfiFKIDDU7y/VCbU HVR6N1XpyXdlEupqZrrJi/FwCGN+XfhveuFfSq0n0tiYj/pGZHuGjZgKpw/NzKSmSWyIHNolT+S Y3xupEH+vZEXfaTtoaIRUxwkgLfKOE6/wkjf7C7XawMFr7lBFxLgcx8EG7wwmIkC2fi7b+i235B BkP/sqGg03Fzl5BoA60KDDAOZYia+Uhq58Gyr5FUkWSdll7NOLuDjNPS07Ghe8CsXo= X-Google-Smtp-Source: AGHT+IG8LdNpEL4SWf4D1T/ymQ4wSC2LwPNOnCTwT+6z9Fn3Hb+IhKCJi8cNPHjArA2oX1w+GGq62Q== X-Received: by 2002:a05:600c:46c7:b0:436:17a6:32ee with SMTP id 5b1f17b1804b1-436e8843d81mr1673755e9.10.1736358116496; Wed, 08 Jan 2025 09:41:56 -0800 (PST) Received: from [192.168.68.163] ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2de8eb0sm28232275e9.24.2025.01.08.09.41.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jan 2025 09:41:56 -0800 (PST) Message-ID: Date: Wed, 8 Jan 2025 17:41:55 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] perf hist: Fix width calculation in hpp__fmt() From: James Clark To: Dmitry Vyukov Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, namhyung@kernel.org, irogers@google.com References: <20250108065949.235718-1-dvyukov@google.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 08/01/2025 5:26 pm, James Clark wrote: > > > On 08/01/2025 6:59 am, Dmitry Vyukov wrote: >> hpp__width_fn() round up width to length of the field name, >> hpp__fmt() should do it too. Otherwise, the numbers may >> end up unaligned if the field name is long. >> >> Signed-off-by: Dmitry Vyukov >> Cc: Namhyung Kim >> Cc: Ian Rogers >> Cc: linux-perf-users@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> --- >>   tools/perf/ui/hist.c | 2 +- >>   1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c >> index e5491995adf08..34fda1d5eccb4 100644 >> --- a/tools/perf/ui/hist.c >> +++ b/tools/perf/ui/hist.c >> @@ -121,7 +121,7 @@ int hpp__fmt(struct perf_hpp_fmt *fmt, struct >> perf_hpp *hpp, >>            const char *fmtstr, hpp_snprint_fn print_fn, >>            enum perf_hpp_fmt_type fmtype) >>   { >> -    int len = fmt->user_len ?: fmt->len; >> +    int len = max(fmt->user_len ?: fmt->len, (int)strlen(fmt->name)); >>       if (symbol_conf.field_sep) { >>           return __hpp__fmt(hpp, he, get_field, fmtstr, 1, >> >> base-commit: 09a0fa92e5b45e99cf435b2fbf5ebcf889cf8780 > > This seems to right align the field correctly with a long name. Although > it's worth noting I had to add a long name to make it obvious. > > Reviewed-by: James Clark > > I saw some other existing issue with small column-width arguments which > is changed slightly by this patch. But I don't think it's worse: > Ah maybe I was looking at it wrong, before and after are the same with width=3, apart from the intended fix. False alarm. > > $ perf report --fields > overhead,overhead_sys,overhead_us,overhead_guest_us,dso --column- > widths=3,3,3,3,3 > > After: > ------ > Overhead       sys       usr  guest usr long name  Shared Object >   63.78%     0.00%    63.78%                0.00%  ld-linux-x86-64.so > > After, width=3: > -------------- > Overhead       sys       usr  guest usr long name  Sha >   63.78%   0.00%     63.78%                 0.00%  ld- > > Before: > --------------- > Overhead       sys       usr  guest usr long name  Shared Object >   63.78%     0.00%    63.78%      0.00%            ld-linux-x86-64.so > > Before, width=3: > --------------- > Overhead       sys       usr  guest usr long name  Sha >  63.78%    0.00%     63.78%    0.00%               ld-