From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C143C4332F for ; Fri, 14 Oct 2022 15:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uoYmT/uZMcon72OrlTzrrfYiYPSW5g04YI2mD3K6gCE=; b=0JYMWF68C/2dJu 7ShcFk1USQ0dHFhjboeMUFp26RqVumlM1KRxHP4RKBClPCfI57H1WMI4dWrG50H4aw2DWwpdVJNtC p8VYGS0vPT0cB/9HPqtB5OemSbMiLKdEptXrWq/ec/FSyWYqNkEAsHM2+XYrsgtRWbbnSqxQLlaIZ 4hdONT+6e3pmIEIZoTubK/JOFyTYf8kLo2aYM5zYJ2/Uc7Q6Nx7oDXiJdqsl7xesTk2pxJQAqc60G LnhAqq77Y98Fk786djPolxLe1qKFcRaN3V3+zyq1OAqi7s3aDZWTUhKXK+ZT+2fL33NuYDhlRqluU eqwQK5bF7RbWe9HQZN1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojN5K-00FFUE-Vb; Fri, 14 Oct 2022 15:58:54 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojN5H-00FFSh-TW for linux-riscv@lists.infradead.org; Fri, 14 Oct 2022 15:58:53 +0000 Received: by mail-ej1-x631.google.com with SMTP id d26so11422863eje.10 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=Q09lsk0sATbgpxASYgVrgA6P2EMxk+ymYC/Z9+XkOWnWKGG5hxWqABNnyHm1DgL+Nx 3PxVj1yYZG5WnoSz2QgwqLHqHISAENwa6d+Wmwm70yeQ3cy1P8KCQb5Rips4+ZfrUotN gl015vSVy6jO0EjkS8VvE6FiFv9eQlnEPdgWnVaTL83t7Hp3l1YPQ2/UPMofm7ujKceL a66PwmbJ0kWjmyZWPjflfbs1BLQU68vF5S08QRcUeqoi87mhp720epxa/CTeDdlGhFn/ SRi9OApfEqgY+OydV99itetE9OkGAu3nVSewXQLE+aWwrM+VXiMx2yXAhuqi3HyfB9u7 Z5DA== X-Gm-Message-State: ACrzQf3itq2Xg7a5Nv05Ey5O5RHH9BVq1l5JhmkBfSasExqYasjDBOxk steCSzwR5qwsW2nbg/HVA6O5eA== X-Google-Smtp-Source: AMsMyM7/e9vDSoMxdhGGaaPUCS7n6lh8z7ltnxJPYvupdtdDP7MiBbMySEaXciThld3Qry9um9n4rA== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_085851_969008_5DB54840 X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 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); -- 2.37.3 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 4468AC43217 for ; Fri, 14 Oct 2022 15:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbiJNP6y (ORCPT ); Fri, 14 Oct 2022 11:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiJNP6v (ORCPT ); Fri, 14 Oct 2022 11:58:51 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 083FA122757 for ; Fri, 14 Oct 2022 08:58:50 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id 13so11479425ejn.3 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=4Sh5/hC/SSmR8nyEBlL5f5SrmR/q2QN5K/7/Q0uZYcKb/xyvOxx6cJIK7Ll2uRoZ3c tz6cfIQ5TpgK7G8cifACQfXLWlYhW4w0JeEnrKiHX/0DsZYBjC5Lj6LHKMMXizzsuJc9 sY28uDBrQqJab018rA6azP+2mcndse14YPkLW+l1EtSeW9qdNRNXBRRlqIzPAXAC+EDB 0YVZBq8C91aGCo9vs7eqj4+OXMiKd5aiYkLkWEzJ02sNw1bhWYtyJ/sy8Y5EaXRbuMii epjUCqfXlvbWSJxwGfuGN2tOgBXeT8mSVvMe7S49Gm9BrxpQc01MGtISOR476ypKMen8 QP9Q== X-Gm-Message-State: ACrzQf0yxMhZdp4qesRRE7lAxdNNnkE3ep5zjRs9T5g1uVGkaQZhzwUN DEIBaNMmtbLvwlrUaXbLeD1+Fw== X-Google-Smtp-Source: AMsMyM7/e9vDSoMxdhGGaaPUCS7n6lh8z7ltnxJPYvupdtdDP7MiBbMySEaXciThld3Qry9um9n4rA== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@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 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); -- 2.37.3 From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.librecores.org (lists.librecores.org [88.198.125.70]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32E74C4321E for ; Fri, 14 Oct 2022 15:58:51 +0000 (UTC) Received: from [172.31.1.100] (localhost.localdomain [127.0.0.1]) by mail.librecores.org (Postfix) with ESMTP id D55F424B82; Fri, 14 Oct 2022 17:58:50 +0200 (CEST) Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by mail.librecores.org (Postfix) with ESMTPS id 96C3E24B82 for ; Fri, 14 Oct 2022 17:58:48 +0200 (CEST) Received: by mail-ej1-f54.google.com with SMTP id w18so11423344ejq.11 for ; Fri, 14 Oct 2022 08:58:48 -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=Zjjf4WtQDRDjakQ3v39laxVZmc04dyf4JK3fX63E9forpvzQqQVhQosUQrZMQpGjpk jIso7cajDo35S6j+OWg1mbBY0JJFewfsVuEx4fybZL7pQkmICaZup7lU9XNg2s0Tgl9S 1NdFUMT0ruhLhDThCLoOyjLdFi+odHYpGMHZNlHLbYLwBsYEzs7DXFAvZKl0XeR/KRxY CcFq4yXXrrcS6VbGymZWncOdzadS7ZwIjO9xwCqVx5J5yoeA6aGNfxA2n04FdtaTEr0c Czm99iFcC1V1zJ+HH7CMZr7HrbIlBgLO6PabXfg1WNCFe3zRCZifzI7DIxiLKJxYMAGs awsg== X-Gm-Message-State: ACrzQf2gZfEHTKddejiidXdKCsb6gJvWKntY49/ALM2VB3G4GP+3PrtX m+PdepLMGaUZDk6Kfk8BJFwHIQ== X-Google-Smtp-Source: AMsMyM7/e9vDSoMxdhGGaaPUCS7n6lh8z7ltnxJPYvupdtdDP7MiBbMySEaXciThld3Qry9um9n4rA== 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 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 Content-Transfer-Encoding: 8bit X-BeenThere: openrisc@lists.librecores.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion around the OpenRISC processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Bonn , linux-s390@vger.kernel.org, Alexander Gordeev , Albert Ou , Vasily Gorbik , Yury Norov , Michael Ellerman , Heiko Carstens , Dave Hansen , Conor Dooley , Anup Patel , Ingo Molnar , Borislav Petkov , Paul Walmsley , Palmer Dabbelt , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org Errors-To: openrisc-bounces@lists.librecores.org Sender: "OpenRISC" 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); -- 2.37.3 From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA30EC4332F for ; Fri, 14 Oct 2022 16:01:41 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Mprjc32Ddz3dyt for ; Sat, 15 Oct 2022 03:01:40 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=TWAL9EKR; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ventanamicro.com (client-ip=2a00:1450:4864:20::62c; helo=mail-ej1-x62c.google.com; envelope-from=ajones@ventanamicro.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=TWAL9EKR; dkim-atps=neutral Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MprfW4bXjz3c6d for ; Sat, 15 Oct 2022 02:58:57 +1100 (AEDT) Received: by mail-ej1-x62c.google.com with SMTP id b2so11461837eja.6 for ; Fri, 14 Oct 2022 08:58:57 -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=Rq/PFMrczBFhpmRik0Prj1EXzF4QqYwTwDlxTcP4mgmfgvlPeBS/yNCq6wqTEqwbo7 cb4MhBRvKWNwu977x0O8PK4rqIDQXGTCzQTX6JS47YPWYZWIyMkFFpn/ASQA4m9MqD+z zfGBtPWrcUaE/j5SKR5BXDrDRl4W2fdVPBq91q1dvqpwjdPF5lV+6SHdZabM8XIr//3+ SFjfBuZdKgolOwoRX98oah8KOFF5/LUybSuRG1G80aO5EDk9TjDqWeG/8+QJ5aW7eNtr 0uxOoVndll0BOO3VHdXuH7fejaZQa6SE5EGxIvhuUp0W+LJRI/p0LAh6FbFT8wxz4LTp kOXw== X-Gm-Message-State: ACrzQf3XvDrkvrx9XkXONkn+dzj3S/oA7g7cRJpOekyQtRyX/gwCuriz UIHy9q7JyNrCQi7mqL2mjy1cYftL9WrQSQ== X-Google-Smtp-Source: AMsMyM7/e9vDSoMxdhGGaaPUCS7n6lh8z7ltnxJPYvupdtdDP7MiBbMySEaXciThld3Qry9um9n4rA== 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 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 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Bonn , linux-s390@vger.kernel.org, Alexander Gordeev , Albert Ou , Vasily Gorbik , Yury Norov , Heiko Carstens , Dave Hansen , Conor Dooley , Stefan Kristiansson , Anup Patel , Ingo Molnar , Borislav Petkov , Paul Walmsley , Palmer Dabbelt , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, Stafford Horne , openrisc@lists.librecores.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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); -- 2.37.3