Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2548033imu; Thu, 29 Nov 2018 06:43:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wmjf7waHzU6vlVT8diKjYL21d5+nl2kiFZq1QY3gIlHlX9YobcAo0E+NBA8qv7Dki2pRoP X-Received: by 2002:a62:8985:: with SMTP id n5mr1649016pfk.255.1543502618910; Thu, 29 Nov 2018 06:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502618; cv=none; d=google.com; s=arc-20160816; b=IeV5tBuTnZ/5cV2r73Zmv0l0GEmzIikFPniGC8pxOLBWhE57yX5N9SjdQa9cAt/irV 0yDxaQhv1qEiS+0hffCxfxETzqMNBmJvjkuB4x2NK4ToMMnxeCOxSuwViVltib3ipq3e LbaBN21/tMc6LLEYez8mzSsaeVe/D6Rmb0N9Rhxr6dSwO9ZHzG7nAfRC6mGtaEFu+u7G FhPPdoSNs3H3I4+nJAmZOcaIw/oAreGQry/M7IkAuGiwd3lkrUm6ifq7aYZj8SpOt4e5 0mh1phO+PbLkQogtOT5FEbA97OA+UsczJNk9eRCRKVyU72x5yBke8FWEkmeEORx01cr9 Q6sw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oB1i/HomofXOTK9x8hwCJLrwSS0/we9Xydhr9FsjW5s=; b=qzJychkXNNQdhACPnfrSCnKTVgaOlZKPqngDrG7EZX9vvU1+a5P75wzJvr8lIaXeh5 gSbCuCeRfypPxnfUwzp4ar5G/JZFRClaBN4L/xbOK3PfZHnfQA3tNaS0hRR/1R0Ipr1x WGaiKGPXsCA/FaHOamskCMxrHditur34zqn1ZyMIFlU069uUNpxTl8n36tM2m2Apkgyg +RifTvCT+uY0KMUIaAs/OpdOPIxdJp7loszRrEhfrbqANXqut+iuxYanLiXJyBs5c7J+ sizuh4QTxLT7L973aehcwOGt0pOPqexMaGXrkRstvlRt7ureVhfIyxZ0j2wTc+1WsM2y k5xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="zW9W/6+O"; 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 bh12si509691plb.353.2018.11.29.06.43.23; Thu, 29 Nov 2018 06:43:38 -0800 (PST) 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=@kernel.org header.s=default header.b="zW9W/6+O"; 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 S2387873AbeK3Bd1 (ORCPT + 99 others); Thu, 29 Nov 2018 20:33:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731863AbeK3Bd0 (ORCPT ); Thu, 29 Nov 2018 20:33:26 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5914E2145D; Thu, 29 Nov 2018 14:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501673; bh=9PA6UorcPNWtyG0sw+UTdz6T5FuGoV6Jnr3UGAlH5M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zW9W/6+OgARpt8IFdf8O+9DJh7lttJzLjvcgO0yAa5XK3+Ejx5WGNuKOeLABOMKSc YKCNQLpdFhCd8KGAOjJUfsuQtFM2CeBTLolWp8mKjT6DRqOR881TE+e4dYBjEw6Xm3 96qQ31CCkiWedTLACyf8s2+ITKF5TedwS3OnuUb0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marius Hillenbrand , David Woodhouse , Peter Zijlstra , "Paul E. McKenney" Subject: [PATCH 4.14 095/100] rcu: Make need_resched() respond to urgent RCU-QS needs Date: Thu, 29 Nov 2018 15:13:05 +0100 Message-Id: <20181129140106.967088733@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul E. McKenney commit 92aa39e9dc77481b90cbef25e547d66cab901496 upstream. The per-CPU rcu_dynticks.rcu_urgent_qs variable communicates an urgent need for an RCU quiescent state from the force-quiescent-state processing within the grace-period kthread to context switches and to cond_resched(). Unfortunately, such urgent needs are not communicated to need_resched(), which is sometimes used to decide when to invoke cond_resched(), for but one example, within the KVM vcpu_run() function. As of v4.15, this can result in synchronize_sched() being delayed by up to ten seconds, which can be problematic, to say nothing of annoying. This commit therefore checks rcu_dynticks.rcu_urgent_qs from within rcu_check_callbacks(), which is invoked from the scheduling-clock interrupt handler. If the current task is not an idle task and is not executing in usermode, a context switch is forced, and either way, the rcu_dynticks.rcu_urgent_qs variable is set to false. If the current task is an idle task, then RCU's dyntick-idle code will detect the quiescent state, so no further action is required. Similarly, if the task is executing in usermode, other code in rcu_check_callbacks() and its called functions will report the corresponding quiescent state. Reported-by: Marius Hillenbrand Reported-by: David Woodhouse Suggested-by: Peter Zijlstra Signed-off-by: Paul E. McKenney [ paulmck: Backported to make patch apply cleanly on older versions. ] Tested-by: Marius Hillenbrand Cc: # 4.12.x - 4.19.x Signed-off-by: Greg Kroah-Hartman --- kernel/rcu/tree.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2772,6 +2772,15 @@ void rcu_check_callbacks(int user) rcu_bh_qs(); } rcu_preempt_check_callbacks(); + /* The load-acquire pairs with the store-release setting to true. */ + if (smp_load_acquire(this_cpu_ptr(&rcu_dynticks.rcu_urgent_qs))) { + /* Idle and userspace execution already are quiescent states. */ + if (!rcu_is_cpu_rrupt_from_idle() && !user) { + set_tsk_need_resched(current); + set_preempt_need_resched(); + } + __this_cpu_write(rcu_dynticks.rcu_urgent_qs, false); + } if (rcu_pending()) invoke_rcu_core(); if (user)