Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3438847rwi; Wed, 12 Oct 2022 01:53:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mYHr68SVa140/qTpEAJYJiNeIi2k9f/5CRuXx1rZvTa36fmIxKaFKhoBdmQ64bh0JaTBo X-Received: by 2002:a17:906:db0d:b0:77b:a7cd:8396 with SMTP id xj13-20020a170906db0d00b0077ba7cd8396mr23111378ejb.264.1665564779945; Wed, 12 Oct 2022 01:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665564779; cv=none; d=google.com; s=arc-20160816; b=fdEW5tAx+4zm92G0wDYsycdlOxirTajnNYjtlZsIXdE9fDCADvb6wzp+h2r0jqybcR A1Rplpk5a7i87kye6Zv+cGCi11uQf0IfoeEepdLnpvmZUajxzVzOelzf7HzM1WJsRRjr F0C1kcR8/fQzc3gktBi+Iyu586hhZ/0sZP7Tzz+PjStbK4twk7MvrHGcvQ5ZyF7uIQTX LJf+DyVHddUgEfrm/R9qH5F7lPFmVbyNrTWVsj72XR1xksahh7+WOVnj+6ijrraJh4NU X4E1HqlvUvd1F6mcd25zP+AoU2xMBzPZd7U99DnRD/2mpOWydGQhOWKDQVs3ZmWK/O8q 1VOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=096nZF81b1D12ii7TVdwo0GKEaFqtBX6kHbwyA9xkjs=; b=vrekW2pnpKFGepbpK/bnkm6BJlyMICPxidxwnl4KVJpHar2HE8gTB576sEOqNPeepy 07y/WlJrqiZW0Vd0x1gPCFODVsSsVyFBiE88b852iA6+mNc84AEJaPGKPYuJ2hUeX5yc NkXvxyjYPd7ZHoG8JbStpftE4JchrDrceH7dM6TtA02te1796JT2NpfAdUoZ5lAle42Z 2wR6BmpPUqhK0kWABQaN76h2G34JF2OMwSiJWtDykOwgypoHimItxGVOpoZrBQ/EvmEI cqHJCNnjWISUdWOzYXJRC1oJVsdcEqTFTtvQYbrrCRNiCzFjXMDsYZNKvedfDTAAjV03 J3pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=4e2k4kYl; 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 z6-20020a170906270600b007807e613e5bsi13487053ejc.933.2022.10.12.01.52.32; Wed, 12 Oct 2022 01:52:59 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=4e2k4kYl; 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 S229650AbiJLImr (ORCPT + 99 others); Wed, 12 Oct 2022 04:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbiJLImq (ORCPT ); Wed, 12 Oct 2022 04:42:46 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E213B4886 for ; Wed, 12 Oct 2022 01:42:44 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id u21so23464896edi.9 for ; Wed, 12 Oct 2022 01:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=096nZF81b1D12ii7TVdwo0GKEaFqtBX6kHbwyA9xkjs=; b=4e2k4kYleevBG2qRYo9wW+tbYP81M6M2BYGFNoSgnqZlElezE4tdekCM044rcprUa3 IWffV3ZWpJjNkJKCofHRJOvAsI/b+UJhXJJaTgJ49VRiwIPrEsZnQIUH8OXoj/AAxkZn DLvQdL0O+Le51LJgHqtWz/BQ7cZgQtqvJM3vRZ+J4l+mKGY04j/wiqjMD5CPpZo7pGTR 3romyhuOIHx/z4cDpyFT4IvBYgjsUCg7fcNNb/1QFTSbwF6brgMZA0h4tyFlIF7iWOJs Vm2tijMSrQrOKIicI0/2fBJAgYxappzIWhDKIxiSZ7GxLb82hYPfAHjmmt20o3AGVNGL Z4nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=096nZF81b1D12ii7TVdwo0GKEaFqtBX6kHbwyA9xkjs=; b=Tv+vp8DihQ5HSMmmR8a8ZY8dqJ4n59JjgFaJsiDIR+oqO98TB0di49CoA5jsIO2v6R mnue0AhkN6Np4YDcwiL3+7mpapO3qQByg2ooG7NIKQis3c8s2k/hWQNyfUzKp+IUuYlf c2xDSjY5jdGGPKDeHCj+m4+iWpytfle8BAr21KGcdcDqlfcM1irsOAqJrSPpUmdGpc1C 4Dahp+/zdsxMPQ913WLpJALXS0Q5gYM5q6kibOb2/EHKGX+muvR1EvpI63b+8xX2bYeH IFwyqfX79kmrvGXz5u2+De9Bn/IBQpO0AGR6HGRAMAZFkOlDnJ926hcNOujrRIwsSeE6 I0NQ== X-Gm-Message-State: ACrzQf2EI4qQw2P7Zguw18DY4ZO9NdhCxwRpSAYMga4Boz12rgqeUv51 LHLLKSwqL/RucEEgEV3Cvqdxc4I1bDYgaI4xj8mozw== X-Received: by 2002:a05:6402:169a:b0:458:fe61:d3b4 with SMTP id a26-20020a056402169a00b00458fe61d3b4mr26147347edv.140.1665564162929; Wed, 12 Oct 2022 01:42:42 -0700 (PDT) MIME-Version: 1.0 References: <20221012082949.1801222-1-ajones@ventanamicro.com> In-Reply-To: <20221012082949.1801222-1-ajones@ventanamicro.com> From: Anup Patel Date: Wed, 12 Oct 2022 14:12:30 +0530 Message-ID: Subject: Re: [PATCH v2] RISC-V: Fix /proc/cpuinfo cpumask warning To: Andrew Jones Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Albert Ou , Yury Norov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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 On Wed, Oct 12, 2022 at 1:59 PM Andrew Jones wrote: > > 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 Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > 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 >