Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1383013imm; Fri, 11 May 2018 15:42:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFs+vINmC1HBydewbjhmqlKyehM+T/ackVowvSjpuIDvQSs1A5OJp3eaaYFxnoPu3kOegu X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr7208483plu.22.1526078541205; Fri, 11 May 2018 15:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526078541; cv=none; d=google.com; s=arc-20160816; b=PTMP8gP1mjW/IgMg3fwk03Kp7rX0x4nIyer3I/OjdLWTXbptk/dnJHNMG0NkhG5Le7 NqYtQMv3t0bhmnN/zH2YyDXH7lFBK+DGyKg7urTDZUVDE8pkuSxxyBck3vcVBm3IvfSQ SXaq0pE6JktAw6P3p0HqOXSbuxLx+71uR2q4YRbwBx5oPndKniNbPDH6dvbdDYyx/8Xr 7eOwb3g7ojkQtR2nd0PVJQQ+sMBxXBwYYe2MyFDLy0szRFh5oyZiScEPjjBzxr4hsObh /fl+77MDCop+H1RWkAnzg4sFuS6Za4gbqt3gxq5kTI3FwnFvKHmAKUHe7paA9lPY0+0A BhQA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=L8scTZ/DHE7M/5n2c7vtq2I++HVE7q4Khs+Qdh0xQO8=; b=QxFcAPuVGeKVUviRJ9FB87TxwV4gToiK1UQwKS128oFCK6ZLFz3JyYL1kcuvkZ8KDw Zd4Pcx/HYgKW1ebqpnUZKFkv88wpNYWpjLBYEXx9vmVYSsZhF0Z60ltMF+71vqcsfr1/ RO653vAJTue7k/RCYbPIrnAI6tN0nF6LnuRFMH/4UR3V/UTbJk7SpUJcTwNc3Chq1wuS NgB4LvG8BbrP0wPBkQ2gRLAdjiCIQpvc79BCrwF8Vg7zHgtX9gLGsi45erpgcXEn9t+5 LL+CHDCHb6JbI/uXzA334euW0RKimTthvLOPgv2eshVk1ww0T2/jh/IiLyrvVrIdeTXP IWKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=BGK97zju; 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 x14-v6si4207592pll.24.2018.05.11.15.41.51; Fri, 11 May 2018 15:42:21 -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=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=BGK97zju; 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 S1751457AbeEKWll (ORCPT + 99 others); Fri, 11 May 2018 18:41:41 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:38585 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbeEKWlk (ORCPT ); Fri, 11 May 2018 18:41:40 -0400 Received: by mail-pl0-f67.google.com with SMTP id c11-v6so4037045plr.5 for ; Fri, 11 May 2018 15:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=L8scTZ/DHE7M/5n2c7vtq2I++HVE7q4Khs+Qdh0xQO8=; b=BGK97zjujPPUXeRXIJbDRQ+O4fLeSt9PG//9930GO0loZ8uba3Plfq6Fx/+eH8k9jV 9NdX6HpZfeZ7yDCE0a3OHzMkfFiqTTdNKo8IxzIeTRal0giR+EHEEsS5iX7K6OsmWbxM MdamHomdyLNF3sm/VKGhRHS81oVnjsgTAVQI04qaJFFr5qBy9tTP4dwhRJqPZzhDKItU M2bw5ZT/I092dcZUwJfuOG9DBaxC1BMTJ9X9M4mHYEPjy7i3VhqbCcCoRpR6S6B8wRcp FXQaE1jLNUqphFBASleZ5cbQfdFKbW3ggCsVlGQNtIrWl4xR1s23zkO7v0Yz+J3bGQF1 YOWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=L8scTZ/DHE7M/5n2c7vtq2I++HVE7q4Khs+Qdh0xQO8=; b=XbM6JGQE0+Bwpb7+vzyqz5wfMtSIFJKAOiOKyitOPQChslXPYDc/QuzHwlz+I1QOrd Zff+7hSWDnMFIwRkXOSYexS1HjkCVgs3o01ayrowzdj004028S7ufuV9DAwUTqeJ0fc3 4OehaD66N9LVeTxC5tmtORwBLncO4a+aJxMj5bY/7kh5YPWvrAeGCCZAbdnQqj+RnKEz mybPHGqsAonVeHPm/IVzjaZ0IWnI4ezeh/rRdZAg/nn2Hybscja2whRVm39LVQSCA1dM NgDpZaNXTo1y9SW/wszwpe94O5NtizFT+CdxjyWqb9rK8a36EXmqXcqE/0HGoKU1fqzK wiFg== X-Gm-Message-State: ALKqPwdjWZ0j4yd8kAaeKYkG+AGAUOHj5A4GfH+mYrYxh4AfwgYtfTig R4whJU86Ioc2iW5w6f1lHEyOYSCQP04= X-Received: by 2002:a17:902:a711:: with SMTP id w17-v6mr7291382plq.292.1526078499511; Fri, 11 May 2018 15:41:39 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id d186-v6sm7875138pfa.79.2018.05.11.15.41.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 15:41:38 -0700 (PDT) Date: Fri, 11 May 2018 15:41:38 -0700 From: Joel Fernandes To: "Paul E. McKenney" Cc: Byungchul Park , jiangshanlai@gmail.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, kernel-team@lge.com, peterz@infradead.org Subject: Re: [PATCH] rcu: Report a quiescent state when it's exactly in the state Message-ID: <20180511224138.GA89902@joelaf.mtv.corp.google.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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180511161746.GX26088@linux.vnet.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 오후 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 = true. So make it report > > >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 should > > >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 preemption > 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 switch 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 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 in the __schedule loop will run if cond_resched is used. I agree that if schedule was called directly but with TASK_RUNNING=1, 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