Received: by 10.192.165.148 with SMTP id m20csp2337026imm; Thu, 26 Apr 2018 09:19:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoeqL2qumm/3q/9yxTsJY3hJMCTkNTbQ//mcNAj6tV9AatYTS/t+0bO408xLMvGmKx9OVdy X-Received: by 2002:a17:902:a718:: with SMTP id w24-v6mr3672559plq.45.1524759583614; Thu, 26 Apr 2018 09:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524759583; cv=none; d=google.com; s=arc-20160816; b=RtCcw2EtAGC6yrJl6Lu8hYwuSXgG5i6tmPqoB+WiPGE+VGdrmssybJpQLJ2vDw0boO iL4ubC12ypF6hc8/ybmb2FVfdUWFeDbkEJXjHbj2bslubTIU7nAwkOH/oZq8FHyuixe9 JLiBmmE/JitXKL9tslwo9btyed50AI4nchRy/0sGuwp3FxnNCfA93fhuIc0y6H2UZDq6 yrBOUaf44GrSeEZYtMI7Zqx6Rn/TkgqAKcf461HVZEc4ak0aUQAiAyVrYAiL7bYdH78T jdsayEf2ZZPmDEk3lY48FlkyJQ3MLTAHUaw4k3A66JV0Kf2Ybtv+nutn3SvGe7dITyk4 8pyw== 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=y6L+tpzoD4MQUwU80uc1/DSCtbZqK4YBdg6upQf5GuY=; b=Pbp1TBzrtbsi1BesEBhNPJ4vumuYaZAGoL++v/uvW6tS+QllS9RMm0dL2Hh6BcEdqI EK+/kpRMj2kVCjmNldGFb9zNY3ERYzeU7gij4iHVk/4u/yxBYVnjTKqEUJFvdazoL0e2 DZaGLMDVj8uPNN80LDbiAFS0pruxmJWKjOwMlm7xA94jGZKDDWOL8kGZZiqjeaRQtZ/D IRveaxXVYVYfIlq4jD0DqXyOt6AUqKO7HeQYr/hZQAP8xxbHjRzraxM/SPxlEDJUZ8L7 2OmwRDvcEqyyQ3XoQDC1gdMbtqFAGnEMTWblzyzq4P11jOia/A+BtVMYyF9DW1SAEh6f /i7g== 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 l6si16334179pgs.531.2018.04.26.09.19.29; Thu, 26 Apr 2018 09:19:43 -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 S1756618AbeDZQSY (ORCPT + 99 others); Thu, 26 Apr 2018 12:18:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47202 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753207AbeDZQSX (ORCPT ); Thu, 26 Apr 2018 12:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC54F818533A; Thu, 26 Apr 2018 16:18:22 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 3BD1F83B6F; Thu, 26 Apr 2018 16:18:21 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 26 Apr 2018 18:18:22 +0200 (CEST) Date: Thu, 26 Apr 2018 18:18:20 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Gaurav Kohli , 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: <20180426161820.GA15391@redhat.com> References: <1524645199-5596-1-git-send-email-gkohli@codeaurora.org> <20180425200917.GZ4082@hirez.programming.kicks-ass.net> <20180426084131.GV4129@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180426084131.GV4129@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 26 Apr 2018 16:18:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 26 Apr 2018 16:18:22 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 On 04/26, Peter Zijlstra wrote: > > For the others, I think we want to do something like the below. I still > need to look at TASK_TRACED, which I suspect is also special, Yes, and TASK_STOPPED. ptrace_freeze_traced() and ptrace_unfreeze_traced() should be fine, but ptrace_stop() wants set_special_state() too, I think. > but ptrace always hurts my brain. mine too ;) > +/* > + * set_special_state() should be used for those states when the blocking task > + * can not use the regular condition based wait-loop. In that case we must > + * serialize against wakeups such that any possible in-flight TASK_RUNNING stores > + * will not collide with out state change. > + */ > +#define set_special_state(state_value) \ > + do { \ > + unsigned long flags; /* may shadow */ \ > + raw_spin_lock_irqsave(¤t->pi_lock, flags); \ > + current->state = (state_value); \ > + raw_spin_unlock_irqrestore(¤t->pi_lock, flags); \ > + } while (0) > + Agreed. I thought that perhaps we can change ttwu_do_wakeup() cmpxchg() instead of plain p->state = TASK_RUNNING, but this helper looks much more clear and simple. Oleg.