From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0DC5346774; Mon, 15 Dec 2025 16:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817556; cv=none; b=XhefZwdO0zFrqbtWKkTHfw6TPLSFN7eHbd8f4/FdDdPK8AIBght06tBOils/6KeWGKH3ZqlYu+6ce5Om2femsioqv++ITZrwh85abMEC9ubdosUsCKQDR73YmEc96fGvlBTNWFvOUruGnGDPGwGX0gnXFnzgQLHaPYc8KMVjTfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817556; c=relaxed/simple; bh=RhXdOrpmvWhEXZAJBOlVp00/Ibtc92pO9VfibfnzKL4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ezZa0YgUNzS+wFcN+zzJoI+tqKQvaHfo/laW31n8XKYzgBklop5vOoH2/0siKrTrRfIPC0uzhiQ7SUlx7fQOmjl5NRf7xvUBz90xcqdiPg0MwAr78QjMT3sjdB7PgQPUNSDuG2K8GKc+Z+MHCSWDABqmDvSe/9uLCE6P6DS51y4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=e5H6dLen; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3u5S2Jqz; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="e5H6dLen"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3u5S2Jqz" Message-ID: <20251215155709.258157362@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1765817553; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=gQFvLoA+8aqRp49/IJYirlydqYT+cxE6z9BZ2w2sdfQ=; b=e5H6dLenjxqDilMNKPMN5Ar3hVRmCaOf2Qr7mpkheVvrfMOV5qrFXcnQu+PEUHuhgIJ6dS XbDpfGt/wjCmsEuObXmQOj4mBw2ZGWJmErIzRJlRYh0x9DQ6ljm21ZQ6Taf5KFmCWhtNtv dRH4YdNtHKC/SahgNNeYtSxJ7c/bN0zO/hmep2oYN6BO7wR32no27FbHcpLuKx1ZUGxkLY 4H2ha2pijCGzg89UiXKO0+LMJ/Gwjn12WmWSZ4sO0QNNnWXE2tSONpbpUddyblKMuU6/zi kDp58wFfshlFEF7Qodud0KPhGpkIVl13veCm5RFypiUyjwia0vQgX61qh6NrTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1765817553; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=gQFvLoA+8aqRp49/IJYirlydqYT+cxE6z9BZ2w2sdfQ=; b=3u5S2JqzhxyvoHf7FYlOFTNCe2FuNXAwGRLW2TIhBb1K1GEtt2w1didBMuj6UBml1oHJsu Q/vjGOt4/204JtAA== From: Thomas Gleixner To: LKML Cc: Mathieu Desnoyers , "Paul E. McKenney" , Boqun Feng , Jonathan Corbet , Prakash Sangappa , Madadi Vineeth Reddy , K Prateek Nayak , Steven Rostedt , Sebastian Andrzej Siewior , Arnd Bergmann , linux-arch@vger.kernel.org, Randy Dunlap , Peter Zijlstra , Ron Geva , Waiman Long Subject: [patch V6 10/11] entry: Hook up rseq time slice extension References: <20251215155615.870031952@linutronix.de> Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 15 Dec 2025 17:52:31 +0100 (CET) Wire the grant decision function up in exit_to_user_mode_loop() Signed-off-by: Thomas Gleixner Cc: Mathieu Desnoyers Cc: Peter Zijlstra Cc: "Paul E. McKenney" Cc: Boqun Feng --- kernel/entry/common.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -17,6 +17,14 @@ void __weak arch_do_signal_or_restart(st #define EXIT_TO_USER_MODE_WORK_LOOP (EXIT_TO_USER_MODE_WORK) #endif +/* TIF bits, which prevent a time slice extension. */ +#ifdef CONFIG_PREEMPT_RT +# define TIF_SLICE_EXT_SCHED (_TIF_NEED_RESCHED_LAZY) +#else +# define TIF_SLICE_EXT_SCHED (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY) +#endif +#define TIF_SLICE_EXT_DENY (EXIT_TO_USER_MODE_WORK & ~TIF_SLICE_EXT_SCHED) + static __always_inline unsigned long __exit_to_user_mode_loop(struct pt_regs *regs, unsigned long ti_work) { @@ -28,8 +36,10 @@ static __always_inline unsigned long __e local_irq_enable_exit_to_user(ti_work); - if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) - schedule(); + if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) { + if (!rseq_grant_slice_extension(ti_work & TIF_SLICE_EXT_DENY)) + schedule(); + } if (ti_work & _TIF_UPROBE) uprobe_notify_resume(regs); From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73F4E32693C; Mon, 15 Dec 2025 18:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765823101; cv=none; b=aA41wgcikOxXT0tWwbDiqbt6rzbVxcwnGGza+qcASC3S5E0i8Oqr8zdtvvI4Vbvynh0w3r4lJjnIwTEaFwlwTtr+krlJpJqAQ4Y2N3xsj6En1ZwWt7gJPYvuYlmb7zynKUb8FcgHeHEpCmXVAW6z+vsZEmS/+lYrQt65YtQl7pE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765823101; c=relaxed/simple; bh=RhXdOrpmvWhEXZAJBOlVp00/Ibtc92pO9VfibfnzKL4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=DPPE1c84Le/CdXLv43nD3bmXEBDGuU/cdqdYEZ3CPWeDkXtpRoIQmKyeJHIy5uuOzl8Mz0kXkALTt/vK5qxNupMIgxzX6OmnuWPwOXu7ZKnQZfPg7xhesn8B7b+ltnimKfFUIKvO2K+yI/rja3+Xw3p5jfTNnPQL7X1dJA5U9og= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=efUUNgXG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=J0Dk3KK2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="efUUNgXG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="J0Dk3KK2" Message-ID: <20251215155709.258157362@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1765823097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=gQFvLoA+8aqRp49/IJYirlydqYT+cxE6z9BZ2w2sdfQ=; b=efUUNgXGGRTo9baBK002GNUTLe3Y+RRtyruCsPOFfNOlIofzFV8TPiV+V3xLMOZxPNBGkE wXU3mbGHVZCX7rDFktpRjQsaXAby8EPO7P5B+9NSmAEpZUZKVNLhXJOPOE0gVyWgO96eX6 jCLN92RMBe5gmwgdfY0VzJgDmpl+Kkuq0QibcKedtStXNTPeNUD0gYqXQ+cX5kTiqocIVh +vieIxM7EKM8g9/pfg9bmoai9b/WVWS9CxUIdDtjpcEJN7Vw8AHZlx8HubAep95s1wcxYo j2gjfw7DDpykXr6ufrzDQzsarHDvIVKhSb621hcl1B2GLF69YWWGPKVD+xth4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1765823097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=gQFvLoA+8aqRp49/IJYirlydqYT+cxE6z9BZ2w2sdfQ=; b=J0Dk3KK2gZKWdckRjo6V68IAWh+kIlOwF/eaYC1mK4FIus8DedS9Y+x04GewZ0Wey/fk1E ZNNeNClRJcxr0zBQ== From: Thomas Gleixner To: LKML Cc: Mathieu Desnoyers , "Paul E. McKenney" , Boqun Feng , Jonathan Corbet , Prakash Sangappa , Madadi Vineeth Reddy , K Prateek Nayak , Steven Rostedt , Sebastian Andrzej Siewior , Arnd Bergmann , linux-arch@vger.kernel.org, Randy Dunlap , Peter Zijlstra , Ron Geva , Waiman Long Subject: [patch V6 10/11] entry: Hook up rseq time slice extension References: <20251215155615.870031952@linutronix.de> Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 15 Dec 2025 19:24:56 +0100 (CET) Message-ID: <20251215182456.Ntpz9GjmnMFSosFc8LEcgLft0xYWaKMVPdO23Y_fUxY@z> Wire the grant decision function up in exit_to_user_mode_loop() Signed-off-by: Thomas Gleixner Cc: Mathieu Desnoyers Cc: Peter Zijlstra Cc: "Paul E. McKenney" Cc: Boqun Feng --- kernel/entry/common.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -17,6 +17,14 @@ void __weak arch_do_signal_or_restart(st #define EXIT_TO_USER_MODE_WORK_LOOP (EXIT_TO_USER_MODE_WORK) #endif +/* TIF bits, which prevent a time slice extension. */ +#ifdef CONFIG_PREEMPT_RT +# define TIF_SLICE_EXT_SCHED (_TIF_NEED_RESCHED_LAZY) +#else +# define TIF_SLICE_EXT_SCHED (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY) +#endif +#define TIF_SLICE_EXT_DENY (EXIT_TO_USER_MODE_WORK & ~TIF_SLICE_EXT_SCHED) + static __always_inline unsigned long __exit_to_user_mode_loop(struct pt_regs *regs, unsigned long ti_work) { @@ -28,8 +36,10 @@ static __always_inline unsigned long __e local_irq_enable_exit_to_user(ti_work); - if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) - schedule(); + if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) { + if (!rseq_grant_slice_extension(ti_work & TIF_SLICE_EXT_DENY)) + schedule(); + } if (ti_work & _TIF_UPROBE) uprobe_notify_resume(regs);