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 063E6C004D4 for ; Thu, 19 Jan 2023 20:26:51 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=923jpwDO+M5EWLhu7aQY31h+NDY5dSdgDt8lOjlok3M=; b=tNKGOFn4TQkOyn Bcruwe0x8a/bDVRY8yp2u0ZKypISAGMH1oZ4JHo/GklSi1JKOwytP6ELiJwwgmwmNKJvQBc/a4jqS 88VBlggN729ze4oL2vTKjMmw0Td9QDjduL6Nx1duUPvmobZt1OLRNDZgeXaweSjqikTEIxDbcBHPP 6hUFJraXRMn3oJfWXbi3jziJERlaFxNQoQMpWhB9geeXDYb7s1QB454xufhZQ4Ot5pSZAILCGxgek MfmhfDwSry9ZH8oKJLGq2R9l1AR8DL3hLkeF8JPxKOwAa88vjlGFsIuPtvRWAA0h1lW8lpvD3fMtj Qq4fgWY8d5kh7XT7B1tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIbTX-0079m1-Ps; Thu, 19 Jan 2023 20:25:31 +0000 Received: from mail-vs1-xe2c.google.com ([2607:f8b0:4864:20::e2c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIbTU-0079lC-Fl for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2023 20:25:30 +0000 Received: by mail-vs1-xe2c.google.com with SMTP id j185so3428379vsc.13 for ; Thu, 19 Jan 2023 12:25:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NNYsCT1OulNJOJ23TkVFfni9pow2SSxPZF4KOP4SuHc=; b=Vh+4tf70mqLqRxgxLcL9G2bXR4AwzNoYgWBS4WtTwgk83nwuC3Sbm58VFOk6qjj+jL deMZS/paX8VGjOhvNrxPKNKXyGVcPl2qjy+ho/sCacVuebffz36FUt1V/vkflciCskzH MxUVsb45C+pJZt5NhS4R741PCearHMlgnWFhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NNYsCT1OulNJOJ23TkVFfni9pow2SSxPZF4KOP4SuHc=; b=azU8jxIu4lBo0BKoxykUUD4CqYoJMhrwqqTncE3DgrVTcrxUJPATDFMY5mjcrFcF78 8lY1CGSp2tTNLarb5y5yjHpT7c+0DafFJzmmTTNbVHN1LBZ96xN1KHcD/Utw5dVSGRBc Kh4bWb1Ov2Gp7cUjPPEoMlTNHiazRd3aRLhwIjJO3yTCzrYxPxTeC/Rx+M/stxEAQNh7 P6hhrUkgYI3p9DsElFMSzrvLQ87gsuSkxQulgI3V63xvRl+zTj6KJDKpKtCmDNtPTVVS lDpBlAqrdfjdk4AlxnZaXEEAJK3n+j+CmmiC1V4s6MDRR+kRJOquDaqdZma2VcawqB+a GFIQ== X-Gm-Message-State: AFqh2krM0zRs6GjUX1NswkducWe0rd0uDcdcAoasOz6StAHcFuecBmLf 10upFfSq7wJrn+ZAhOEg/HNcTAns6cuBy0VC X-Google-Smtp-Source: AMrXdXtr9N5wNQPQDy+kNHCBAbxYeHE4XPqxGJ5eXHbBqy4Oul6EB1txRGoKJ5f9PUNq5DXGL94VGg== X-Received: by 2002:a05:6102:7d1:b0:3d4:540:785a with SMTP id y17-20020a05610207d100b003d40540785amr7845982vsg.19.1674159923661; Thu, 19 Jan 2023 12:25:23 -0800 (PST) Received: from localhost (129.239.188.35.bc.googleusercontent.com. [35.188.239.129]) by smtp.gmail.com with ESMTPSA id bj30-20020a05620a191e00b006bb82221013sm24544620qkb.0.2023.01.19.12.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 12:25:22 -0800 (PST) Date: Thu, 19 Jan 2023 20:25:22 +0000 From: Joel Fernandes To: Frederic Weisbecker Cc: "Paul E. McKenney" , Zhouyi Zhou , "moderated list:ARM/STM32 ARCHITECTURE" , Will Deacon , Marc Zyngier , Mark Rutland , Catalin Marinas , rcu Subject: Re: arm64 torture test hotplug failures (offlining causes -EBUSY) Message-ID: References: <20230117043011.GD2948950@paulmck-ThinkPad-P17-Gen-1> <24953EEA-5B3E-4046-B106-7A7FBE8B8995@joelfernandes.org> <20230117045456.GG2948950@paulmck-ThinkPad-P17-Gen-1> <20230117204231.GP2948950@paulmck-ThinkPad-P17-Gen-1> <20230118040058.GV2948950@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230119_122528_574104_A3811583 X-CRM114-Status: GOOD ( 30.21 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jan 19, 2023 at 02:57:59PM +0100, Frederic Weisbecker wrote: > On Wed, Jan 18, 2023 at 10:37:08PM +0000, Joel Fernandes wrote: > > > > That's a great idea. I found a way to do that without having to do the > > EXPORT_SYMBOL (like in Zhouyi's patch). > > > > Would the following be acceptable (only build-tested)? > > > > I can run more tests and submit a patch: > > > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > > index 55405ebf23ab..f73bc520b70e 100644 > > --- a/drivers/base/cpu.c > > +++ b/drivers/base/cpu.c > > @@ -487,7 +487,8 @@ static const struct attribute_group *cpu_root_attr_groups[] = { > > bool cpu_is_hotpluggable(unsigned int cpu) > > { > > struct device *dev = get_cpu_device(cpu); > > - return dev && container_of(dev, struct cpu, dev)->hotpluggable; > > + return dev && container_of(dev, struct cpu, dev)->hotpluggable > > + && !tick_nohz_cpu_hotpluggable(cpu); > > } > > EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); > > > > diff --git a/include/linux/tick.h b/include/linux/tick.h > > index bfd571f18cfd..9459fef5b857 100644 > > --- a/include/linux/tick.h > > +++ b/include/linux/tick.h > > @@ -216,6 +216,7 @@ extern void tick_nohz_dep_set_signal(struct task_struct *tsk, > > enum tick_dep_bits bit); > > extern void tick_nohz_dep_clear_signal(struct signal_struct *signal, > > enum tick_dep_bits bit); > > +extern bool tick_nohz_cpu_hotpluggable(unsigned int cpu); > > > > /* > > * The below are tick_nohz_[set,clear]_dep() wrappers that optimize off-cases > > @@ -280,6 +281,7 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { } > > > > static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { } > > static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { } > > +static inline bool tick_nohz_cpu_hotpluggable(unsigned int cpu) { return true; } > > > > static inline void tick_dep_set(enum tick_dep_bits bit) { } > > static inline void tick_dep_clear(enum tick_dep_bits bit) { } > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > > index 9c6f661fb436..d1cc7525240e 100644 > > --- a/kernel/time/tick-sched.c > > +++ b/kernel/time/tick-sched.c > > @@ -522,6 +522,11 @@ static int tick_nohz_cpu_down(unsigned int cpu) > > return 0; > > } > > > > +bool tick_nohz_cpu_hotpluggable(unsigned int cpu) > > +{ > > + return tick_nohz_cpu_down(cpu) == 0; > > +} > > + > > Can you make it the opposite? Have tick_nohz_cpu_down() call > tick_nohz_cpu_hotpluggable()? To avoid future accidents. > > Thanks. You mean move the logic of tick_nohz_cpu_down() into tick_nohz_cpu_hotpluggable()? That wont work because tick_nohz_cpu_hotpluggable() returns a boolean, while tick_nohz_cpu_down(cpu) returns an integer. I could do something like the following and that should prevent the accident you mentioned, which I think is that someone accidentally adds some code with side-effects to tick_nohz_cpu_down() and ends up changing the behavior of tick_nohz_cpu_hotpluggable(). Or was there a different accident you were referring to? I will submit a patch like the following, then. Thanks. ---8<----------------------- diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4c98849577d4..7af8e33735a3 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -487,7 +487,8 @@ static const struct attribute_group *cpu_root_attr_groups[] = { bool cpu_is_hotpluggable(unsigned int cpu) { struct device *dev = get_cpu_device(cpu); - return dev && container_of(dev, struct cpu, dev)->hotpluggable; + return dev && container_of(dev, struct cpu, dev)->hotpluggable + && tick_nohz_cpu_hotpluggable(cpu); } EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); diff --git a/include/linux/tick.h b/include/linux/tick.h index bfd571f18cfd..9459fef5b857 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -216,6 +216,7 @@ extern void tick_nohz_dep_set_signal(struct task_struct *tsk, enum tick_dep_bits bit); extern void tick_nohz_dep_clear_signal(struct signal_struct *signal, enum tick_dep_bits bit); +extern bool tick_nohz_cpu_hotpluggable(unsigned int cpu); /* * The below are tick_nohz_[set,clear]_dep() wrappers that optimize off-cases @@ -280,6 +281,7 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { } static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { } static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { } +static inline bool tick_nohz_cpu_hotpluggable(unsigned int cpu) { return true; } static inline void tick_dep_set(enum tick_dep_bits bit) { } static inline void tick_dep_clear(enum tick_dep_bits bit) { } diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index ba2ac1469d47..6a2e52d5f0d0 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -532,7 +532,7 @@ void __init tick_nohz_full_setup(cpumask_var_t cpumask) tick_nohz_full_running = true; } -static int tick_nohz_cpu_down(unsigned int cpu) +static int tick_nohz_cpu_hotplug_ret(unsigned int cpu) { /* * The tick_do_timer_cpu CPU handles housekeeping duty (unbound @@ -544,6 +544,16 @@ static int tick_nohz_cpu_down(unsigned int cpu) return 0; } +static int tick_nohz_cpu_down(unsigned int cpu) +{ + return tick_nohz_cpu_hotplug_ret(cpu); +} + +bool tick_nohz_cpu_hotpluggable(unsigned int cpu) +{ + return tick_nohz_cpu_hotplug_ret(cpu) == 0; +} + void __init tick_nohz_init(void) { int cpu, ret; -- 2.39.0.246.g2a6d74b583-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel