Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3426853rwi; Wed, 12 Oct 2022 01:37:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bW2sdLkopwRyW+vr2kxf0RBWvF7lBR1ew5UnG0yxQaMDhITG0rZ0kQzhcCflAytEofuAs X-Received: by 2002:a17:90b:38c7:b0:20d:9598:8c26 with SMTP id nn7-20020a17090b38c700b0020d95988c26mr512876pjb.159.1665563873225; Wed, 12 Oct 2022 01:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665563873; cv=none; d=google.com; s=arc-20160816; b=x6JoLlkuvovUWHGNYXsZipd2hrf2/m/lzROQ1QEK+BBe3bE29nKj05LKCc4Tf7PwQC 2HBjY5NJDOfa+R3P444IrXq1kmwm/YVofSLrOzGxaPRjqlhF4tcoK69JCP5mdQX1bCZX HFOa9ALJ3CJMou7D6KBga8X1ubUEHTzYhYhy5xb22mcSto3gDsTcUN0P3R+uZ/LAJzOA l5CQE+iLskhTgBKHhZYz98G6/qSkILF6gwMRvu1/IwALJ69VhrcAzQDEBs9gFM9A1VK4 Ab7oxs8yXFAIDmmXdJ4VjQHn2D89SvPhfn/yYUvG4lkqHhfEmT9mwhvkZZ8eJS4bZ/og tO4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3SHj2Fb76Fovm6HDfGtTx6DbQVGg9mgHqRHBMfoAHK8=; b=ZurfUzhjirXYskgkOKpU+jruaxgPVw2RvfELNbl5yHk8/NVWT71VY3G4RVRDJBEg/5 tOEdyvN8x3P3D+V9ei4kw3ee++GJITUlnFE9TPbGSi76BnB91HlwZk/raWrSuCOZ6xGb /ro/mUZw3/KtXXlqiZaWzVFdOTRBFMrbljKmxAtxVdlbhMXlfCEHYLTTvBZvI/AXmYEh LbRZ4nrmeuyW4Kf97xtbnh7scCEOG/+Jps70/T0KIgWdnRtYntiiomYw+xwZbil9YQqi 5dJHb6NyFbhTaRhCbFGl/ApZd6uLidaqRvNb10JN0AyE5BIqbvlCPp1kKLxDp+tj6+C4 vEVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IbLtQIYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a170902edc500b00179f8a3f838si14862179plk.593.2022.10.12.01.37.42; Wed, 12 Oct 2022 01:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IbLtQIYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbiJLI34 (ORCPT + 99 others); Wed, 12 Oct 2022 04:29:56 -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-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-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = cpumask_next(n - 1, mask); show(n); while (1) { ++n; n = cpumask_next(n - 1, mask); if (n >= 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 --- 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) static void *c_start(struct seq_file *m, loff_t *pos) { + if (*pos >= nr_cpu_ids) + return NULL; + *pos = cpumask_next(*pos - 1, cpu_online_mask); if ((*pos) < nr_cpu_ids) return (void *)(uintptr_t)(1 + *pos); -- 2.37.3