From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from r3-25.sinamail.sina.com.cn (r3-25.sinamail.sina.com.cn [202.108.3.25]) (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 5B21D275AE1 for ; Sun, 16 Nov 2025 23:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763335435; cv=none; b=L2hqeXI4cPUaeRojTb0o4U3QTGYcMDDp2tboWUUFGgc7VfsBSRcp1yqWP/o0bczOGnD9xA2xlmqJRfphDIp3FkRqJcM+y1RW4scO84Bk2bL6UbnELyWwW0q1aXlmzPow3zAj0jg2R9Xrelkrm81L3h9qSjXT36bh+cvJVtPzU8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763335435; c=relaxed/simple; bh=O01VdL0erXk1DvEnlNEWyaG6a6H0u+3s7fjIAJm3wks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VLJM0eZY2Mi9YGDmKmYDjhTgx7F2GLd1DK6acZ0LkF9zNZU2gHYolRh0u2eM+Deqwidv3oVzufx2szK01/oW5iyw87jOh10fhF/YwblxRqezGbNdFiRgIQvPtCDKGGs9Uf8sUXV47gcf+Lp7LkSyNVmVJxNvVODgXlIXuDo0Pw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=Ht4aJh4n; arc=none smtp.client-ip=202.108.3.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="Ht4aJh4n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1763335430; bh=lQPMKhaKHpuzjZVlU4fXRraG4f1GNTGKXbE37dS907s=; h=From:Subject:Date:Message-ID; b=Ht4aJh4nZOW2GMSAl+KE2844YxdVEAnNQkKJxLpSn+/qXKlQA/8azISmSehtZkeOt UEOW9lrABzsJ9C2pxjOwzn+3FNMho+Xcy6dI2PsfkV2N0Fqjpx65MwujafirPQ7eHj U3F9tjEFi5/c4ZZCYjWWm2r+3/a8PMIVF3WRWVEs= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.57.85]) by sina.com (10.54.253.31) with ESMTP id 691A5CF8000069C7; Sun, 17 Nov 2025 07:23:41 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 2869566816438 X-SMAIL-UIID: C8E69904936C47669A9283BC8ABFFDB4-20251117-072341-1 From: Hillf Danton To: Thomas Gleixner Cc: LKML , Mathieu Desnoyers , "Paul E. McKenney" , Boqun Feng Subject: Re: [patch V4 08/12] rseq: Implement time slice extension enforcement timer Date: Mon, 17 Nov 2025 07:23:25 +0800 Message-ID: <20251116232326.9373-1-hdanton@sina.com> In-Reply-To: <20251116174751.112541791@linutronix.de> References: <20251116173423.031443519@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.