From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BD49C74A5B for ; Tue, 21 Mar 2023 14:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbjCUOUu (ORCPT ); Tue, 21 Mar 2023 10:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbjCUOUs (ORCPT ); Tue, 21 Mar 2023 10:20:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1A3620A1C; Tue, 21 Mar 2023 07:20:46 -0700 (PDT) Date: Tue, 21 Mar 2023 14:20:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679408445; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/pBoFmguioMLSvMkftSbQsFCmP0noBrs9vtbgLjshAc=; b=EP3O/vmqEGzpvO+v4uy3UK5mD6qeM4iyotV+LChHLXWFgtDv/Al0BOhbd7Lr2T/nXWOiOm kSGdFdEuTcezs4RXywDnt1fJZPm8COnq6Fyr1oT7DDNFqCyFCXK5jEFOn6HCCodiEqfbrC 55h+X7BZ5UMHSsOm0s1wgvR1fxilFb5Deok7pE1DH+M5dfV9pcjr48faUsnyg+Gv13yq8j HLqlfZyrzq4jzzukM/hLIYgh9oJRSUE5TNosrFYQI/93qN0C5j2WVeZ41h3B4UlJ0Lk0m+ mkKPPdu7m52ggB0iapsnMMayNXbU7QU14iWDCWHMlPI+p7bICX7j/CmsHtNjPQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679408445; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/pBoFmguioMLSvMkftSbQsFCmP0noBrs9vtbgLjshAc=; b=vYszxp0jgFDPzW/LXpFoSgkUgMD01QQOUV0eslXVrhl1X9MDbBLUsUv1vGaf9BHz7UaKBu bM3jExA7eUhTB9CQ== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/urgent] entry/rcu: Check TIF_RESCHED _after_ delayed RCU wake-up Cc: Frederic Weisbecker , "Paul E. McKenney" , "Joel Fernandes (Google)" , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230315194349.10798-3-joel@joelfernandes.org> References: <20230315194349.10798-3-joel@joelfernandes.org> MIME-Version: 1.0 Message-ID: <167940844480.5837.12194388325667368870.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/urgent branch of tip: Commit-ID: b416514054810cf2d2cc348ae477cea619b64da7 Gitweb: https://git.kernel.org/tip/b416514054810cf2d2cc348ae477cea619b64da7 Author: Frederic Weisbecker AuthorDate: Wed, 15 Mar 2023 19:43:43 Committer: Thomas Gleixner CommitterDate: Tue, 21 Mar 2023 15:13:15 +01:00 entry/rcu: Check TIF_RESCHED _after_ delayed RCU wake-up RCU sometimes needs to perform a delayed wake up for specific kthreads handling offloaded callbacks (RCU_NOCB). These wakeups are performed by timers and upon entry to idle (also to guest and to user on nohz_full). However the delayed wake-up on kernel exit is actually performed after the thread flags are fetched towards the fast path check for work to do on exit to user. As a result, and if there is no other pending work to do upon that kernel exit, the current task will resume to userspace with TIF_RESCHED set and the pending wake up ignored. Fix this with fetching the thread flags _after_ the delayed RCU-nocb kthread wake-up. Fixes: 47b8ff194c1f ("entry: Explicitly flush pending rcuog wakeup before last rescheduling point") Signed-off-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230315194349.10798-3-joel@joelfernandes.org --- kernel/entry/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/entry/common.c b/kernel/entry/common.c index 1314894..be61332 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -192,13 +192,14 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, static void exit_to_user_mode_prepare(struct pt_regs *regs) { - unsigned long ti_work = read_thread_flags(); + unsigned long ti_work; lockdep_assert_irqs_disabled(); /* Flush pending rcuog wakeup before the last need_resched() check */ tick_nohz_user_enter_prepare(); + ti_work = read_thread_flags(); if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) ti_work = exit_to_user_mode_loop(regs, ti_work);