Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp895958rwi; Fri, 14 Oct 2022 09:57:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5R1kB0rVO5xOmjsyrxMvwDdoO66AMhd1wzU4WAfMK4IRS6rzGTBTzK8dvr3WA5he3tYFa2 X-Received: by 2002:a17:907:2cd0:b0:78d:d789:e2f8 with SMTP id hg16-20020a1709072cd000b0078dd789e2f8mr4329111ejc.88.1665766646597; Fri, 14 Oct 2022 09:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665766646; cv=none; d=google.com; s=arc-20160816; b=BSBqwLggEjsapu8f2cVgwkZ8CGSov9lR/hD7kVbS2BbD7CXPoZnQ7QxWY1z9QuFY2M lYzjfYXtp5cIs3oHLaGDJBNn9rsVQldBCkutvOeRu0u2w4fVeX3Skq8u5p7PudUPthgf dBdS1UkR4ypDcMES4grk3WLIHjOpRC7resYqFUI6YufzxCmGnt+l/lhObqN4gl8Lp1Q/ Olz++BqobXQKNPp2FNsPi4dwdAxOM/C0ZJokzHl+iwAAVA7SVbYEA64K86PQq7kDngi5 uNqeJkUz4N3YNwsjLJSlk/KNWPf/fqI2vbXb4FGCK/lqAihgxnU7NqiEimEZa81Xh0nM +1+g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XBIOqGjmdzThiZsnnbTdUiYSPQXS/qp/QRUJHndogxY=; b=fgRelulnzcqya5VdVrnKxWkMX9OnliJo3aG5BQKi1QszfgfL6eusWTNCS6HqGccRnV jSltoDzpD33B76fMjXlNDnFCzDfiCjpTg6JMVCladj3ECYOOs7itKdhBRvRvK+L++MeH h75quNknx7Z8Yv2gAyzHi9enQnuOMDhfZQx93sWdV7lbtUa4ynyX429lqToRi0dMElnT yxSD5uD8HnUQ0GRb8G0YAy+4RN6pzuDpRKiPWJ310yOKaRf5C4YMARFnRMDZh4gqO1mn kCwlS0RhigYNFxycrT14S5WS/3csKGEOgpFG2pwJqg4BGQy/+2urkvwo1RmVUYmgbD+1 Pcew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=de2qcklm; 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 dd10-20020a1709069b8a00b0078d90768fcdsi3384966ejc.754.2022.10.14.09.57.00; Fri, 14 Oct 2022 09:57:26 -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=de2qcklm; 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 S230333AbiJNP7D (ORCPT + 99 others); Fri, 14 Oct 2022 11:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbiJNP6x (ORCPT ); Fri, 14 Oct 2022 11:58:53 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A30FB155DB2 for ; Fri, 14 Oct 2022 08:58:51 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id l22so7455003edj.5 for ; Fri, 14 Oct 2022 08:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XBIOqGjmdzThiZsnnbTdUiYSPQXS/qp/QRUJHndogxY=; b=de2qcklml8jKYdhJlyXqmJXoz8FYGzMVRLfN9JcOUqf4UOLuKCrWZr59qwP/CI15i8 9ZEYt9iqHJUORqeLDasCpf2TvKXJ2eNiOMML8Fk+bz7YKFJbV57Ez3yS2OMYxbifi8aU 80V2z5mOPzJ5j+SPiaK/ExtA7pvzSXkVFgQy9BgPDzmgfE18Klp1ebv/IKnNb6TVl3x7 K0gO3P8T9E6LTR2oS1WZnI3pbS2vkD6iCSFlqd/rinFyB9u6Ftb/GsYDL097UX4vn1na X5w9kGup7pabQp9pwZ84Krxhofd+fyywuWkx0d61FPGLmHqmWuc2PbVNpdjodZPMfLJV 6NYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XBIOqGjmdzThiZsnnbTdUiYSPQXS/qp/QRUJHndogxY=; b=JeavNpwsiLzHRwV0PhhxsUWzZ1bIwGkV0HS9+eeBvvFJz65xNH2k2HkgUiW3AiBovD NjFNk7VFgv9hlmHc2h+tmlOGeStYxyxK86fttydyYwQfpQO/AMCf96Ur47YxdcwFse8q iQVZUSb9gfqVrvtp2wwGnBay+9YimzADvXBy7ha++4URS4WZy7trnqyami70gDaJgw7z kw0cBDfOruLtqKwpzeyoNBkfJg7ldKcoWnRWetAfbx28nV/4DdGK/CAmU5wwUTw53hzu x1zqVHFD1qozmHW5ZTG/bzeTzEHIp/F9L5xYiEXCQl+jONwUV66OMzrSOzjGxcdJby5a yleQ== X-Gm-Message-State: ACrzQf04gd8vECZ8P+h2HrA+g6ysJ21ITVRDCakqzcbSEWFgo0U9M/PZ bx+qKF5ckjtkwNZwhY7+/5Ixkw== X-Received: by 2002:a05:6402:3485:b0:45c:d688:6848 with SMTP id v5-20020a056402348500b0045cd6886848mr4672473edc.279.1665763129826; Fri, 14 Oct 2022 08:58:49 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id 12-20020a170906300c00b0077a1dd3e7b7sm1746796ejz.102.2022.10.14.08.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 08:58:49 -0700 (PDT) From: Andrew Jones To: x86@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Yury Norov , Palmer Dabbelt , Paul Walmsley , Albert Ou , Jonas Bonn , Stefan Kristiansson , Stafford Horne , openrisc@lists.librecores.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-s390@vger.kernel.org Subject: [PATCH v3 2/2] x86: Fix /proc/cpuinfo cpumask warning Date: Fri, 14 Oct 2022 17:58:45 +0200 Message-Id: <20221014155845.1986223-3-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014155845.1986223-1-ajones@ventanamicro.com> References: <20221014155845.1986223-1-ajones@ventanamicro.com> 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=unavailable 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 --- arch/x86/kernel/cpu/proc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c index 099b6f0d96bd..de3f93ac6e49 100644 --- a/arch/x86/kernel/cpu/proc.c +++ b/arch/x86/kernel/cpu/proc.c @@ -153,6 +153,9 @@ static int show_cpuinfo(struct seq_file *m, void *v) 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 &cpu_data(*pos); -- 2.37.3