Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1035781imm; Tue, 5 Jun 2018 08:10:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0WE7WFZkScoKBvKbuM5YHXDtVQWGXdrvkLFYZRwVlx58aY8Nae/zudrHGj+5lgCsz7pLN X-Received: by 2002:a65:6290:: with SMTP id f16-v6mr12969015pgv.155.1528211456911; Tue, 05 Jun 2018 08:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528211456; cv=none; d=google.com; s=arc-20160816; b=OiLuZPd0nOicOOBMcQsoTSe9NPfmOJ5mR+5IAK5vhC8y9tKO4T2JTHoPbHiXO/NCf8 bu9qOSDz/24EYtGww2fG4aJmvGWpUFI5jo6HVBUbq2E2zm+WnNDd6UnNhfqPyofobCzl 9lp7BBIk+4oO+i2/87aQMCOTgIYI55CQfv0V0SOxzQ1muaYGb7qr/jwGxhDIf/SN2TGL SLOEt7CfObvYRpkXkD8x5+VXTqg+N8JjOKpaN/6+VpWmGssa301I+8rC3D7FuwlhmG6J sCUy/y+PEYMpNsK2Wd75iM4HePC7fKr+4QJ8TNH9zEuMJcensmi4fmNQKXviD4xomhaE +H6w== 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:arc-authentication-results; bh=pc4rTtC7B/u0P8g8vmTrpTZlNJyJ/6N9Nx7f8SQDO/U=; b=Xs0A6lZIV1pjq+7zD5Er8zruDp5A6kTm2GYxgVAYBIdFi6c9MAJB9JWysURnYBksOH rsv46F6WYGlSuaukCCkl1odv7Je27LCZc8f6Qt4jGXS67Rc20VcT/XnY3X7iiDpSmUIQ arEn2YMS+WQoJI/bqcuDsIw558Yq7zCzSzyw5pJFLPDabYLX93OMW8WNE6VJax498xf7 5C+FEyRgGGsYnliBPe716OmgaQViIYDaamHfNHx21JyxSpkXxr5p9Rvo1RmLS2QUBkEn FAPPxVwuf1mW+TYq0scd7CH9MljNnkOpZDKrKZdMiI7ANTU6BO8lGdIL7BApnNB6nl+U zXBw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si38046859pgc.156.2018.06.05.08.10.42; Tue, 05 Jun 2018 08:10:56 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbeFEPIp (ORCPT + 99 others); Tue, 5 Jun 2018 11:08:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47758 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751508AbeFEPIo (ORCPT ); Tue, 5 Jun 2018 11:08:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0A2840BC060; Tue, 5 Jun 2018 15:08:43 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 1886110EE6C2; Tue, 5 Jun 2018 15:08:41 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 5 Jun 2018 17:08:43 +0200 (CEST) Date: Tue, 5 Jun 2018 17:08:41 +0200 From: Oleg Nesterov To: "Kohli, Gaurav" Cc: Peter Zijlstra , tglx@linutronix.de, mpe@ellerman.id.au, mingo@kernel.org, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Neeraj Upadhyay , Will Deacon Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against wakeup Message-ID: <20180605150841.GA24053@redhat.com> References: <20180501113132.GF12217@hirez.programming.kicks-ass.net> <745d762d-9ab3-0749-9b87-9bb03d913071@codeaurora.org> <20180501131904.GG12217@hirez.programming.kicks-ass.net> <9b289790-9b3a-73bd-7166-bf39f32cefd8@codeaurora.org> <20180502082011.GB12180@hirez.programming.kicks-ass.net> <830d7225-af90-a55a-991a-bb2023d538f1@codeaurora.org> <55221a5b-dd52-3359-f582-86830dd9f205@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) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 05 Jun 2018 15:08:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 05 Jun 2018 15:08:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'oleg@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I have to admit that I didn't try to follow this discussion, somehow I thought that the plan was to use set_special_state(PARKED)... On 06/05, Kohli, Gaurav wrote: > > As last mentioned on mail, we are still seeing issue with the latest > approach and below is the susceptible race as mentioned earlier.. > controller Thread CPUHP Thread > takedown_cpu > kthread_park > kthread_parkme > Set KTHREAD_SHOULD_PARK > smpboot_thread_fn > set Task interruptible > > > wake_up_process > if (!(p->state & state)) > goto out; > > Kthread_parkme > SET TASK_PARKED > schedule > raw_spin_lock(&rq->lock) > ttwu_remote > waiting for __task_rq_lock > context_switch > > finish_lock_switch > > > > Case TASK_PARKED > kthread_park_complete > > > SET Running I think you are right. And, now that I look at 85f1abe0019fcb3ea10df7029056cf42702283a8 ("kthread, sched/wait: Fix kthread_parkme() completion issue") I see this note int the changelog: The alternative is to promote TASK_PARKED to a special state, this guarantees wait_task_inactive() cannot observe a 'stale' TASK_RUNNING and we'll end up doing the right thing, but this preserves the whole icky business of potentially migating the still runnable thing. OK, but __kthread_parkme() can be preempted before it calls schedule(), so the caller still can be migrated? Plus kthread_park_complete() can be called twice. No? Oleg.