From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 C71CE279DB1 for ; Wed, 26 Aug 2026 04:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787716848; cv=none; b=HUQYNb7ou6RXuWhWP6dTvL5dLFl2oLTzdwWyqWn49WUP+dNM7Hg/PfECgSEXjs7UsZITXuhjv4qrNA2TjUdra/bFhjDS1x4qROe2ZDpV/deBO9FM61/VDqydaJyskBxjDfiBVXqoZp4MKYcF7C66mwrSi++289Y07F/WhOemcsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787716848; c=relaxed/simple; bh=iRkAQwXdnunTwwOr8Pcv46cwXYDPlva0tFdLTymCGG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ch94AaUaaeSsoAoGDMfD8g5CAXNLLDi1P3UFCOARUMm7VSYID5jvxkFHICbPT/EB1hav/XHEtesYRD5w4exByhbKV/snINoEzFoV/h/vLebyLNJvSLEuQteyWYV5DRjZGM3DateLWeRgQRlZ5nJqlPaQTFUvXc/VdDVAhWTDi6c= 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=cAlT9Jm/; arc=none smtp.client-ip=209.85.216.54 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="cAlT9Jm/" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3964dfb5b9aso784530a91.1 for ; Tue, 25 Aug 2026 21:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787716846; x=1788321646; 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:content-type; bh=Xj2hgCeQjnn0PgiipSyXtUibXQepu9keclbW+JUqDZU=; b=cAlT9Jm/YmHaLj9D05x4CooDxnvfwXKJtoZILprnoPAKrqiavEi2Ls9F4AfAH4eceS u5ghbBSk+Dv3O1mhzWoFWHHh6VvTf03aY8I+Ge7tvZc9Zj6nScsLlMRYecbEEWGYF4Tv qVizBQGSStqoHxwrYfXOeY8m89IjgjqdB2M9D4c7ymhJ1vZeZecQWq+L2zNAcuyilchD thGA2YbRTlQY8M1r/y4fLm1xwihvlzZ6N4m9QwKsE5p63PQfBaX7bte/gHZortqIiJZv Mmqc/N20pTfAj8x1EOv9a8KvfcfHGlDKjhPaPBpfb56dQaVW1Ua4+ANK+WjsFys4ycc9 4TtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716846; x=1788321646; 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:content-type; bh=Xj2hgCeQjnn0PgiipSyXtUibXQepu9keclbW+JUqDZU=; b=c3mwC4gyBWkikYx1ZzQNo7B51N/2RTIK8cs1Vy3w2t0j4csE+ZsNMh2VGof2HdFVUW Ur1osVS754K9aLpJTuIaPNK6j5iAXYyL9Hti7eVOuC/YyETW+WAbbrlm4Dy+c8HMMp7s cm7AosFJUJUwZOCWbzJHYYja3Ybx5maKBdUgDvS7QjcVUPJpeBvSVtM22eQt1w1hwx8d msPhSeIixhlS0rQewymkqU4l6j/Vir+X+iIZqIjpblGhwmbgc4Jl/HWk2TXwuN/rO3vj C5oAjCd/px399rZZDK4FdS1ZYvtuWpT7rBYx7qz7BlQBSA4iRAItxn0A/20RD8zeECaT Ceng== X-Forwarded-Encrypted: i=1; AHgh+RrX0Fl4v449CbSB6nw92Mb71+Hb0EJD+X6oyKzDVBjv2S0K2TtE3Jq7Kqq6+0N3ZgHCzniLdJyDd8SR2Vs=@vger.kernel.org X-Gm-Message-State: AFuF++kp3gKkTx2xwcnZcDtwZJPrtYOGaMpHtLqpSoNXmrAf50kaKWyt dbWXXUOwa2C+h+skMgxdZkEOJBHtuMKYFHGKSApIKAqg2YC357KRWfbb X-Gm-Gg: AR+sD12dGJ4uSXhQHqyL8cupGImYrgy5/xVFwOUryvIXrczpaiyh3GMKSnOvngTxnSr iigrCBk6Th2by9+VOGq61cV68jvHEg9QXqrMTFbY6dueONieqtJgLxWGdQVV9wQGZz9MaXd34nK TPGrpZGadX2aLQ/cW/Skkxte9zOSYH1UyCXdOFz0obo6ECYM/a1RHWsBmukGEODuqMau3dYoNtC KD1/Fo49Pg60VHM606xpjuJKJBA0YWkUv685DrGTKo96eKQH7zZnaCQUwlmq6nHNN6BhBfaceK2 TyzsH4tuqGl/5Wlw5TaLiPIGDabbDVxbgPYOSwqtbwGn6uxYuHaW70iFPIsEA5GTHXs3s328aIT A7ZYLaaP+jEhwbJ8+wtEt8JGKlFvtGS15XvGl4PvGcxmgyeUBml9g03FAN64z5ixGHMqe4aMaR+ S9s4kBpwOenlZYjFAdgKO53QxSYVOoOt/aj73MJ9K3pvCVUITMBiuUsCkPJrjSyzajcuIdX3zme npI7JlKqsJ1+eE= X-Received: by 2002:a17:90b:390a:b0:396:5785:843 with SMTP id 98e67ed59e1d1-3966d203a94mr6882053a91.8.1787716846059; Tue, 25 Aug 2026 21:00:46 -0700 (PDT) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396689f1419sm2213142a91.9.2026.08.25.21.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:00:45 -0700 (PDT) From: Zhan Xusheng To: sh@gentwo.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, shubhang@os.amperecomputing.com, cl@gentwo.org, linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com Subject: Re: [PATCH] sched/fair: Restart hrtick after same-task repicks Date: Wed, 26 Aug 2026 12:00:37 +0800 Message-ID: <20260826040037.201697-1-zhanxusheng1024@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260813-sched-fair-hrtick-restart-v1-1-4230d1e18fbb@gentwo.org> References: <20260813-sched-fair-hrtick-restart-v1-1-4230d1e18fbb@gentwo.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhan Xusheng On Thu, 13 Aug 2026 14:23:48 -0700, Shubhang Kaushik (Ampere) wrote: > + rq->hrtick_rearm_fair = hrtick_enabled_fair(rq) && > + rq->cfs.h_nr_runnable > 1 && > + rq->cfs.h_nr_runnable == rq->cfs.h_nr_queued; The last term switches the fix off whenever anything on the rq sits in delayed dequeue. set_delayed() decrements h_nr_runnable and leaves h_nr_queued alone (kernel/sched/fair.c:6398), clear_delayed() puts it back (6418), so the two differ exactly while a delay-dequeued entity is present. With DELAY_DEQUEUE that is routine, and it says nothing about whether the running task still needs its slice bounded. Your test cannot show that either way: two CPU-bound tasks pinned to one CPU never sleep, so nothing is ever delay-dequeued there and the term is true for the whole run. Adding a third task that sleeps in a loop should bring the missed hrtick back while the term is false. If the intent is only to skip rqs whose other queued entities are not competing for the CPU, h_nr_runnable > 1 already says that by itself. > +static inline void hrtick_rearm_fair(struct rq *rq, struct task_struct *p) > +{ > + if (rq->hrtick_rearm_fair) > + __hrtick_rearm_fair(rq, p); > +} What does the rq field buy? __hrtick_rearm_fair() already tests hrtick_enabled_fair(), hrtick_active() and the class, and a same-task repick that finds no hrtick armed wants one regardless of what triggered the repick. If there is a same-task repick that must not arm one, the changelog is the place to name it. Last one is only a question. entity_tick() -> update_curr() -> update_deadline() has already pushed se->deadline by a slice before task_tick_fair() reaches the queued branch, so hrtick_start_fair() would compute a valid delay if called right there, with no new field and no change to put_prev_set_next_task(). The difference I can see is that the tick callback runs with rq->hrtick_sched == 0, so hrtick_start() would program the hrtimer immediately from inside its own callback instead of leaving it to hrtick_schedule_exit(). Is that what moved you to the pick side? Thanks, Zhan Xusheng