Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8056007rwb; Wed, 23 Nov 2022 14:55:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zEm6FFD1IvUfzVJU70YNHY46wxQ+mJRwq0QI/+IfV0g20LI4UnpnuDgGgS/hBExcI8G4V X-Received: by 2002:a05:6402:d6a:b0:467:6dbf:e3e8 with SMTP id ec42-20020a0564020d6a00b004676dbfe3e8mr13541011edb.291.1669244127591; Wed, 23 Nov 2022 14:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669244127; cv=none; d=google.com; s=arc-20160816; b=FwNgPsnuOxw6vc/Vpm84EbTDQakS3GosbcX9ez+hQAzdf9t2TBL4jo2Xs0aWIKJ1rV QnmKK/1/GfFWnVPKprJgdPw+PVggaKp1CywyjBbAjFqkouajZ/13gZQ2q5m2r1BBG4Fi hNsMdfgG2OVvnV0rpYlC3Mj5CAXYC+0IAHdPN4ZGoEkAWJEsrPX3DkYWm25ov7oJ1yGz JwG3cBPGMGUIY4epX0+HuQWcsm8Zk0txTc+lSqvhz2+tPyjyiWnkq2rq12uu306mSquS M6DLTgPfAcD1fx3Y8OBrEpQ9RZTdxkQA3oJmzQ11W08taDNdF4lFIPCcwj0awT/Od2zQ OtlA== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=n8NqfA4vwM0xNx2V8zpegLfyXdpX20KrtoHBs6QuFFI=; b=ksKUnFHTIrCbqdP6RniJndfjiZzI/EvFvZF4T0TFGIlqZopbjtxj2SEFezbeUpmKNF JDqYPSsmAsZd1ejXwgNzMXHVVZviuyqPdL7Dl6JndNIphHhV8lpICtwcUCAyDu8RguEr uRPq5Eljli7LA7UO4SHckOkPXUFpRjwR6gNrTShD5ALIij8wOopDOSWAwOvoZcOn9oXQ aTqzTRvCRANwhsOxpBCIT7H88VSiQX27gO7t5tNZsJHkciTXmxB/VoWzoWPXo45cIlN6 rYYRkkfcXSP1N/J8h51EvEzzTzVjhbF61QYDpFcEg+pIQ4Nkb1VH53Z7K5Xbegw6lFH4 dlag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZY/gsWR1"; 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 js15-20020a17090797cf00b007aea0bbe2e2si561293ejc.394.2022.11.23.14.55.06; Wed, 23 Nov 2022 14:55:27 -0800 (PST) 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="ZY/gsWR1"; 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 S229714AbiKWWhK (ORCPT + 88 others); Wed, 23 Nov 2022 17:37:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiKWWhF (ORCPT ); Wed, 23 Nov 2022 17:37:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381A815F28B for ; Wed, 23 Nov 2022 14:37:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C8CA861F62 for ; Wed, 23 Nov 2022 22:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5433C433B5; Wed, 23 Nov 2022 22:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669243021; bh=pFxW3XhSD3d0Xg11g6vFFA+rrYHw+VJrUIpvO4P87Yk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZY/gsWR1+ftH5DmBc5HB7/AUYXKs0bWvfWJvgxns0MX4s3BWaWwpRfSIcHTKcEYmV B0wnZtvhgasQ8QQHSG2F/yEhwaCYy/3vmu/4vnG8nq4qv5T9iXYwi7F1fpEvszTTcf ggzhMUVag7f+38J1um0MBp9jS9hA1pPCgTK/Py9Hhy8u29ScfdMKm2uZyK+oUqtJd+ 8rEbhdATPFXXMo7SgV5s6h3zBAoxoas3rl1taC6vt/YMWQMNG65L1l8Nz4+Xdr8qjM ZZs5fdUge3U1dKHzUFe13npiakAyb0XB4nMjOnuJv8TFbIbPmDC24lB5vTHpfUXuW3 gWhmggu4Bmpxg== Date: Wed, 23 Nov 2022 23:36:58 +0100 From: Frederic Weisbecker To: Zhouyi Zhou Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, dave@stgolabs.net, paulmck@kernel.org, josh@joshtriplett.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH linux-next][RFC]torture: avoid offline tick_do_timer_cpu Message-ID: <20221123223658.GC1395324@lothringen> References: <20221121035140.118651-1-zhouzhouyi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221121035140.118651-1-zhouzhouyi@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Mon, Nov 21, 2022 at 11:51:40AM +0800, Zhouyi Zhou wrote: > During CPU-hotplug torture (CONFIG_NO_HZ_FULL=y), if we try to > offline tick_do_timer_cpu, the operation will fail because in > function tick_nohz_cpu_down: > ``` > if (tick_nohz_full_running && tick_do_timer_cpu == cpu) > return -EBUSY; > ``` > Above bug was first discovered in torture tests performed in PPC VM > of Open Source Lab of Oregon State University, and reproducable in RISC-V > and X86-64 (with additional kernel commandline cpu0_hotplug). > > In this patch, we avoid offline tick_do_timer_cpu by distribute > the offlining cpu among remaining cpus. > > Signed-off-by: Zhouyi Zhou > --- > include/linux/tick.h | 1 + > kernel/time/tick-common.c | 1 + > kernel/time/tick-internal.h | 1 - > kernel/torture.c | 10 ++++++++++ > 4 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/include/linux/tick.h b/include/linux/tick.h > index bfd571f18cfd..23cc0b205853 100644 > --- a/include/linux/tick.h > +++ b/include/linux/tick.h > @@ -14,6 +14,7 @@ > #include > > #ifdef CONFIG_GENERIC_CLOCKEVENTS > +extern int tick_do_timer_cpu __read_mostly; > extern void __init tick_init(void); > /* Should be core only, but ARM BL switcher requires it */ > extern void tick_suspend_local(void); > diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c > index 46789356f856..87b9b9afa320 100644 > --- a/kernel/time/tick-common.c > +++ b/kernel/time/tick-common.c > @@ -48,6 +48,7 @@ ktime_t tick_next_period; > * procedure also covers cpu hotplug. > */ > int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; > +EXPORT_SYMBOL_GPL(tick_do_timer_cpu); Please rather make a function for this. This is an internal value that we don't want to expose to modules. This can be: int tick_nohz_full_timekeeper(void) { if (tick_nohz_full_enabled() && tick_do_timer_cpu >= 0) return tick_do_timer_cpu; else return nr_cpu_ids; } And then just check if the value is below nr_cpu_ids. Thanks.