Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2538534imu; Thu, 29 Nov 2018 06:35:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XfT5KXvia/rNjFQDXI/6d+GY6g0zDtnSbQyx0cmDBV4791nhJfLB4qKoKq38EgIZ8Wourc X-Received: by 2002:a65:60c2:: with SMTP id r2mr260705pgv.393.1543502107023; Thu, 29 Nov 2018 06:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502106; cv=none; d=google.com; s=arc-20160816; b=nyv6sCcYbsEE+H8FiPlFH8QiPT7u5G1KYPeGQFs8nwNqZCXyG6QB6jQD30YxbJqvZS /WREjRDtJBu05JN9atBGibradlQx/B5WhzsixYy+WE+ArL7yEXVTjk2ysrpaIz1kaa0b zjRiI5+luv4N5EGBUfgPR4Pwm3jY6rc7QEf5RUJ6iFPJUFjv66+/HHSNtND2O+T49gJL bHI9Nm21eddxgAAoGCOjcnAgxCXlbiINPybGiNsGoeTCPg8Fy9gh1wduRrDHCZ/TN5NB LloInNIP6nLhUaf8YBY7dMC4B9HHb0Cw8+p6CzSYCnz/hKxBTFVIkQfbYwoDb8lCHyDl VaZA== 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=sJ+fAq4VjoBG/E6GmZxTCTgfIi9o+ga2wBb7FVQY2OM=; b=PAMvNjWU3XEzfXdHr6DVPfDgGyPHz5ALfVDBOzVqd/94NGr9lSKdC+v6yargwM+n+0 7Z87Q6xqOj01+qxo/YvFIvdrpgYioRdZgc0DoERlxNIYzP3LMQvfXPA0qWKgtPCzTpkj SKOfHUxjhoIj6oxO0LugNwvjFxE+fhHOeRi95/vRhNw0z9om2ORSBBHPhvNSmogLe0CN mPXUVLHkd32Xx42oXkdCVFb5/DTMjRQsbLVuXDJ8ygWfuGrxPDvX60vEHhz40mcwNaFC v3DamWkkiOgCMAd8JT/hzZrCW2fDAJAIZ1ye74hvxWnRZ9wNiJffj9XmJ3wIxLwsDX/s 83fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UWgxLQ5i; 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 d23si2022790pgj.558.2018.11.29.06.34.52; Thu, 29 Nov 2018 06:35:06 -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=UWgxLQ5i; 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 S2389429AbeK3Bhx (ORCPT + 99 others); Thu, 29 Nov 2018 20:37:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:41082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389406AbeK3Bhx (ORCPT ); Thu, 29 Nov 2018 20:37:53 -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 6EAC4213A2; Thu, 29 Nov 2018 14:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501939; bh=5D2sBsUvpuB/Q/1VIDe3AlZhGTpt4RQHDLvvPIQwnEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWgxLQ5icggkw0XN6vD/g6fQ5FcDbZksa9rkemnq+6RjKxrE7DS0zmjLxUb50s2tn QYsmB6ndB8ykX7Zj8XbRmr0Y0t0KwUqo8g1Q+cmEvKD/ybwCXmSzyM2Uy2IuumFLdP T8WSUR6SUiCCNvt77tITRzcGWOTtjGLEujb1SGtc= 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.19 104/110] rcu: Make need_resched() respond to urgent RCU-QS needs Date: Thu, 29 Nov 2018 15:13:15 +0100 Message-Id: <20181129135925.449820048@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@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.19-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 @@ -2662,6 +2662,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();