From nobody Fri Dec 19 17:28:35 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 35D4229372F for ; Wed, 30 Apr 2025 17:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746035513; cv=none; b=eeDGQ7d5geOt/Xam5429DznD7f9Mq1odp7UL2Qjy5zWooXoAZzU9oW/hvQFxKzFoQjZEeTGA8VAp34655wfFtkkjQFFMBb5RbwNzDI4q7VGMJbtpDn0sj/MGPHUy8+YwC/DFkBa4m0LmrldQuYyRdZRA24CBn4/gh0R+KKnbCTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746035513; c=relaxed/simple; bh=cRmg9Uhy/kSRny4v9VxENzuNJ6XDnUaDzdD6WOoauU4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HWMelS77ap8KkD/CDNpheZN4++fv2WjpakMaWyCGo9DYS74ZWlp7LCihp8n0EWLtlvS8ZtrG8NYC2+WmOR1FQkuPqLzFVfxdlZMN1y1HmHkMeQ64f1FT/iR2sLCj7kGbDiHMT64+sF7qg/dSM9JW341WmQ1B90QMzvPv66gEYjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pl7vcDP8; arc=none smtp.client-ip=209.85.215.201 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=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pl7vcDP8" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b1b2fa98c39so92382a12.2 for ; Wed, 30 Apr 2025 10:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746035512; x=1746640312; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eLABi1cAYEw9fAUdNsHNLvlLHNMrUQ32W3A6QzBe7uI=; b=pl7vcDP8iDP1YhOiVhyQULrqZork/ulbJNyYHiF5avBDiaKGhRo13plo/b98rTi2+/ g6DVCZHGf6/0rzuDG72amp1gM/l4k3Thad8sdrw4pfkNvJo94XqtV1m1GKr3giUzRyNl jxyLazF5LAQoD87gOeE9V68TR282M3BUN+eurO64K3O2zUJOiOl4b+XdM6sV1ZBRyMCB 9m0B2vWTvzZCyx5qaEYXjMmpANk14We3wg0b1CNefN0wBuTgvoponbOhTnr4DTuvMWDY 1NBA+ntw9NrSN7C3P3n4C8lJ78DOeYrzCf1HYsB2CAFmnvCtEACux43pFObG/MMrXfCT ryXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746035512; x=1746640312; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eLABi1cAYEw9fAUdNsHNLvlLHNMrUQ32W3A6QzBe7uI=; b=wLhkx2x8XCHdEbWAZxBc/JaToT/GHPRPTD31UDgGgRJYzPaX+AKVVPeJWgKRFfgni1 42qWnVoZ1/wfgdAS0I2g05Su3oCgVs9vpAXA+CSjEKE2uyooQWc0rCMEEGH+O+BxXFoA /pE0big3LzPI2iB7xTX7TWNbY7sLJ7xCDt+fAJWW+ouprv8HIDSjiCpnU3JqZixcbPQb h6vmZ6n/eVQ3tNsuN/JyvNX9ROWnuEW2TR/xa8+yQwdEt3LIemZM/qo3uiIL2olxjKXS fjCP8tZDU/128i8PvpfmwwAyp03P4tgjoLpm86E+mIYcue9eljZ1wA00kt715tQfjqgb M0wQ== X-Forwarded-Encrypted: i=1; AJvYcCWrCUN9o709gYStTI1fQJoS4oybsryUhwFrEuWbuEebtGixWW5zLUcQBsd87hSbsHpeN2k3JZ/Z67pNevM=@vger.kernel.org X-Gm-Message-State: AOJu0YwLyOscHymKtaexXyqYLN933IdIgnhOftuwiS7QuxbOXDLAmZ8r cAzQsxJbuFgAcYyFDc12nhIJ6ft1mSmgjY0jwkhU6GJfWWUTRatU3YbihGSbtio6XS2judoDjEO Dy3a27Q== X-Google-Smtp-Source: AGHT+IGIUuzSwqqdo5HW7am+AeE4/a6b6jacfSJCk8vxA7uRt24KCIqbt8SNuwNGgHLKwxFchcrFLUe52XI7 X-Received: from pgam20.prod.google.com ([2002:a05:6a02:2b54:b0:b0b:2c1f:b8b3]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6f05:b0:1ee:e33d:f477 with SMTP id adf61e73a8af0-20ba6ff8e7emr145936637.15.1746035511348; Wed, 30 Apr 2025 10:51:51 -0700 (PDT) Date: Wed, 30 Apr 2025 10:50:15 -0700 In-Reply-To: <20250430175036.184610-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250430175036.184610-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.906.g1f30a19c02-goog Message-ID: <20250430175036.184610-28-irogers@google.com> Subject: [PATCH v2 27/47] perf kwork: Silence -Wshorten-64-to-32 warnings From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yury Norov , Rasmus Villemoes , Thomas Gleixner , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Jonathan Cameron , Nathan Chancellor , Bill Wendling , Justin Stitt , Josh Poimboeuf , Al Viro , Kyle Meyer , Ben Gainey , Athira Rajeev , Kajol Jain , Aditya Gupta , Eder Zulian , Dapeng Mi , Kuan-Wei Chiu , He Zhe , Dirk Gouders , Brian Geffon , Ravi Bangoria , Howard Chu , Charlie Jenkins , Colin Ian King , Dominique Martinet , Jann Horn , Masahiro Yamada , Arnd Bergmann , Yang Jihong , Dmitry Vyukov , Andi Kleen , Graham Woodward , Ilkka Koskinen , Anshuman Khandual , Zhongqiu Han , Hao Ge , Tengda Wu , Gabriele Monaco , Chun-Tse Shao , Casey Chen , "Dr. David Alan Gilbert" , Li Huafei , "Steinar H. Gunderson" , Levi Yun , Weilin Wang , Thomas Falcon , Thomas Richter , Andrew Kreimer , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , Christophe Leroy , Jean-Philippe Romain , Junhao He , "Masami Hiramatsu (Google)" , Xu Yang , Steve Clevenger , Zixian Cai , Stephen Brennan , Yujie Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The clang warning -Wshorten-64-to-32 can be useful to catch inadvertent truncation. In some instances this truncation can lead to changing the sign of a result, for example, truncation to return an int to fit a sort routine. Silence the warning by making the implicit truncation explicit. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 11 +++++------ tools/perf/util/bpf_kwork_top.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index c41a68d073de..cc5488cb98e4 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1574,8 +1574,7 @@ static void top_print_per_cpu_load(struct perf_kwork = *kwork) load =3D stat->cpus_runtime[i].load; if (test_bit(i, stat->all_cpus_bitmap) && total) { load_ratio =3D load * 10000 / total; - load_width =3D PRINT_CPU_USAGE_HIST_WIDTH * - load_ratio / 10000; + load_width =3D (int)(PRINT_CPU_USAGE_HIST_WIDTH * load_ratio / 10000); =20 printf("%%Cpu%-*d[%.*s%.*s %*.*f%%]\n", PRINT_CPU_WIDTH, i, @@ -1595,7 +1594,7 @@ static void top_print_cpu_usage(struct perf_kwork *kw= ork) u64 idle_time =3D stat->cpus_runtime[MAX_NR_CPUS].idle; u64 hardirq_time =3D stat->cpus_runtime[MAX_NR_CPUS].irq; u64 softirq_time =3D stat->cpus_runtime[MAX_NR_CPUS].softirq; - int cpus_nr =3D bitmap_weight(stat->all_cpus_bitmap, MAX_NR_CPUS); + int cpus_nr =3D (int)bitmap_weight(stat->all_cpus_bitmap, MAX_NR_CPUS); u64 cpus_total_time =3D stat->cpus_runtime[MAX_NR_CPUS].total; =20 printf("Total : %*.*f ms, %d cpus\n", @@ -1801,7 +1800,7 @@ static int perf_kwork__read_events(struct perf_kwork = *kwork) session =3D perf_session__new(&data, &kwork->tool); if (IS_ERR(session)) { pr_debug("Error creating perf session\n"); - return PTR_ERR(session); + return (int)PTR_ERR(session); } =20 symbol__init(&session->header.env); @@ -2088,8 +2087,8 @@ static void top_calc_cpu_usage(struct perf_kwork *kwo= rk) =20 top_subtract_irq_runtime(kwork, work); =20 - work->cpu_usage =3D work->total_runtime * 10000 / - stat->cpus_runtime[work->cpu].total; + work->cpu_usage =3D (u32)(work->total_runtime * + 10000 / stat->cpus_runtime[work->cpu].total); =20 top_calc_idle_time(kwork, work); next: diff --git a/tools/perf/util/bpf_kwork_top.c b/tools/perf/util/bpf_kwork_to= p.c index b6f187dd9136..808d0c84d26d 100644 --- a/tools/perf/util/bpf_kwork_top.c +++ b/tools/perf/util/bpf_kwork_top.c @@ -219,7 +219,7 @@ static void read_task_info(struct kwork_work *work) int fd; struct task_data data; struct task_key key =3D { - .pid =3D work->id, + .pid =3D (__u32)work->id, .cpu =3D work->cpu, }; =20 --=20 2.49.0.906.g1f30a19c02-goog