From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C7839A801 for ; Fri, 22 May 2026 13:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455476; cv=none; b=ouCoiTLYCq+jBkcPwVMd4sBtachSKBGV+TDMfbpvhUmzbYYO2QYtOUtPTIzponIAompFmiKeQ2ykMYzDgD5ISLPQBv6N/J/Ts/U/ZdcNawOR4hMikBib/nh/j6Qhx5DZUgOoviONeJCLY9BeYXktTMwP2lq48WycynYlC/7MKWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455476; c=relaxed/simple; bh=8Qmb4NUWQKug52jxg4KO30zYqHSTL0W3sImtSojvI84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q4neISAgcMO0FN/B0xxrFgL/d4fxk8YohmGZ0dCaiLTKbwglHzGnQE4hLWAN3T4E1WqDEtR4qocKQPstbKto9BmYwQoFV4Y1q8afCKdcdtdi5uTmWnanl3tRIBr7+YuIKmG+taBzRla+F+LPwCG94kvf3tqHbbUVoooXul4BjbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ofwPGqMm; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ofwPGqMm" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-459bf19e87bso4376130f8f.1 for ; Fri, 22 May 2026 06:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779455473; x=1780060273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eqaGR9QC9sk0vele50CdUpWtSWhtR0zZvI8lmeOz5HE=; b=ofwPGqMmZIcRMMv2APRl5goBEgdi2FUwpuhJak1L0U+172/6Axtbt55Hcfbwn0F/wo 5d14teoMyfIvBEqK1EEO++1dh/RDPXpiP3UoxEyIpuGJa+zcz2CNVf0ciDRTSx4VZQmd L/YKQi7yvGv8OxrbrxpKys1oZbD+FjesHuB5kfAwgvLrId1qws2rFyr9ecI9a6HJnXpv 68HLRs5oNJ5OEqgCvoeSpfpNPXfRu9M69n/vhqKoOa9+ZPmSBGUn3U8K8y2sBY7zDwil fvdGYYvxE9IDf77Dtgn94oUHul9jD/VnRqU93fcjKmJYlsCWOyeoG2cAeNo0fMz1+CHu E/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779455473; x=1780060273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eqaGR9QC9sk0vele50CdUpWtSWhtR0zZvI8lmeOz5HE=; b=Nqtj4K3DLR4JjNKiFplu3RdT0qvZ1TVLT7lCixOc0QrOfwnCslKFxwH30XyToxN5DD cgJch6TFGp3SkjljKArgkHbWOmJRKxk6BhqM3jL+BIpFbrmIT2JFQ2tTgJSr8k0CIWrA 29o7SFBJZhAcgD4vg1FaEpKiVEDjPLxNgybetVLCpZ55Jv3xbzhJSuTzLfMSfvFgTDeL B1v8/s87s6CPehGxP5Co9RykpyhQlGzlSgbfvDYaY70BFdrcQkAFvcSnyWSVBiDThDXz Z69XnGGE29vfxXHzUyZ7+gyVRJik+JKmeEyD/yBExvzcBTVYHqKxIkbpYbIORXcbuM5j Pqew== X-Forwarded-Encrypted: i=1; AFNElJ9Vh5esPkySiMLgBqa/JmSc+DoSoXXQDyFJow0qT+/qaEpyxAd/citnCtPxtT8KXIpJKHLUPumVg6JMslw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4j/YUmkf57qTiXsQySPCmj4zZY0yDBpSRCyyBPLw5DVfJf4Kk hT66gPkg7D8iDtH7+BbfwMy2Xq00aajFCtXyf6Jg3IxQemFPhT7vaXGW X-Gm-Gg: Acq92OH7+fXbGktI/yAdD8opJ7wPJCbAntXbMLY2gT88jXzdWmE29Hs7t/oxsxmiXf6 iMOqPOMUTQOxShVFrl8dIyRJhMpcjC+7FgrOBkQoQJepK2lnVyA8R0sXraS2DhuM2spUWMNmVDE 3VXDuwNrDli8/uQHisCuJh/ZTbpYP0OHZG9ihxdFCfMZ3m+CTZSgiOLXAMTM8zXdTDjDgifw3ic K6hpheKSRyWjAy1io8vSBwrAFGYb0MXqL3tD7/Sbk3IUv1AlNnmGl/mRZcoq8tGZpfLiH3ExgbI h7GzXIMD5Lfvm6Yo1JYtL0wexAp3IGgCQ4EfYqnQTYDAqEhcpIWGPU0u4c46F+NliBbHl6xfWPx gbN4hkxYwNRLZzEELr8WMrB/CDmDlp4PREF4vv5ARM5TDN7L05GMb+vWDjZ3iAyYGeN4RefXzrf gN7EjZOMgbod738zarm5CbTcMiVW09NvHxDRfie2gcilZEj4MJHkSQvxgBggGVjxU= X-Received: by 2002:a05:6000:1a87:b0:43f:dd91:b022 with SMTP id ffacd0b85a97d-45eb38d7d0emr5367027f8f.35.1779455472506; Fri, 22 May 2026 06:11:12 -0700 (PDT) Received: from mi-HP-ProDesk-600-G5-PCI-MT.mioffice.cn ([43.224.245.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6d5e484sm4091262f8f.30.2026.05.22.06.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 06:11:12 -0700 (PDT) From: "Guanyou.Chen" X-Google-Original-From: "Guanyou.Chen" To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Andrew Morton Cc: Thomas Gleixner , Felix Moessbauer , Dietmar Eggemann , Steven Rostedt , Kees Cook , K Prateek Nayak , chenguanyou@xiaomi.com, linqiaoting@xiaomi.com, chunhui.li@mediatek.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 2/2] fork: fix default_timer_slack_ns inheritance from RT parent Date: Fri, 22 May 2026 21:10:00 +0800 Message-Id: <20260522131000.1664983-3-chenguanyou@xiaomi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260522131000.1664983-1-chenguanyou@xiaomi.com> References: <20260521070440.GD3126523@noisy.programming.kicks-ass.net> <20260522131000.1664983-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-Transfer-Encoding: 8bit Per prctl(2), "Timer slack is not applied to threads that are scheduled under a real-time scheduling policy." This means RT tasks' timer_slack_ns is forcibly 0 - not a user-chosen value but a "not applicable" state. When copy_process() sets the child's default_timer_slack_ns from the parent's timer_slack_ns, it inherits this forced 0 for RT parents. This corrupts the child's reset target, making prctl(PR_SET_TIMERSLACK, 0) and sched_setscheduler() back to NORMAL unable to restore a meaningful default. Fix this by using default_timer_slack_ns (which preserves the pre-RT value) when the parent is RT/DL. For non-RT parents, timer_slack_ns is a meaningful user value and the existing behavior is preserved. Fixes: ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values for realtime tasks") Reported-by: Qiaoting.Lin Signed-off-by: Guanyou.Chen Signed-off-by: Chunhui.Li --- kernel/fork.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index 65113a304518..bc4df18bfd90 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -2133,7 +2134,10 @@ __latent_entropy struct task_struct *copy_process( retval = -EAGAIN; #endif - p->default_timer_slack_ns = current->timer_slack_ns; + if (rt_or_dl_task_policy(current)) + p->default_timer_slack_ns = current->default_timer_slack_ns; + else + p->default_timer_slack_ns = current->timer_slack_ns; #ifdef CONFIG_PSI p->psi_flags = 0; -- 2.34.1