Re: [PATCH v2 4/5] sched: Add task enqueue/dequeue trace points
From: Peter Zijlstra <peterz@infradead.org>
Date: 2025-08-19 08:24:51
Also in:
lkml
On Tue, Aug 19, 2025 at 09:49:20AM +0200, Nam Cao wrote:
On Fri, Aug 15, 2025 at 03:40:16PM +0200, Peter Zijlstra wrote:quoted
On Wed, Aug 06, 2025 at 10:01:20AM +0200, Nam Cao wrote:quoted
+/* + * The two trace points below may not work as expected for fair tasks due + * to delayed dequeue. See: + * https://lore.kernel.org/lkml/179674c6-f82a-4718-ace2-67b5e672fdee@amd.com/ (local) + */quoted
+DECLARE_TRACE(dequeue_task, + TP_PROTO(int cpu, struct task_struct *task), + TP_ARGS(cpu, task)); +quoted
@@ -2119,7 +2121,11 @@ inline bool dequeue_task(struct rq *rq, struct task_struct *p, int flags) * and mark the task ->sched_delayed. */ uclamp_rq_dec(rq, p); - return p->sched_class->dequeue_task(rq, p, flags); + if (p->sched_class->dequeue_task(rq, p, flags)) { + trace_dequeue_task_tp(rq->cpu, p); + return true; + } + return false; }Hurmpff.. that's not very nice. How about something like: dequeue_task(): ... ret = p->sched_class->dequeue_task(rq, p, flags); if (trace_dequeue_task_p_enabled() && !(flags & DEQUEUE_SLEEP)) __trace_dequeue_task_tp(rq->cpu, p); return ret; __block_task(): trace_dequeue_task_tp(rq->cpu, p); ... Specifically, only DEQUEUE_SLEEP is allowed to fail, and DEQUEUE_SLEEP will eventually cause __block_task() to be called, either directly, or delayed.Thanks for the suggestion, this makes sense. From my understanding, it makes the tracepoints work correctly for fair tasks too, so I will get rid of the comment.
Just so indeed :-)