[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251116232326.9373-1-hdanton@sina.com>
Date: Mon, 17 Nov 2025 07:23:25 +0800
From: Hillf Danton <hdanton@...a.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Boqun Feng <boqun.feng@...il.com>
Subject: Re: [patch V4 08/12] rseq: Implement time slice extension enforcement timer
On Sun, 16 Nov 2025 21:51:21 +0100 (CET) Thomas Gleixner wrote:
> If a time slice extension is granted and the reschedule delayed, the kernel
> has to ensure that user space cannot abuse the extension and exceed the
> maximum granted time.
>
[snip]
>
> #ifdef CONFIG_RSEQ_SLICE_EXTENSION
> +struct slice_timer {
> + struct hrtimer timer;
> + void *cookie;
> +};
> +
> +unsigned int rseq_slice_ext_nsecs __read_mostly = 30 * NSEC_PER_USEC;
> +static DEFINE_PER_CPU(struct slice_timer, slice_timer);
> DEFINE_STATIC_KEY_TRUE(rseq_slice_extension_key);
>
> +static enum hrtimer_restart rseq_slice_expired(struct hrtimer *tmr)
> +{
> + struct slice_timer *st = container_of(tmr, struct slice_timer, timer);
> +
> + if (st->cookie == current && current->rseq.slice.state.granted) {
> + rseq_stat_inc(rseq_stats.s_expired);
> + set_need_resched_current();
> + }
> + return HRTIMER_NORESTART;
> +}
Feel free to add a comment for the migrated tasks, because the percpu
slice timer fails to catch them, to specify how to clamp the maximum
granted time.
Powered by blists - more mailing lists