Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3912684imm; Wed, 5 Sep 2018 07:56:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdatxfRaeBOSGH3B7AzXfa6QVZxhrCZJb6Nb5ukb91SdGjXeeJ9dyWQbpExpH5z24zgSbhRg X-Received: by 2002:a62:1544:: with SMTP id 65-v6mr40592967pfv.178.1536159365978; Wed, 05 Sep 2018 07:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536159365; cv=none; d=google.com; s=arc-20160816; b=m9zs9qBrZ2sh6dCljJt8McTkFabF7R4qjQ8yPF6ILnugessPOBzIuDc41eVAlEB/py 5k0jotZ76QIBsobGttFJPbih6Keu2vQPXkigUr0QSdKI3MLZxeI57ZepNd37DCoY+QIK 6PCwR9qo7wUuLqlvcW4XMmKMyqmuR8iKOszyCaz9UcrsxXXu/LCluFozVnmOzB0nN6QR dwE6Sxve/f5bIrN8eOSfj2oxeqXQeiL3gj3i7J+R988xXZUt/9J4CuLkWpno1dhNL8xD tS5BW3ZNkQuFC7QGXcjUjIerByKKl0Gj4t4U+jUbUgQBbl9u6gszqatamVrYEp3bsGtG bJ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=55nf6Aq9R7L2SWl49q0CeodicquGZqhD0c3cqvgYgzk=; b=xnR+fAEPROR1ahZ99lh+6KNEfSs0ru/ilI0iWOznE2vH+KegfP+ZvdC4ll4nVNdqJE M9+ytiSPrcewDqbGtB+QV8tUS0qACD9x3V2uugrDuC1HDZqu4R8OmC3qNgDE6F+9Pd/3 9s3PUqXKziocsUPTCntI7lX6/xBUcg4WuDu+no6UVu3YZd7h7dHUhs5Gda9uRlvRS1dY wgDzBTi1yFqeo7b0KRcKcGHwQit3/4yWaUYMAd1cmc0FZ7OsAEfvrwLqkXdmr9Ixzbwy j4J50Hzg7Yx9uZnnxWzUhr2fEZmh/CZVKhVQAjUaJNOGWRHEU8VzEkRCO8qfw8+5AaRR iVhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x26-v6si2176850pfn.286.2018.09.05.07.55.50; Wed, 05 Sep 2018 07:56:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727707AbeIETYj (ORCPT + 99 others); Wed, 5 Sep 2018 15:24:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59522 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbeIETYi (ORCPT ); Wed, 5 Sep 2018 15:24:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5D2380D; Wed, 5 Sep 2018 07:54:04 -0700 (PDT) Received: from e107155-lin (e107155-lin.Emea.Arm.com [10.4.12.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B89B3F575; Wed, 5 Sep 2018 07:54:02 -0700 (PDT) Date: Wed, 5 Sep 2018 15:53:53 +0100 From: Sudeep Holla To: Thomas Gleixner Cc: Neeraj Upadhyay , josh@joshtriplett.org, peterz@infradead.org, mingo@kernel.org, jiangshanlai@gmail.com, dzickus@redhat.com, brendan.jackman@arm.com, malat@debian.org, linux-kernel@vger.kernel.org, sramana@codeaurora.org, linux-arm-msm@vger.kernel.org, Geert Uytterhoeven , Lorenzo Pieralisi , Sudeep Holla Subject: Re: [PATCH] cpu/hotplug: Fix rollback during error-out in takedown_cpu() Message-ID: <20180905145353.GA14069@e107155-lin> References: <1536042803-6152-1-git-send-email-neeraju@codeaurora.org> 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 05, 2018 at 02:23:46PM +0200, Thomas Gleixner wrote: > On Wed, 5 Sep 2018, Thomas Gleixner wrote: > > On Tue, 4 Sep 2018, Neeraj Upadhyay wrote: > > > ret = cpuhp_down_callbacks(cpu, st, target); > > > if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) { > > > - cpuhp_reset_state(st, prev_state); > > > + /* > > > + * As st->last is not set, cpuhp_reset_state() increments > > > + * st->state, which results in CPUHP_AP_SMPBOOT_THREADS being > > > + * skipped during rollback. So, don't use it here. > > > + */ > > > + st->rollback = true; > > > + st->target = prev_state; > > > + st->bringup = !st->bringup; > > > > No, this is just papering over the actual problem. > > > > The state inconsistency happens in take_cpu_down() when it returns with a > > failure from __cpu_disable() because that returns with state = TEARDOWN_CPU > > and st->state is then incremented in undo_cpu_down(). > > > > That's the real issue and we need to analyze the whole cpu_down rollback > > logic first. > > And looking closer this is a general issue. Just that the TEARDOWN state > makes it simple to observe. It's universaly broken, when the first teardown > callback fails because, st->state is only decremented _AFTER_ the callback > returns success, but undo_cpu_down() increments unconditionally. > > Patch below. This patch fixes the issue reported @[1]. Lorenzo did some debugging and I wanted to have a look at it at some point but this discussion drew my attention and sounded very similar[2]. So I did a quick test with this patch and it fixes the issue. -- Regards, Sudeep [1] https://lore.kernel.org/lkml/CAMuHMdVg868LgL5xTg5Dp5rReKxoo+8fRy+ETJiMxGWZCp+hWw@mail.gmail.com/ [2] https://lore.kernel.org/lkml/20180823131505.GA31558@red-moon/