Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp300443pxb; Wed, 20 Jan 2021 07:21:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrXg5vVDGfZRGeLa3XtoDiqrwAKdst3HqQHT61lYDl3rTDZrMFTvfldoVolPZS/gRo8v6v X-Received: by 2002:a17:906:1348:: with SMTP id x8mr6276487ejb.81.1611156094275; Wed, 20 Jan 2021 07:21:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611156094; cv=none; d=google.com; s=arc-20160816; b=rGehJR3RVpK+O6TocKQK5HIgQrIqGb5Q308IUw2PHRhT+eiek3F+z9C2YUWBas4hQR p7KnF5IICNcCiHguTtZ7r68gySTmFdV4rFGBF7Ooayf11eiqcv4FxTwlew6sIBCevK4f A2tokU7cpaj2kGR+xRQsAmk8gIR+kbJaDDvAAf/QD3Es40GuZiVPiyZuUq3ZxT55VtJh VapZMwP22ajQZ1YJJecm/ytaHrH1zvfvpSh/mLW6Z2kYulVwumUtHx8q0BHC/9SMycaJ ThqvBMf1RNgGJSyX6PqLbXEJejtHi1FiM6BPmtji9bMqA8+BNxyzrumiQ1CwgP2AqoWq 2zNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=08HjlCJ0DaBa2TF2sEWcTFH5eiwSq8HYTO4GCgthTHY=; b=MxIS7LXpYG6M6TySOelrXc6pVNpPVhD0m4OygwdK7G3VpkxSxz6hmQYPtY165CfokK c6MP9gQPBUv/fJUUXlhO5dOHDCaHR0O4Il1erVyEEl79MaxzFN9XQVEjEmhC1wabg/6Q fIhylnxNJs6gAnG/MRPmmIUlzY3t/Q8u1exw2vl+wk7xLcIGCOERZ1EChy3fz1SPPumO KIKQRLtWUDJr8mC5VYf04GUjsRD37gk3/wgxdaQX9UDupOugC8575xbr7k0+mzfgnMmK mMg6g7pBpkbFk+sUWlNFpCqmZzVlgSsoddWiE8gaNR4snd1c/KSiqymXEnLmpd0mH6Me F9Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho11si869200ejc.404.2021.01.20.07.21.05; Wed, 20 Jan 2021 07:21:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390280AbhATPSw (ORCPT + 99 others); Wed, 20 Jan 2021 10:18:52 -0500 Received: from foss.arm.com ([217.140.110.172]:39586 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390940AbhATPSR (ORCPT ); Wed, 20 Jan 2021 10:18:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9A5D431B; Wed, 20 Jan 2021 07:17:30 -0800 (PST) Received: from e120877-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D330C3F68F; Wed, 20 Jan 2021 07:17:29 -0800 (PST) Date: Wed, 20 Jan 2021 15:17:24 +0000 From: Vincent Donnefort To: Peter Zijlstra Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, valentin.schneider@arm.com Subject: Re: [PATCH 2/4] cpu/hotplug: CPUHP_BRINGUP_CPU exception in fail injection Message-ID: <20210120151723.GA284273@e120877-lin.cambridge.arm.com> References: <1610385047-92151-1-git-send-email-vincent.donnefort@arm.com> <1610385047-92151-3-git-send-email-vincent.donnefort@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 01:58:35PM +0100, Peter Zijlstra wrote: > On Mon, Jan 11, 2021 at 05:10:45PM +0000, vincent.donnefort@arm.com wrote: > > From: Vincent Donnefort > > > > The atomic states (between CPUHP_AP_IDLE_DEAD and CPUHP_AP_ONLINE) are > > triggered by the CPUHP_BRINGUP_CPU step. If the latter doesn't run, none > > of the atomic can. Hence, rollback is not possible after a hotunplug > > CPUHP_BRINGUP_CPU step failure and the "fail" interface shouldn't allow > > it. Moreover, the current CPUHP_BRINGUP_CPU teardown callback > > (finish_cpu()) cannot fail anyway. > > > > Signed-off-by: Vincent Donnefort > > --- > > kernel/cpu.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/cpu.c b/kernel/cpu.c > > index 9121edf..bcd7b2a 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -2216,9 +2216,14 @@ static ssize_t write_cpuhp_fail(struct device *dev, > > return -EINVAL; > > > > /* > > - * Cannot fail STARTING/DYING callbacks. > > + * Cannot fail STARTING/DYING callbacks. Also, those callbacks are > > + * triggered by BRINGUP_CPU bringup callback. Therefore, the latter > > + * can't fail during hotunplug, as it would mean we have no way of > > + * rolling back the atomic states that have been previously teared > > + * down. > > */ > > - if (cpuhp_is_atomic_state(fail)) > > + if (cpuhp_is_atomic_state(fail) || > > + (fail == CPUHP_BRINGUP_CPU && st->state > CPUHP_BRINGUP_CPU)) > > return -EINVAL; > > Should we instead disallow failing any state that has .cant_stop ? We would reduce the scope of what can be tested: bringup_cpu() and takedown_cpu() are both marked as "cant_stop". Still, those callbacks are allowed to fail. Checking for cant_stop, made me also see that write_cpuhp_target() is probably missing a check for cpuhp_is_atomic_state(). For the same reason as this patch, when doing cpu_down(), we can't stop in one of these states. -- Vincent