From nobody Wed Feb 11 10:31:25 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62694C7618D for ; Wed, 15 Mar 2023 14:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbjCOObH (ORCPT ); Wed, 15 Mar 2023 10:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbjCOObC (ORCPT ); Wed, 15 Mar 2023 10:31:02 -0400 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221662A6C7 for ; Wed, 15 Mar 2023 07:30:34 -0700 (PDT) Received: from ramsan.of.borg ([84.195.187.55]) by andre.telenet-ops.be with bizsmtp id YeWY2900R1C8whw01eWYSs; Wed, 15 Mar 2023 15:30:33 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pcS6R-00CI9L-4A; Wed, 15 Mar 2023 15:28:21 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pcS73-00D174-Gj; Wed, 15 Mar 2023 15:28:21 +0100 From: Geert Uytterhoeven To: Andrew Morton Cc: linux-renesas-soc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Tobias Klausmann Subject: [PATCH] lib: dhry: Fix unstable smp_processor_id(_) usage Date: Wed, 15 Mar 2023 15:28:17 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Message-ID: <20230315142817.KygTzqIIRdkvRUrH9E66DLrpXcbIxX-n0AoGRftGyww@z> Content-Type: text/plain; charset="utf-8" When running the in-kernel Dhrystone benchmark with CONFIG_DEBUG_PREEMPT=3Dy: BUG: using smp_processor_id() in preemptible [00000000] code: bash/938 Fix this by not using smp_processor_id() directly, but instead wrapping the whole benchmark inside a get_cpu()/put_cpu() pair. This makes sure the whole benchmark is run on the same CPU core, and the reported values are consistent. Fixes: d5528cc16893f1f6 ("lib: add Dhrystone benchmark test") Reported-by: Tobias Klausmann Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D217179 Signed-off-by: Geert Uytterhoeven --- lib/dhry_run.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dhry_run.c b/lib/dhry_run.c index f9d33efa6d090604..f15ac666e9d38bd2 100644 --- a/lib/dhry_run.c +++ b/lib/dhry_run.c @@ -31,6 +31,7 @@ MODULE_PARM_DESC(iterations, =20 static void dhry_benchmark(void) { + unsigned int cpu =3D get_cpu(); int i, n; =20 if (iterations > 0) { @@ -45,9 +46,10 @@ static void dhry_benchmark(void) } =20 report: + put_cpu(); if (n >=3D 0) - pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", - smp_processor_id(), n, n / DHRY_VAX); + pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", cpu, + n, n / DHRY_VAX); else if (n =3D=3D -EAGAIN) pr_err("Please increase the number of iterations\n"); else --=20 2.34.1