Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1488171rdb; Sat, 26 Aug 2023 05:01:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwoUC3Teq48SPwDGJm1p7ElYKiwG/HB1HF79oQJ5Elz8oicJ8w7pGBlW4CHk/cn0NO1/Gb X-Received: by 2002:a05:6a00:2389:b0:686:be77:431c with SMTP id f9-20020a056a00238900b00686be77431cmr21916148pfc.13.1693051305980; Sat, 26 Aug 2023 05:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693051305; cv=none; d=google.com; s=arc-20160816; b=KL1pC4LsjZ79WgACbpoBUF8Q1HAH81y4uxt7xkT1/Q5xcWs1bHuEla0Cz86UbOvl0f FJFRy+AipFtXNqnGH8FVqWyxr6RWilrYH3BxhItj7c0RrElf/4V52cHJmOLOZHLs4lmk efeeV0ywtqyAFuBJIkiml+XtJtsrKumIPS9dJjjiADd3RktN+nLZESe8QRK6wqB2+DUG FYp+Pjw9Zia0yprSknXpTQH/fuZpQS4DbSMDtjR2wEGMv+Erj58CpLg7lRqPt4ryj81x oBktslQa0W7mYtLt+eucbADekTNaIOpBTlvMDfWR148Aw7E/Tu3o7KPUcvoqJRFHwmju /wcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9VAIG5lVeJv5MNHS9OOprXwqyE0YDLy/ELv/L/SYde4=; fh=L9eq19OpWJBETh20BKuvWgUU1M4myKynO9hgRbIFsXU=; b=0dCdX2r6f6jzR6qo9IGGKW4PKoF5GuDReEiZGbSOHfBSJTsf287yt2QOUaVADXhmGk A66uPbyrJKWv+I/UEWISG9o22FRjzqF7Vuy3Vo7tOJRTNpSczW0VH7inxsYrP+QzV8U5 HPsLbz67c5xgJRZYqx11cvOF4DYEW345oVQQj0isI3g6490clPtX6dKEBDlutqEA2e4Y tkmf24gAvVr3qHyBFgxFMIAorToKx4V9uVZQKpIwdNNyqQQ7BRskheCBQNAnk/PNUcRh L1y3NTVFv0dFiCHhp5YGvVBn4+54tIYAkjVQUELE6X6Pnq8asxvhNxNfPY0OcLUtgwtK eQzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kfGEfMYY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br4-20020a056a00440400b00688453b9bbbsi3810858pfb.223.2023.08.26.05.00.33; Sat, 26 Aug 2023 05:01:45 -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=@kernel.org header.s=k20201202 header.b=kfGEfMYY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbjHZBaL (ORCPT + 99 others); Fri, 25 Aug 2023 21:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbjHZBaD (ORCPT ); Fri, 25 Aug 2023 21:30:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA89A1FC3; Fri, 25 Aug 2023 18:30:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7D3AD64C0C; Sat, 26 Aug 2023 01:30:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAFDAC433C8; Sat, 26 Aug 2023 01:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693013399; bh=vGGntP/JUdpGvY/07N+/3z2nUB9BkwpVwyJJTpsdfMg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=kfGEfMYYKcbwI/jG6Ts2ZdQjxP0ZGKpC1ObuNtY/s/+odMnttVxTUOIVZyVnQAvCN ZWl3Qg5HEioZ9sjs2Z5ay74NVMCEdU6mQ5xwPEnD6HzJYMTSH4OmfNVCOXNBC9JZRS tkQtgh1U1/Fuxch1IsVEQab+aVZt/27cR29M2dhJExX6TDVlx5g5B5ODUfq6cE0ldG B0mudmV7MbnV9r2y2GWInggIvO4csOyWHcheSxYx2/EM0xZKZf9O2oIgeqbBcLzSWv hjB2saMxkQhaUE0xxjZx1OnNVR9D3TArIwAuXkkiJUZO9t58ohjGxf5X1W8TLev+wK Ll9d1aEpZ026A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3B4ABCE137E; Fri, 25 Aug 2023 18:29:57 -0700 (PDT) Date: Fri, 25 Aug 2023 18:29:57 -0700 From: "Paul E. McKenney" To: Z qiang Cc: joel@joelfernandes.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: Re: [PATCH] rcutorture: Traverse possible cpu to set maxcpu in rcu_nocb_toggle() Message-ID: <20e7f112-ff70-4ba7-b39f-a0fea499d8d7@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230824084206.22844-1-qiang.zhang1211@gmail.com> <162989fe-5ed8-4d1f-8c99-144e2de532f5@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 On Fri, Aug 25, 2023 at 10:28:37AM +0800, Z qiang wrote: > > > > On Thu, Aug 24, 2023 at 04:42:06PM +0800, Zqiang wrote: > > > Currently, the maxcpu is set by traversing online CPUs, however, if > > > the rcutorture.onoff_holdoff is set zero and onoff_interval is set > > > non-zero, and the some CPUs with larger cpuid has been offline before > > > setting maxcpu, for these CPUs, even if they are online again, also > > > cannot be offload or deoffload. > > > > > > This commit therefore use for_each_possible_cpu() instead of > > > for_each_online_cpu() in rcu_nocb_toggle(). > > > > > > Signed-off-by: Zqiang > > > --- > > > kernel/rcu/rcutorture.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > > > index a58372bdf0c1..b75d0fe558ce 100644 > > > --- a/kernel/rcu/rcutorture.c > > > +++ b/kernel/rcu/rcutorture.c > > > @@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg) > > > VERBOSE_TOROUT_STRING("rcu_nocb_toggle task started"); > > > while (!rcu_inkernel_boot_has_ended()) > > > schedule_timeout_interruptible(HZ / 10); > > > - for_each_online_cpu(cpu) > > > + for_each_possible_cpu(cpu) > > > > Last I checked, bad things could happen if the code attempted to > > nocb_toggle a CPU that had not yet come online. Has that changed? > > For example, there are 8 online CPUs in the system, before we traversing online > CPUs and set maxcpu, CPU7 has been offline, this causes us to miss nocb_toggle > for CPU7(maxcpu=6) > > Even though we still use for_each_online_cpu(), the things described > above also happen. before we toggle the CPU, this CPU has been offline. Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures? Thanx, Paul > Thanks > Zqiang > > > > > > Thanx, Paul > > > > > maxcpu = cpu; > > > WARN_ON(maxcpu < 0); > > > if (toggle_interval > ULONG_MAX) > > > -- > > > 2.17.1 > > >