From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6EAD439446B for ; Thu, 21 May 2026 07:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779347099; cv=none; b=GG30+d6qJ7/AchUN1rCCbBD6Mu1kHaC8NMpBz/Mq9GtcqpL+jC1H+NYRynqvE18dQPBKkMtCnm3jhzR2M+EFOxnoAkYJw8r36oyjp1YFLyWL+1L1QRO1OxdnfBJHJBej8/lIA3mbHnRizPvvH7mDUJTCyXOoD1MARy5bpWYdJQE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779347099; c=relaxed/simple; bh=B0I4dlT6tZ8e+whjjd7GwXG9Fb5dSJbW5rzJDpFEvSY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OrVP7e/GUzapzgv1g2x6p05NNOD4BigL06rCrbYoYWkDBNL+4C3rZdJ4sG65aT1gYWXUIHSaqVtpMck5fI7bdAuStjxc3djbgX5OdNCsrTaThwNvzTV54iiNs1LVzsJ6Hm1nOB/GkpnwrLLkeOMTRBLUVTbF+0B4PGAbpuU9Tuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=rTEG3Unb; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rTEG3Unb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=x50blBBEh1e8KVa5ZRCDfRRnzgZM/gDu9glUwswplyY=; b=rTEG3Unb87EY3k9vOcIDMPJ5Hm b+lB5aWsNIS71plFnT8fY+rPveHFkuGn5NBEEeVUdW6oM2rOD+bq+nMh95mQkZXcUgJHPe4QKQEOU LgfdKnaxdLewiT6s6UCAXptn/F+oOUS6lCHn+Emfp0Mdv2tnr68exEGqYFDdTtSpLf3nmgb24cV3/ Ir4IRVDxoK+TgrczqsFHAHCv2Te9fXk+xcds2PomiasmhDOkR4WWyUKFZqPXfY6j4UCvvOTarHNvL oB/R2DQUe5hoQYGSIHyqphDbEGQ5kY+Y1JCVqJh5oeCaspIHfUKN77J3KUr5GPi+H5OpeWBzLfGxu WQe2Ux7g==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wPxST-000000012Uv-2oOU; Thu, 21 May 2026 07:04:42 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 26E7F300446; Thu, 21 May 2026 09:04:40 +0200 (CEST) Date: Thu, 21 May 2026 09:04:40 +0200 From: Peter Zijlstra To: "Guanyou.Chen" Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Andrew Morton , Thomas Gleixner , Felix Moessbauer , Dietmar Eggemann , Steven Rostedt , Kees Cook , chenguanyou@xiaomi.com, linqiaoting@xiaomi.com, chunhui.li@mediatek.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] sched: restore timer_slack_ns when resetting RT policy on fork Message-ID: <20260521070440.GD3126523@noisy.programming.kicks-ass.net> References: <20260521025250.1469390-1-chenguanyou@xiaomi.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260521025250.1469390-1-chenguanyou@xiaomi.com> On Thu, May 21, 2026 at 10:52:50AM +0800, Guanyou.Chen wrote: > diff --git a/init/init_task.c b/init/init_task.c > index 5c838757fc10..57ff8dae9bfb 100644 > --- a/init/init_task.c > +++ b/init/init_task.c > @@ -170,6 +170,7 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = { > INIT_CPU_TIMERS(init_task) > .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock), > .timer_slack_ns = 50000, /* 50 usec default slack */ > + .default_timer_slack_ns = 50000, /* 50 usec default slack */ > .thread_pid = &init_struct_pid, > .thread_node = LIST_HEAD_INIT(init_signals.thread_head), > #ifdef CONFIG_AUDIT > diff --git a/kernel/fork.c b/kernel/fork.c > index 65113a304518..8358df80e11d 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -2133,8 +2133,6 @@ __latent_entropy struct task_struct *copy_process( > retval = -EAGAIN; > #endif > > - p->default_timer_slack_ns = current->timer_slack_ns; > - > #ifdef CONFIG_PSI > p->psi_flags = 0; > #endif Cunlong makes a good point in that this changes behaviour. That said I do find the current behaviour 'odd'. *IF* we want to change this (and changing behaviour is always dodgy), then it should be a separate patch with a separate justification. > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index b7f77c165a6e..b1a241810ce0 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -4649,6 +4649,7 @@ int sched_fork(u64 clone_flags, struct task_struct *p) > p->policy = SCHED_NORMAL; > p->static_prio = NICE_TO_PRIO(0); > p->rt_priority = 0; > + p->timer_slack_ns = p->default_timer_slack_ns; > } else if (PRIO_TO_NICE(p->static_prio) < 0) > p->static_prio = NICE_TO_PRIO(0); Yes, this matches __setscheduler_param(). And yes, this wants to be done. Anyway, while looking at all this I found that the manpages specify RESET_ON_FORK to apply to CAP_SYS properties; which is a tad awkward, esp if we end up allowing unpriv access to DL (or even FIFO/RR when isolated in a bandwidth group). Additionally, it doesn't look like PR_SET_TIMERSLACK is CAP_SYS guarded itself, so this is all a bit of a mess.