From nobody Tue Apr 7 04:58:33 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 C26D8C433FE for ; Wed, 12 Oct 2022 08:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbiJLI35 (ORCPT ); Wed, 12 Oct 2022 04:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiJLI3y (ORCPT ); Wed, 12 Oct 2022 04:29:54 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B658113DD5 for ; Wed, 12 Oct 2022 01:29:51 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id bj12so36362475ejb.13 for ; Wed, 12 Oct 2022 01:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3SHj2Fb76Fovm6HDfGtTx6DbQVGg9mgHqRHBMfoAHK8=; b=IbLtQIYb/GAt2wP/f+c78c9HTErL9EwM4EZGcTZukvPE16gaweDJFacFzRdudVgV4H fc8B5CtXe5kjG3EA+kJIvnbRqZfgsb9wWwBpcCExqfB8ZuT6bgoqEVxaeU/peINRlzZv vjzrw3hRNtAXPoQ39x2A2WI4Bu2VErzvU/dCPFip+PKW7wLQ7YmkPGkkXvJbgt1K0A39 BBW6zxsiZiTPubkKfEX6Lh+5stpKSZiB6Kb5TusQ9n1p/aM5uGQBQ+SAZV9CmQsP2gMr TE68STD4d3kXPOFzw0oFUAwfDUG4kim8c/1FSWlj4/dZIvMWmpi0FgOnQ+xerZGqK82V 5W8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3SHj2Fb76Fovm6HDfGtTx6DbQVGg9mgHqRHBMfoAHK8=; b=h92CzuOPwG9ENRFjOI3LUOaeT/M/EX0dKD8BzpoKmngPa4WMYlF2MLm+UvqND0pBJt f+PjJW0YkDzMksZbgHH8jpG0WBOK8CbHC14CzsrRXQ9gWtVwrV8p1Ggy4eC+EnwERM/4 DlronOzEeBzw+Hl3vbqmBspoLb08TMisfQeZtdzcb9OAdW8PYvOFanACX4Uac3ixC4KK 2SyyKFfivYsFRatiZCgySc9eoHI0uOpjUSsiGt8Vd8uuKuals7xZQMc1SHFIBR7v/vUV K/Eu6UPgl/nMiQY1OQhckzhU7aqbSetV1ONHDVCuhiDEZH1AnFy4qqhHmYJoQVLFeKHf kL/Q== X-Gm-Message-State: ACrzQf0hmUq4AiKE0Uahykw7v0NU9XfAp2DRCuVpGuTkgvkyW10aSEsW 11wLovofN1DjYTzj1FT551a/8g== X-Google-Smtp-Source: AMsMyM5EykqRulQ3gG5bEmbILwZWtKL7NT+e20G3tO34y/FV2IhTVNnY0/akQSMPZgHQjnj/m3MS/Q== X-Received: by 2002:a17:906:5d11:b0:78d:a41c:6a2d with SMTP id g17-20020a1709065d1100b0078da41c6a2dmr13192661ejt.215.1665563390318; Wed, 12 Oct 2022 01:29:50 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id l27-20020a056402345b00b00457160c3c77sm10663429edc.20.2022.10.12.01.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 01:29:50 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Yury Norov Subject: [PATCH v2] RISC-V: Fix /proc/cpuinfo cpumask warning Date: Wed, 12 Oct 2022 10:29:49 +0200 Message-Id: <20221012082949.1801222-1-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit 78e5a3399421 ("cpumask: fix checking valid cpu range") has started issuing warnings[*] when cpu indices equal to nr_cpu_ids - 1 are passed to cpumask_next* functions. seq_read_iter() and cpuinfo's start and next seq operations implement a pattern like n =3D cpumask_next(n - 1, mask); show(n); while (1) { ++n; n =3D cpumask_next(n - 1, mask); if (n >=3D nr_cpu_ids) break; show(n); } which will issue the warning when reading /proc/cpuinfo. Ensure no warning is generated by validating the cpu index before calling cpumask_next(). [*] Warnings will only appear with DEBUG_PER_CPU_MAPS enabled. Signed-off-by: Andrew Jones Cc: Yury Norov Reviewed-by: Anup Patel Reviewed-by: Conor Dooley Tested-by: Conor Dooley --- v2: - Got comments on the x86 equivalent patch and made the same changes to this one - Added all the information I should have in the first place to the commit message [Boris] - Changed style of fix [Boris] arch/riscv/kernel/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 4aa8cd749441..63138b880b92 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -166,6 +166,9 @@ static void print_mmu(struct seq_file *f) =20 static void *c_start(struct seq_file *m, loff_t *pos) { + if (*pos >=3D nr_cpu_ids) + return NULL; + *pos =3D cpumask_next(*pos - 1, cpu_online_mask); if ((*pos) < nr_cpu_ids) return (void *)(uintptr_t)(1 + *pos); --=20 2.37.3