From nobody Mon May 25 06:43:08 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 DA6DB2DF3D1 for ; Sun, 17 May 2026 04:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990872; cv=none; b=Zi1XZO4fqc6kPvo4W3NASVkibpXGx8MeVjcav0G4HIg9gdVXLEAkEgcf/2XOs5Ek16LiUi0uo1CiKSa/VLlBuge03sOJ38YBe1JW9f/1/F2qIQJN6xvuZCRBLkaoQUeioWGwp/FZCHa78OWrr1XX6ES53pPy4o5LhCxi/Ocm2ZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990872; c=relaxed/simple; bh=AYN8/SzWy3jBnPu731MIEbWOsFyU1tE2X0028Lac4tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BHgxxnDn7pJ7VXqCLP/sNJ9C0cQjg57lwG6DOuwGkLPrLS31cLP41xJ7GXe36WINh6kqbKhwrHzEhb5An9sfZOGefKQBJ47fxtE9kR3L5UjbY2RLbpshNGJn/NBXvXywZFoABFA1/T6HV2WTdi5dgI13jZqEg2FJb67hw89kwrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b=UmaAsVRC; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b="UmaAsVRC" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso6015745e9.0 for ; Sat, 16 May 2026 21:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20251104.gappssmtp.com; s=20251104; t=1778990869; x=1779595669; 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=wSRH5YGuKT/WOHTAt6om6/ykzNGaG/9poDzpuaDsh2g=; b=UmaAsVRCooxPXx9npQWpPCzQNfDYerqKetJx6xaweNtF+D6InDI2l4oloXaLPDR5eL X8DSHQkjPTdmbxuRe2Rk2WYPI4jQSA03RMVJC0dgdZFOADaKKurNDjbcYEm1E0B1hkkj XWBlW+mvHRpnvdv4RpiqAAHFaCz/TKvrg1DZftGm58BRy+zzOYWA6XwAb3cTJ3q1s4l2 gSAin8KiPyNiOHDP5IxJLOkaowB1b9+bTd9IjDjoUWnPBSfR2NOzbpDv+65zfHY7QVit zAs1vnbIXV9THvUt5p15Muc9BuzpwPeSbgiBpBRH+MSU33y3QyCfDMsZmAsiVFCfkrgd /dXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778990869; x=1779595669; 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=wSRH5YGuKT/WOHTAt6om6/ykzNGaG/9poDzpuaDsh2g=; b=McaHOdy8wa9As/vxnW+bMI1XYXSjO+8ZLL7Xaxc00mtTRhA0jrvidUWxNgyhTV29R+ RPtGAgtItd+CfRw990FMMpcXnZmSeoR2hDUyDBYDakQdm8G1aQ3JZmj24NvemT7Ik/TP wYp6iW1S8lNSiLaeD5k/sCz4rrkaGdljYrPWSgAAn9zzjFH6TneDjMpTHtTIhkn9DidD o/e5KB+i36O1jaEKEK08HR4Jocdl8NStbxddgTWhLew7TisZ8EuqzVt8B77FWENSYJVi bYq6+JWHbQsOShglc189L5TFPlwsSxNUVojjm6raIDFqu7dl/1GrsXOWRqirrKQGfO/4 082g== X-Forwarded-Encrypted: i=1; AFNElJ/Um4Xj/QjmUbYpWplYXO0vMYTr0xR8qC6zB3h6CYJrtbi4lJtP+GuJ90ClZ37j8lZjs6VZQakrwhZf2Uk=@vger.kernel.org X-Gm-Message-State: AOJu0YyGwfbT7onTs6xpRDGMBMx2ImpWlTMJWnZ+GRrytrP52iao78Vr 8Eiw1ngi2UxO0DbSFBmjEIquZWdSjlB0Qo8bv1Slqyb9O3l7TvEb9IAm0n0p6vxx0Dc= X-Gm-Gg: Acq92OHjPwxmWaGyDUOr1wO5j9LJMljmEfDOt+0FVFKj2rsN6aNNBPVtjw7kEk1uo1l fHnoKIxpEqvI5LaxGDboSPtXNK2PXXdUmJX8L5X65aVPiM+WpgJgyDDScZd+EK5QUMxMgA7gVKN Pd7dXFVadlKgyi96su3/dcxX+oIv2N6D+E/qvBW2UoVDarv58XvTY+1SPQxkMM8Erj1D2jL/UzI DQv6Q8Y17nK5YNyfNKd/u0cDTV85n6SWJmYIa+k/erKH/p7DxQUQmrMY5ktELYIUkYuOlGs5GEt BEIWKNgspekyRb7G+d/j59/OmLSVw7eVFqff42BnczfXgOcydRzAKBXT+scDA/aSjKVWDGp2rWg nbrDMMAwMPcYoVpdOo1NLA0OtrbFydwbjU40qeVZ637KjLV/9e0i5ErJ1KwAZBioKarhrPjFg9O WhT2QdtOnMLTKPymg6zjY7nwtXY6U3 X-Received: by 2002:a05:600c:6386:b0:48f:dedb:bd8b with SMTP id 5b1f17b1804b1-48fe61f7b08mr140878845e9.18.1778990868364; Sat, 16 May 2026 21:07:48 -0700 (PDT) Received: from airbuntu.. ([149.40.48.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe5ab3977sm184754395e9.9.2026.05.16.21.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 21:07:48 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot Cc: Juri Lelli , Steven Rostedt , John Stultz , Thomas Gleixner , Frederic Weisbecker , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH 1/3] sched/tick: Decouple sched_tick() from HZ Date: Sun, 17 May 2026 05:07:38 +0100 Message-Id: <20260517040740.444729-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517040740.444729-1-qyousef@layalina.io> References: <20260517040740.444729-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add new sched_feat(PTICK), Pseudo Tick, which runs at a more regular 1ms interval when a task is running ensuring more timely update of sched stats. As discussed in previous attempt to change default HZ to 1000 [1], it is very consequential on scheduler decisions. By decoupling sched_tick() from HZ (timer tick), scheduler will no longer be limited by other TICK implications and can be set to a constant value, 1000. We could make it configurable, if folks think it can be useful, but this seems to defeat the purpose of introducing it. We want fast regular ticks. It can be turned off via sched_features for folks who don't want the potential additional overhead. Defaults off for now. PTICK will only be active when there are tasks running on the CPU. Given HRTICK is now default on, it'd be more consequential for solo long running tasks. When HRTICK off, it'd help with more precise time slices when HZ is low. When no tasks are running, sched_tick() will still be triggered from regular TICK. The actual interval is actually 1025us to ensure a PELT period (1024us) has passed. Since load balancer is tied to jiffies, we need additional work to decouple it and help with faster reaction. Circulating patches to introduce push load balancer could make this conversion unnecessary. Other users of jiffies might find it useful to use the new ptick. But any jiffies related conversion will be left out for now. [1] https://lore.kernel.org/lkml/20250226000810.459547-1-qyousef@layalina.i= o/ Signed-off-by: Qais Yousef --- kernel/sched/core.c | 78 +++++++++++++++++++++++++++++++++++++---- kernel/sched/features.h | 7 ++++ kernel/sched/sched.h | 7 ++++ 3 files changed, 86 insertions(+), 6 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b905805bbcbe..b47ac98ff42b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -890,7 +890,7 @@ static void __used hrtick_clear(struct rq *rq) } =20 /* - * High-resolution timer tick. + * High-resolution timer tick. Triggers at the end of next_task slice. * Runs from hardirq context with interrupts disabled. */ static enum hrtimer_restart hrtick(struct hrtimer *timer) @@ -1011,11 +1011,63 @@ static void hrtick_rq_init(struct rq *rq) hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD | HRTIMER_MODE_LAZY_REARM); } + +static void ptick_clear(struct rq *rq) +{ + if (hrtimer_active(&rq->ptick_timer)) + hrtimer_cancel(&rq->ptick_timer); +} + +static void ptick_start(struct rq *rq) +{ + hrtimer_start(&rq->ptick_timer, ns_to_ktime(PTICK_NSEC), + HRTIMER_MODE_ABS_PINNED_HARD); +} + +static void ptick_ctx_switch(struct rq *rq, + struct task_struct *prev, struct task_struct *next) +{ + if (is_idle_task(next)) + ptick_clear(rq); + + if (sched_feat(PTICK) && is_idle_task(prev)) + ptick_start(rq); +} + +void __sched_tick(void); + +/* + * High-resolution timer tick. Triggers regularly every PTICK_NSEC. + * Runs from hardirq context with interrupts disabled. + */ +static enum hrtimer_restart ptick(struct hrtimer *timer) +{ + struct rq *rq =3D container_of(timer, struct rq, ptick_timer); + + WARN_ON_ONCE(cpu_of(rq) !=3D smp_processor_id()); + + __sched_tick(); + + hrtimer_forward_now(timer, ns_to_ktime(PTICK_NSEC)); + + return HRTIMER_RESTART; +} + +static void ptick_rq_init(struct rq *rq) +{ + hrtimer_setup(&rq->ptick_timer, ptick, CLOCK_MONOTONIC, + HRTIMER_MODE_REL_HARD | HRTIMER_MODE_LAZY_REARM); +} #else /* !CONFIG_SCHED_HRTICK: */ static inline void hrtick_clear(struct rq *rq) { } static inline void hrtick_rq_init(struct rq *rq) { } static inline void hrtick_schedule_enter(struct rq *rq) { } static inline void hrtick_schedule_exit(struct rq *rq) { } +static inline void ptick_clear(struct rq *rq) { } +static inline void ptick_start(struct rq *rq) { } +static inline void ptick_ctx_switch(struct rq *rq, + struct task_struct *prev, struct task_struct *next) { } +static inline void ptick_rq_init(struct rq *rq) { } #endif /* !CONFIG_SCHED_HRTICK */ =20 /* @@ -5246,6 +5298,7 @@ static struct rq *finish_task_switch(struct task_stru= ct *prev) prev_state =3D READ_ONCE(prev->__state); vtime_task_switch(prev); perf_event_task_sched_in(prev, current); + ptick_ctx_switch(rq, prev, current); finish_task(prev); tick_nohz_task_switch(); finish_lock_switch(rq); @@ -5637,11 +5690,7 @@ static int __init setup_resched_latency_warn_ms(char= *str) } __setup("resched_latency_warn_ms=3D", setup_resched_latency_warn_ms); =20 -/* - * This function gets called by the timer code, with HZ frequency. - * We call it with interrupts disabled. - */ -void sched_tick(void) +void __sched_tick(void) { int cpu =3D smp_processor_id(); struct rq *rq =3D cpu_rq(cpu); @@ -5691,6 +5740,22 @@ void sched_tick(void) } } =20 +/* + * This function gets called by the timer code, with HZ frequency or + * PTICK_NSEC. We call it with interrupts disabled. + */ +void sched_tick(void) +{ + int cpu =3D smp_processor_id(); + struct rq *rq =3D cpu_rq(cpu); + + /* Skip HZ calls unless there are no tasks running when PTICK is enabled = */ + if (sched_feat(PTICK) && rq->nr_running) + return; + + __sched_tick(); +} + #ifdef CONFIG_NO_HZ_FULL =20 struct tick_work { @@ -9017,6 +9082,7 @@ void __init sched_init(void) rcuwait_init(&rq->hotplug_wait); #endif hrtick_rq_init(rq); + ptick_rq_init(rq); atomic_set(&rq->nr_iowait, 0); fair_server_init(rq); #ifdef CONFIG_SCHED_CLASS_EXT diff --git a/kernel/sched/features.h b/kernel/sched/features.h index 84c4fe3abd74..dcce2558ac21 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -73,6 +73,13 @@ SCHED_FEAT(HRTICK, false) SCHED_FEAT(HRTICK_DL, false) #endif =20 +/* + * Pseudo Tick. Triggers when tasks are running on CPU. sched_tick() will = run + * off of it when turned on. Will use regular TICK when no tasks are runni= ng or + * turned off. + */ +SCHED_FEAT(PTICK, false) + /* * Decrement CPU capacity based on time not spent running tasks */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9f63b15d309d..78ea50905331 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1297,6 +1297,8 @@ struct rq { ktime_t hrtick_time; ktime_t hrtick_delay; unsigned int hrtick_sched; + + struct hrtimer ptick_timer; #endif =20 #ifdef CONFIG_SCHEDSTATS @@ -3070,6 +3072,11 @@ extern unsigned int sysctl_numa_balancing_hot_thresh= old; =20 #ifdef CONFIG_SCHED_HRTICK =20 +/* PELT period is 1024us, add 1 to ensure one PELT period has passed */ +#define PTICK_USEC (sched_feat(PTICK) ? (long)(USEC_PER_MSEC * 1.025) : T= ICK_USEC) +#define PTICK_NSEC (sched_feat(PTICK) ? (long)(NSEC_PER_MSEC * 1.025) : T= ICK_NSEC) +#define PTICK_HZ (sched_feat(PTICK) ? 1000 : HZ) + /* * Use hrtick when: * - enabled by features --=20 2.34.1 From nobody Mon May 25 06:43:08 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 49BFD2F8EB4 for ; Sun, 17 May 2026 04:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990872; cv=none; b=dfiBr2DFHFZci7Hj0kQ6B9OpquQOd2pIyCeypQVwyTLvhPw3zJcjxFK5CaIgwIRCwckbl+T0zzH/7IaHqFhMXDHBIMOD1dmeyoEwcUCp9nEBHFYrbKxcBTnTIGHC8JZakPw+IipjSoQQMlO8ctW/mDAJ0doLLwNaRZAeZFR39k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990872; c=relaxed/simple; bh=Pn1AG/8zxHx29EpQWshnzUiBYTf2WCFgTA7U8i7sj7o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qLaqPZ2jDzrbtO6+vmDmnMzrow16tq7Hm3Fm1Kj5k/uhyB66Aaqo5aSeKk26l/dx5C1VtoEPOeSKq5md30aJ1ngpsTZ5Uz6CH0Yu8Q0EaP90xYOlEHKcXn/AvNV2aeCAIWcmpGhEelvZi5g6qNzy0pGVUaaMQW5tOj6edrrr4gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b=C0fh5UNe; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b="C0fh5UNe" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso11566335e9.3 for ; Sat, 16 May 2026 21:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20251104.gappssmtp.com; s=20251104; t=1778990870; x=1779595670; 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=8aUvtRhoHzg1yg2mA8CHEVvWi7uGp05sg/jRtMyYhkg=; b=C0fh5UNeHiPUnmgjItQ4cjCiahjjIrb+VYY8U7aN0TCIYvzdmj4htFw4DXaToC19uP xgZPiSJQPMAkKU3Ktcc54KBnH4U/eQXUhiQ/gVJVPhEvkQV74CwQ4+Uvm9aKKA+Fsqo1 7yGZ4Z4y94q5DnMIANdN0q65Pc9WKfZfZnENHkslk5ixPLebWLcRwpjeacuCvDuazZj3 R2k9315ORQsAZb+5SHGNOF+2qZSJ6zG5Am9kTvEp/ZUkvji/3BPQo31fFsSd79Y8dvLt JOg6IHEQonWXGJXLLCql00EhWksKxixUVMRqYVJEU1zzQEMlfnT9NJ98XztWyzb9FU9J WVMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778990870; x=1779595670; 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=8aUvtRhoHzg1yg2mA8CHEVvWi7uGp05sg/jRtMyYhkg=; b=ew7DRmW9EE7OCkeLtvDOZe2UN697J6L24OabxJOmwiJ8w0p/olo6fwFsYmmHO0He6x elhysEnpz9LHfr6iuhVokdBSfCl42st+GikVju3RWchyoCAl2cSddZ7yH8SM/quUw7i4 DQZp2jaG4x5wH9P8UZZmag2Gi4AUCPFuZl7kId0q1ZWWmyCFtAmjb7g3hstttVHw7+Bm jbhfBCGKHr4uROiBvCGlEZQDBusjEmas5czTRXR+bk7k4iNzAsvZ+BXP8BCzlVbcrTdy BSVaiBKIV/k4YUW3tb7QkKxOTJig/FKixAq1itd8t1gSJ4wod0NnHweQMUyT+G+vTLwQ 2/XA== X-Forwarded-Encrypted: i=1; AFNElJ/giWUk1bYswRoQO3kcnQt3aHFLO9rQ5EsSTFnZ7+GGYUJbBboI/mGZgcDfvb8C73ELHoHk9d4y5fvnhNA=@vger.kernel.org X-Gm-Message-State: AOJu0Ywt5Gi6IAj+AyKpzWLp486vvceI/c6f6tZN3Mmm+Ai8oDMNSdhG efAmKKqxI3G+3wTV2kNBhSlsXm0DwNH8BbxTuc4xaYkVkwxb8Lg9WZGK9WSxw5Fbijw= X-Gm-Gg: Acq92OF6ObwfZVOwmK9OMceiJUfJp+Vs7rjFwd2jBVMsMvRKJWfD8l2tfnAZqvbEhn2 NTRh99THJAidAyc+y5y33isC06ou8U4w1CRSG72fHpt7Tguwb71hzkt2HgkOot265GoTxF3cVMc Y3T0GK8mExW49NWgm94U/2Q6EB8PnbeUsAOVrUSx6LQhO4Mq1K9TQpVg5U3kP53nMvFYtjtzoCw YYbTbZNNh89svXp89e/GKSqxvePDVQL/bS0lSt/wesxBrMt7szUVnKcbj7f0zRDhAHPm+npE938 ejopyC122tKhkOX/dlSwJs54pTbcVkJSDF7z0snSSW0MDOysmHPN+xhoYPyodl/rYS0gmX5pp0a bjKlBeDDd3EFOF7Rg9a8PHvE2G00RUTO0FSofIzvEvDm6FYDN/aUvldsuNzwID/iJS2vo503hHM OXtBnRVyKcS287MZWcq1SnD9XzoqJC X-Received: by 2002:a05:600c:c10b:b0:48f:d612:3c59 with SMTP id 5b1f17b1804b1-48fe60eb0f6mr97071555e9.9.1778990869703; Sat, 16 May 2026 21:07:49 -0700 (PDT) Received: from airbuntu.. ([149.40.48.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe5ab3977sm184754395e9.9.2026.05.16.21.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 21:07:49 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot Cc: Juri Lelli , Steven Rostedt , John Stultz , Thomas Gleixner , Frederic Weisbecker , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH 2/3] sched/tick: Move TICK_NSEC users to PTICK_NSEC Date: Sun, 17 May 2026 05:07:39 +0100 Message-Id: <20260517040740.444729-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517040740.444729-1-qyousef@layalina.io> References: <20260517040740.444729-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Leave users in cputime.c and numa related load balance hooked to actual TICK_NSEC. But the remainder of the references in kernel/sched were converted to PTICK_NSEC. Signed-off-by: Qais Yousef --- kernel/sched/clock.c | 4 ++-- kernel/sched/cpufreq_schedutil.c | 2 +- kernel/sched/fair.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 2ae4fbf13431..a331d9f47107 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -282,13 +282,13 @@ static __always_inline u64 sched_clock_local(struct s= ched_clock_data *scd) /* * scd->clock =3D clamp(scd->tick_gtod + delta, * max(scd->tick_gtod, scd->clock), - * scd->tick_gtod + TICK_NSEC); + * scd->tick_gtod + PTICK_NSEC); */ =20 gtod =3D scd->tick_gtod + __gtod_offset; clock =3D gtod + delta; min_clock =3D wrap_max(gtod, old_clock); - max_clock =3D wrap_max(old_clock, gtod + TICK_NSEC); + max_clock =3D wrap_max(old_clock, gtod + PTICK_NSEC); =20 clock =3D wrap_max(clock, min_clock); clock =3D wrap_min(clock, max_clock); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedu= til.c index ae9fd211cec1..d06527cf8d21 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -252,7 +252,7 @@ static bool sugov_iowait_reset(struct sugov_cpu *sg_cpu= , u64 time, s64 delta_ns =3D time - sg_cpu->last_update; =20 /* Reset boost only if a tick has elapsed since last request */ - if (delta_ns <=3D TICK_NSEC) + if (delta_ns <=3D PTICK_NSEC) return false; =20 sg_cpu->iowait_boost =3D set_iowait_boost ? IOWAIT_BOOST_MIN : 0; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 728965851842..2f8ed2eee2d7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -601,7 +601,7 @@ static inline bool entity_before(const struct sched_ent= ity *a, * and this value should be no more than two lag bounds. Which puts it in = the * general order of: * - * (slice + TICK_NSEC) << NICE_0_LOAD_SHIFT + * (slice + PTICK_NSEC) << NICE_0_LOAD_SHIFT * * which is around 44 bits in size (on 64bit); that is 20 for * NICE_0_LOAD_SHIFT, another 20 for NSEC_PER_MSEC and then a handful for @@ -822,7 +822,7 @@ static inline u64 cfs_rq_max_slice(struct cfs_rq *cfs_r= q); * is possible -- by addition/removal/reweight to the tree -- to move V ar= ound * and end up with a larger lag than we started with. * - * Limit this to either double the slice length with a minimum of TICK_NSEC + * Limit this to either double the slice length with a minimum of PTICK_NS= EC * since that is the timing granularity. * * EEVDF gives the following limit for a steady state system: @@ -831,7 +831,7 @@ static inline u64 cfs_rq_max_slice(struct cfs_rq *cfs_r= q); */ static s64 entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 = avruntime) { - u64 max_slice =3D cfs_rq_max_slice(cfs_rq) + TICK_NSEC; + u64 max_slice =3D cfs_rq_max_slice(cfs_rq) + PTICK_NSEC; s64 vlag, limit; =20 vlag =3D avruntime - se->vruntime; --=20 2.34.1 From nobody Mon May 25 06:43:08 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 F321D33C195 for ; Sun, 17 May 2026 04:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990877; cv=none; b=g5dzIuZqAdLi81X3gxT6PnHnA38llqI+ZVfIm2S0Smwyjh16vqhwqkSIj6jEmXz2VzLJo/uAQ5P0r81Yyl/SU93yaZijt02cvcyZiJhI+6LL1sPf0x+TgYQ+3QDsPxzLAUDzzUe3pTXfG2yz7TIDjGq1ZYwy34tigoMUUX3U6Hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778990877; c=relaxed/simple; bh=niQ9EKaM36qzgLaR26LDLqlHO/kbl5TnJfaIxPXUBOw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rFF8RjkxdVJbL/VEePK6NS76I14MQ93aUVbp41SZeq/bcHfvU9t1M0IWR8IPoV+ZT2XuPiLz0JXK6sWmx2qY3439xaVtdBb8LgHPz78mcCEviS3+HcwlXHfInOV0ZSxvd1XAiomE2ixhVD/ZehgyOjOWoR54jWMAwRU9t/f6Dhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b=OAH3oVIt; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20251104.gappssmtp.com header.i=@layalina-io.20251104.gappssmtp.com header.b="OAH3oVIt" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-48984d29fe3so11942525e9.0 for ; Sat, 16 May 2026 21:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20251104.gappssmtp.com; s=20251104; t=1778990872; x=1779595672; 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=UtRHkHaL9HXpEFRceEmN1veeUrW/oZDP5i2CNpumZ9Q=; b=OAH3oVItQNY2mi67D7xH+aMn3P0o/5xZkSnHIOKGHfbD4ELT3RUdcZa1s7ftiat1s+ AUazVcB2dNLjTfaiK3CzXdggSJYDYS5AjRltyMFMPnCWFFaztAtR+yVrSppCrYMVumEB S9BusZkp7YN0xgox1Fva60eamVE3pjVMfxYbXFbv3mb8/IGXXWIjjH9R/dOJ30tb+tbB hApq5+uzq67B3j+aFLrv4NhJ0wpGdJkaoIXEKoVta3/Y21ell45GMjKQtkaBgK+oG4uG 0/4C/SlfmqWBJ8FoGeGh97zmg4tgvNbAJq3g+MnzhyH8qRJIABAoCN4p8YbnWvuRJcQF /Rgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778990872; x=1779595672; 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=UtRHkHaL9HXpEFRceEmN1veeUrW/oZDP5i2CNpumZ9Q=; b=ACbg2G7XKihZkDL+VpyoUJnnoRVEFowDqixuI/kaGMsaqhn2KFSU0WCrdGfS958HdD eYZO5+AZiNv2l7OYF3l2nZmuigcZ5RepIVRND52VIrayKY2aY8cYS+SUVcAtKctXh/Zk EQ0i+4Qyzo3XDZMykn+EEb/aNxKVOIUyeQDYvev9hfyvOl0NcOyZGb/lbZ9Zc1UiGe0D vEpTVqu89fDKbz0PCu0D27eHxzrZae12LV5G2KDrh1tUxQJ7diFeWoDbKVoJFmm+vhZU gNUPjhG2cDInnNOIeaTMnuV8y/+VW6IHpFFeGTF1vnj6LHbeZjTYTdxAibT0HxoHmr1y nPUQ== X-Forwarded-Encrypted: i=1; AFNElJ/sutMWOZv9DZf6fpam0ik1qLieJA1NeKmlSIOZ4QrW6tJmJkmLFR5dK0n5SSQiCHe00dMZ/AVyEhjFn6U=@vger.kernel.org X-Gm-Message-State: AOJu0YzbXFQ0Y85kgiTCa6UYo3D7NIkGA7ZLpEnbGMFX486Ro33JQBUt fF6TmZGBwXZ0peJeoHxqUoi3NXjip+tVXe+mFAUd7M2Ez5qOGrMZezzm90atD6GCIlU= X-Gm-Gg: Acq92OFPnjG6LMk55g90ATucY1YirSVh/MDcKRlKwliiCsTXCKqG+Q3uIvEmXkp5KqS Mp4zf3/rUYHftce0dLClVT6nJvqM1tU/1gM1kKnPaW8ZYNv0rF4SRd05zn+vW6oF+50OVADZmGb wZjWBSgvBc+r92YLZRoaD8iwhxCx149erwe30rrq+tapKmu1fPYhT5z/46hSMhvbX8S6t/9Ao3M y6ivYuLsIumfzfYvMNt2QYXwiXkoli3vYuM7YahoR64E4qPDJe382ZzjowFQP0BNBg03IJzpmuw eq6sbBW48e2d5CN6eME+sGl0ewxPEE3nhLtckEfad9tZcwvEJxIaiBxGsThom0ZyFs0a/nkjuHb ysdhSCUXpy/SWl05wWN9dJqf1ObR3ZyvO2uzUU5WThFHzhwc6Q/w0/iHOILRN9gCiQFVODc8aT3 NOERvelTjyrdsQyKJ3Zw== X-Received: by 2002:a05:600c:c167:b0:48f:d410:6065 with SMTP id 5b1f17b1804b1-48fe66138dfmr144642395e9.29.1778990872408; Sat, 16 May 2026 21:07:52 -0700 (PDT) Received: from airbuntu.. ([149.40.48.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe5ab3977sm184754395e9.9.2026.05.16.21.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 21:07:50 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot Cc: Juri Lelli , Steven Rostedt , John Stultz , Thomas Gleixner , Frederic Weisbecker , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH 3/3] sched/tick: Turn on PTICK by default Date: Sun, 17 May 2026 05:07:40 +0100 Message-Id: <20260517040740.444729-4-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517040740.444729-1-qyousef@layalina.io> References: <20260517040740.444729-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While load balancer is still hooked to actual TICK, but the few users that relied on TICK_NSEC were converted and we should be able to switch this on by default. Yet to be seen load balancer conversion would be necessary if push load balancer is merged soon. Signed-off-by: Qais Yousef --- kernel/sched/features.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/sched/features.h b/kernel/sched/features.h index dcce2558ac21..4db90a266ce8 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -68,17 +68,18 @@ SCHED_FEAT(WAKEUP_PREEMPTION, true) #ifdef CONFIG_HRTIMER_REARM_DEFERRED SCHED_FEAT(HRTICK, true) SCHED_FEAT(HRTICK_DL, true) -#else -SCHED_FEAT(HRTICK, false) -SCHED_FEAT(HRTICK_DL, false) -#endif =20 /* * Pseudo Tick. Triggers when tasks are running on CPU. sched_tick() will = run * off of it when turned on. Will use regular TICK when no tasks are runni= ng or * turned off. */ +SCHED_FEAT(PTICK, true) +#else +SCHED_FEAT(HRTICK, false) +SCHED_FEAT(HRTICK_DL, false) SCHED_FEAT(PTICK, false) +#endif =20 /* * Decrement CPU capacity based on time not spent running tasks --=20 2.34.1