From patchwork Fri Oct 14 15:58:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 2752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp258135wrs; Fri, 14 Oct 2022 09:04:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6g7mWx45ET+CUyrbqEc2tlMFYWb2v9wfIkB+7DGpLeXkSArwC4GD1nQ/5pQHG9PV8aLMIQ X-Received: by 2002:a17:907:2c75:b0:78d:c201:e9aa with SMTP id ib21-20020a1709072c7500b0078dc201e9aamr4030208ejc.235.1665763493972; Fri, 14 Oct 2022 09:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665763493; cv=none; d=google.com; s=arc-20160816; b=V99EhYQu5waThl3xxy5O83I0jZMQqZAAvudHToggff/Hiuu7jwD0aFGKJTQsS6j7Wc QvYsgsBgwCOaEW9/zMcY90PfrwMEplLWwMSSVh20AY8tQutA7/SDQmheMtPkKmTsd88+ A3hZBMEH9PR+moeQPOACAoGq6FWHCP8Mw/i6teo7ZGH514P0RiC7V9SHtidzO3iPbkti sfj73yRegNgC95OnTO1aUvfmLDS7DNdPtXvu63qqVQK7wtj5GxesE8xRIYnhPF531Mrw ut7p3POXg2FShTB4OSHGpmxD/rchHpYZljhIfyjDxZyrPLaJ0TIUXvntPasz5IoS+WWC F3aA== 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=uFKG/UoJdjvjZL4a++TyBLwRn5J9ab/1o+9LeC1+Wdk=; b=gyTCPLv4lh8i0bpD9OqtQPLorPSnwGk/3ht9HYNnGfy3gj2Gjdl/KQv+nU1YSWnrbX G1wDoVIVaxvQz3aVu/LlrBhcaAgVtUkBVb7eBtfDNWQcn1Beh547v1d7Tk2ozK+JITa6 ZSmHF/xVewjdmynNChGOw+JBfopDDJYZ10PCV30keM0nKK+nHKRFb/OTZVBBr7wdNtsq f42jU5nL4xAIKXj4MK78tbDx1TOR/qD4aJJP1f78ZwaSD1Zk+K6QuakGVb3cG2cnbcKI 59DMftu5hBTsOnKhkv38uicvnUMcZ3Zi8IlemQ0bPCVEjWcrZly+kxeyWRAMxxsoxPno OjNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=TWAL9EKR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk38-20020a1709077fa600b0078d9be7f100si2843738ejc.852.2022.10.14.09.04.04; Fri, 14 Oct 2022 09:04: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=TWAL9EKR; 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 S230218AbiJNP65 (ORCPT + 99 others); Fri, 14 Oct 2022 11:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbiJNP6v (ORCPT ); Fri, 14 Oct 2022 11:58:51 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CD2115C03 for ; Fri, 14 Oct 2022 08:58:50 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a26so11480721ejc.4 for ; Fri, 14 Oct 2022 08:58:49 -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=uFKG/UoJdjvjZL4a++TyBLwRn5J9ab/1o+9LeC1+Wdk=; b=TWAL9EKRVGNsLjKjhYh/mC6I8/1d/oatjVnsDN9OWuvFem7UzU02ZKqRzzv3m+6WNJ XpbFkMRKHd8kMuyJPFPJ2O4coxdaDl4faAyVqhStpaSUGYq7BHI1TWK1CROOsrCSLceS oCa0J4Fufc1QFYIqSNT7YYCBkHCuQagy+1h8ytDYHkttIN15LC4NsO9AFDHEPqj1jTqO 4aCSqLM2Nu3stjaVcqAwPtMDAHgS/shNxwcrymDs9yg/ism0dyRjPiNJywK3a2Ao/iyX qrOsHJe4Ab8pwfjJp7mLQWu47/wJG/qQKDv8bTBXEBTHUkrCbt724EXqhc5mXve0RXVF Q5Ug== 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=uFKG/UoJdjvjZL4a++TyBLwRn5J9ab/1o+9LeC1+Wdk=; b=LlZcD1edK9QKhfhnQklQDXQKObmlNcjcUJtV4LT9pR2ilQkcws7wsRVxN3+DoO/F9c ilQIG3icMSOPtaFROnCLHxExSsQ/CVL3nRCu7q4PuRtUBPNEV++ABldOI85Qo5s7UDSJ 1W13X+z+qTVF6rXOvQzUJg3DbhYlpehcHvyKb1F6tuvyV0eW035Kr//IOLO9oT2EL3l4 Nxi4EnL/xOEyhhJQwtAgZcwUalVTYdnwDMpFZ3BXKJWTMLC28s4kliDL3zPlbOfwHWLc JDl8W/wlWC2EduTlPu8Ye21ZbPulbZDXqwGz5vvrX/xlei7+HUlGLrFV4Ere1kQAWGhD oFjw== X-Gm-Message-State: ACrzQf0RW6NUeORuVqYvxQkXOjoK0haBDgt2vtsN7HpeMbmvm/HQnMSI 65nsjTNpASiBH0T4KqFbm6/LJA== X-Received: by 2002:a17:906:4783:b0:780:5be5:c81b with SMTP id cw3-20020a170906478300b007805be5c81bmr4152627ejc.76.1665763128360; Fri, 14 Oct 2022 08:58:48 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id z15-20020a170906434f00b007806c1474e1sm1686070ejm.127.2022.10.14.08.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 08:58:48 -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, Anup Patel , Conor Dooley Subject: [PATCH v3 1/2] RISC-V: Fix /proc/cpuinfo cpumask warning Date: Fri, 14 Oct 2022 17:58:44 +0200 Message-Id: <20221014155845.1986223-2-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746679621700747708?= X-GMAIL-MSGID: =?utf-8?q?1746679621700747708?= 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 Reviewed-by: Anup Patel Reviewed-by: Conor Dooley Tested-by: Conor Dooley --- 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 4d0dece5996c..5aa0ae8dd115 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); From patchwork Fri Oct 14 15:58:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 2753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp261510wrs; Fri, 14 Oct 2022 09:10:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uyJFLMjWyHZe1r3jzAaH7U5zQWgwlJCH+bsG9uWx6DoRYwuJYxoxeM+bnnWi2SSxiN1M2 X-Received: by 2002:a17:907:8a27:b0:78e:274e:9235 with SMTP id sc39-20020a1709078a2700b0078e274e9235mr2280709ejc.754.1665763832179; Fri, 14 Oct 2022 09:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665763832; cv=none; d=google.com; s=arc-20160816; b=L+xuS8mIX3x68PLdXc/LjrctJkUHUPIl/9+o3v+l9uzxDanTRe1BhMwggEQFPzxo3B W1WabW+JXY2iVmd5xXVYHGmD3EzB0vCTZRPgrXXt2QxNutmhkD5kG+f/kC2+LSR8HPqL Azv5LK+yKN6zwTBri/IGudIpAdEJx+Jo/2SpaVWjrbbwXBL4crMz1/889eMslqcTUd6D um49InlpcGqTJaQWy8+0ZsEmR+d9OyKs8qSNDOQj890giWxqXdjx0R0YRTuofGPZSheJ MFo0zngnO1Q4ywD9VuksbhHSM7HbCNfAt7OFl5wWynPhOmQ1POdyHk4E4NWhlez/BBc0 n9/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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a056402274200b0045cf3f51a34si3189465edd.24.2022.10.14.09.10.05; Fri, 14 Oct 2022 09:10:32 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746679975796089815?= X-GMAIL-MSGID: =?utf-8?q?1746679975796089815?= 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);