Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4428886imm; Mon, 14 May 2018 07:27:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpDq52DBzzsERwWy7S2cj/sWa6Bjoq7SEsb9U2sbWLuxtcLtjF/aWCbdm9Nd/7e8W9yzmfp X-Received: by 2002:a17:902:8f93:: with SMTP id z19-v6mr9988150plo.166.1526308066965; Mon, 14 May 2018 07:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526308066; cv=none; d=google.com; s=arc-20160816; b=cMVo5kkdxkC9G3Mwf5Ojhz9QKvrZ/coET3ZwbmuSTzAbtFi3f+h49oSXiPfwjlaotU Gu1UrvTIqkYlI0ys/u8wc7P9joGq4KbYh6dccSxuMnETD566Wd0BHjJheWq+ASZuxiOK Yfa1XH4wHDl8kW8UfHXo5E3R+SplSvfBia4v0xemwdWSY4Df+XjbneaU4UC+mX6pRyFG zti0nJPhn0ntvUByNYvjvEr0b6/1Qo0Dk+RwKF45+BLtxI7VJ29SwR1+VfBgkEJDh5Zg glrLhNSYKp/7ykojj85wKEr+g6zgQ3nioNkc1KCad7sq8FHJfDpNhIdknYL4c9GY+IKz GyvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=vZCCLmMnMBTmnWcvGSOfAYrTK0WnNzMivG2X54fdQXk=; b=ptj+H/uY2Q5htsNcfZmuIEYLu+8ULvGRgPBkOrMhlDILnr40MXDDXgspvI7xeZN2Wq mWwrLIXlbGydhLZhSF6P+1Sq25ktpVIDKuCzb9SGf1lYIzP4+oSXlCA0NfrbuH8h7QGl 9hrf/5cj97YDo4UjJZHDEW7duHB6vYdnlPv1sPkBXnwgu68jnYwLOjvaViy5DB7phFcF TlmZuwG9gbeJYbeSFV9Wuthtw6R4BMDkwWS7Y9R3PSB2XNCWH8sqejESUz+q5B+AC8Jh GT32Ol0SZHprT5ijm54ynN6fbTsfMsThC2m81OOXkt0I8nuyyAh2Jjv5MlezOSPgOMIM yJVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E2vA2ZgE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o189-v6si9623134pfo.20.2018.05.14.07.27.30; Mon, 14 May 2018 07:27:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E2vA2ZgE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753948AbeENOZO (ORCPT + 99 others); Mon, 14 May 2018 10:25:14 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:44331 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753939AbeENOZN (ORCPT ); Mon, 14 May 2018 10:25:13 -0400 Received: by mail-lf0-f68.google.com with SMTP id h197-v6so18295202lfg.11 for ; Mon, 14 May 2018 07:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vZCCLmMnMBTmnWcvGSOfAYrTK0WnNzMivG2X54fdQXk=; b=E2vA2ZgETpRQ5+kDgva1/iDEpbofxeKgLglD/ZeLkWq8LIUV7wpa0JJ3M0iiYAwKjU 0RdHeqK8OKDfZni+mIKwOYxb5XDaypQUsvKmaT3u2AUlvSpK6BTZ86hY05ozk7zJj6eS ID15R1oTBH26a1FgGrH+Epl7WXqC5Xy3iDR45nBc+BNztlX2Kcb/maaWelMrP6CSo37T 8xIj/rvxRxgLmjsykoxNxXo5T2PP/+HMz0zDXnkSD06j5P6omim2Z+zQlZMSFoWOtz6O vgdQHa/dlJXESMxuTMpYnGjWZGTcsqTH6Z1ObU33flDaWJnDa6jOlTPb+f9VDq/9HU9P 92/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=vZCCLmMnMBTmnWcvGSOfAYrTK0WnNzMivG2X54fdQXk=; b=H4+fnhbSV89bhrdPFDQNvVQB0c7GLDnNx0lopF6bBLfq9LeTw3KwCwUZOdP9UCHZhs hvfxZSYj/HtNTHtT+9ixZg6RhYs3LRsRHIkwiIpuE4D27Y2UzLU0kZtb8HKPyGUwC/E+ AeUhm2RCbglqHKEQOokoj0xNB7CnIpo39FAzaY6UmG+svIRbo7lJT//YcjNPJ4bcoRJB Z21Bf7T1P9t51LCsk702jYexoOa/WojukbRHIRvIWDseGbQtFDWxjT6rf7lzHLyd6uFb q9L5zQzaz8AfP444qvH2Gvk9qUwqMIqftNREGWfU3EmjsNdIvwiLKSPHy+eouyAusU8s iDhg== X-Gm-Message-State: ALKqPwd5+t94OMY/mOhKvtlUuOVHBOi88LyKmOJ2tmH+XfPzrjQzZZK5 Pe6vgdamjHQCyQBIAFZq34Al3yQN+wVtVLOdWnA= X-Received: by 2002:a19:180a:: with SMTP id o10-v6mr9336710lfi.18.1526307911500; Mon, 14 May 2018 07:25:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.179.80.147 with HTTP; Mon, 14 May 2018 07:25:10 -0700 (PDT) In-Reply-To: <9f2e445b-15b0-d1fa-832c-f801efc34d03@lge.com> References: <1526027434-21237-1-git-send-email-byungchul.park@lge.com> <3af4cec0-4019-e3ac-77f9-8631252fb6da@lge.com> <20180511161746.GX26088@linux.vnet.ibm.com> <20180511224138.GA89902@joelaf.mtv.corp.google.com> <9f2e445b-15b0-d1fa-832c-f801efc34d03@lge.com> From: Byungchul Park Date: Mon, 14 May 2018 23:25:10 +0900 Message-ID: Subject: Re: [PATCH] rcu: Report a quiescent state when it's exactly in the state To: Byungchul Park Cc: Joel Fernandes , "Paul E. McKenney" , jiangshanlai@gmail.com, josh@joshtriplett.org, rostedt@goodmis.org, Mathieu Desnoyers , linux-kernel@vger.kernel.org, kernel-team@lge.com, Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 11:59 AM, Byungchul Park w= rote: > > > On 2018-05-12 =EC=98=A4=EC=A0=84 7:41, Joel Fernandes wrote: >> >> On Fri, May 11, 2018 at 09:17:46AM -0700, Paul E. McKenney wrote: >>> >>> On Fri, May 11, 2018 at 09:57:54PM +0900, Byungchul Park wrote: >>>> >>>> Hello folks, >>>> >>>> I think I wrote the title in a misleading way. >>>> >>>> Please change the title to something else such as, >>>> "rcu: Report a quiescent state when it's in the state" or, >>>> "rcu: Add points reporting quiescent states where proper" or so on. >>>> >>>> On 2018-05-11 =EC=98=A4=ED=9B=84 5:30, Byungchul Park wrote: >>>>> >>>>> We expect a quiescent state of TASKS_RCU when >>>>> cond_resched_tasks_rcu_qs() >>>>> is called, no matter whether it actually be scheduled or not. However= , >>>>> it currently doesn't report the quiescent state when the task enters >>>>> into __schedule() as it's called with preempt =3D true. So make it re= port >>>>> the quiescent state unconditionally when cond_resched_tasks_rcu_qs() = is >>>>> called. >>>>> >>>>> And in TINY_RCU, even though the quiescent state of rcu_bh also shoul= d >>>>> be reported when the tick interrupt comes from user, it doesn't. So >>>>> make >>>>> it reported. >>>>> >>>>> Lastly in TREE_RCU, rcu_note_voluntary_context_switch() should be >>>>> reported when the tick interrupt comes from not only user but also >>>>> idle, >>>>> as an extended quiescent state. >>>>> >>>>> Signed-off-by: Byungchul Park >>>>> --- >>>>> include/linux/rcupdate.h | 4 ++-- >>>>> kernel/rcu/tiny.c | 6 +++--- >>>>> kernel/rcu/tree.c | 4 ++-- >>>>> 3 files changed, 7 insertions(+), 7 deletions(-) >>>>> >>>>> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h >>>>> index ee8cf5fc..7432261 100644 >>>>> --- a/include/linux/rcupdate.h >>>>> +++ b/include/linux/rcupdate.h >>>>> @@ -195,8 +195,8 @@ static inline void exit_tasks_rcu_finish(void) { = } >>>>> */ >>>>> #define cond_resched_tasks_rcu_qs() \ >>>>> do { \ >>>>> - if (!cond_resched()) \ >>>>> - rcu_note_voluntary_context_switch_lite(current); \ >>>>> + rcu_note_voluntary_context_switch_lite(current); \ >>>>> + cond_resched(); \ >>> >>> >>> Ah, good point. >>> >>> Peter, I have to ask... Why is "cond_resched()" considered a preemptio= n >>> while "schedule()" is not? >> >> >> Infact something interesting I inferred from the __schedule loop related >> to >> your question: >> >> switch_count can either be set to prev->invcsw or prev->nvcsw. If we can >> assume that switch_count reflects whether the context switch is >> involuntary >> or voluntary, >> task-running-state preempt >> switch_count >> 0 (running) 1 involuntary >> 0 0 involuntary >> 1 0 voluntary >> 1 1 involuntary >> >> According to the above table, both the task's running state and the >> preempt >> parameter to __schedule should be used together to determine if the swit= ch >> is >> a voluntary one or not. >> >> So this code in rcu_note_context_switch should really be: >> if (!preempt && !(current->state & TASK_RUNNING)) >> rcu_note_voluntary_context_switch_lite(current); >> >> According to the above table, cond_resched always classifies as an >> involuntary switch which makes sense to me. Even though cond_resched is > > > Hello guys, > > The classification for nivcsw/nvcsw used in scheduler core, Joel, you > showed us is different from that used in when we distinguish between > non preemption/voluntary preemption/preemption/full and so on, even > they use the same word, "voluntary" though. > > The name, rcu_note_voluntary_context_switch_lite() used in RCU has > a lot to do with the latter, the term of preemption. Furthermore, I > think the function should be called even when calling schedule() for > sleep as well. I think it would be better to change the function > name to something else to prevent confusing, it's up to Paul tho. :) Let me explain more what I did earlier. In the scheduler core when classifying nivcsw/nvcsw, they classify the tries as "voluntary", which go to the inactivate state i.e. sleep through a normal path w/o any disturbed e.g. by interrupt preemption. However, in RCU, it's for indicating the places trying to explicitly call scheduler which are quiescent states anyway for TASKS_RCU. Any explicit tries including voluntary preemption points are the cases. That 's why I said they have different meaning from each other. But anyway I also think it would be much better if we can make them consistent by renaming or modifying both scheduler and rcu code. >> explicitly called, its still sort of involuntary in the sense its not >> called >> into the scheduler for sleeping, but rather for seeing if something else >> can >> run instead (a preemption point). Infact none of the task deactivation i= n >> the >> __schedule loop will run if cond_resched is used. >> >> I agree that if schedule was called directly but with TASK_RUNNING=3D1, = then >> that could probably be classified an involuntary switch too... >> >> Also since we're deciding to call rcu_note_voluntary_context_switch_lite >> unconditionally, then IMO this comment on that macro: >> >> /* >> * Note a voluntary context switch for RCU-tasks benefit. This is a >> * macro rather than an inline function to avoid #include hell. >> */ >> #ifdef CONFIG_TASKS_RCU >> #define rcu_note_voluntary_context_switch_lite(t) >> >> Should be changed to: >> >> /* >> * Note a attempt to perform a voluntary context switch for RCU-tasks >> * benefit. This is called even in situations where a context switch >> * didn't really happen even though it was requested. This is a >> * macro rather than an inline function to avoid #include hell. >> */ >> #ifdef CONFIG_TASKS_RCU >> #define rcu_note_voluntary_context_switch_lite(t) >> >> Right? >> >> Correct me if I'm wrong about anything, thanks, >> >> - Joel >> >> > > -- > Thanks, > Byungchul --=20 Thanks, Byungchul