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 A5E292153FA for ; Thu, 9 Jan 2025 10:22:22 +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=1736418145; cv=none; b=EdZYdF4GypnpfnZPLL4UmWvJokpFG0an5yAZwKUakwKSCNQGl/JFJu7Ld/HSuP/PM5FrfzW60fYtkIx4+NPoxpUHUPbBvZpfz7AxKeBq1WnYbfOmtWAJm7CF783dwfq+puRhGeRVb0/+dtTcP11WvDV/0/bDwixGoGRxRRRerk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736418145; c=relaxed/simple; bh=dspqxObliRfvQ/hlYCxHi05RrHbmDMxNzDYLg2kO3dE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g/KC+8VCaGJ/45GG+5MNAwaD/BLGGtT2/FKjoZo8YbyxQXyUnd5MKr+hMZmz5yIj1qxJghGAfT8rlMFlKkXJ6TgGsb3XoK/xVvfj1kCeekda7wk0Ge0w/T1tWS6Ak5BFKEe+zdD91UpONZOKrjVrjyq4gIw/TFZOmkd+CdZkFb4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (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=bK08m2TT; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="bK08m2TT" 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=BLL1ksbVZk8Jo7bWQs1WNTdRSXr9ujyx7ZxROj5Gsfg=; b=bK08m2TTqD/TvrqRdqmsMDoIz9 uHGIKQSynpQxMsJtp76xWyXijWB1ZcnydtfnHt0YidNPyJH5lOvZZhjHDRHXxfucWEO/ato64pxEg 7WBLdI+fX+gw8jvp5aDQx3Z1l51vhBLAW6Y+paAVuRSuDbNtGOmkAi8P94Tz7p6nYLBqUsKqbaZ5e sUERqtUrCXGZciARQXilSSoh4HGUQn9IbqDSPavsJ8ggrNHhyiXwhR1wEOpXszeD6q3GU7Ndpdj8o iW20PXwkny/6FdiAXDMvRxHFZo1h0AC9vnEPScxJs4bfkT3OScIsCDhUfls0FZcxiIqGuFobjH8V+ AQ6cexEg==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tVpg5-00000009Xt9-1QP1; Thu, 09 Jan 2025 10:22:13 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id EA24B30057C; Thu, 9 Jan 2025 11:22:12 +0100 (CET) Date: Thu, 9 Jan 2025 11:22:12 +0100 From: Peter Zijlstra To: Andrea Righi Cc: Tejun Heo , David Vernet , Changwoo Min , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5] sched_ext: Refresh scx idle state during idle-to-idle transitions Message-ID: <20250109102212.GR20870@noisy.programming.kicks-ass.net> References: <20250109101952.443769-1-arighi@nvidia.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: <20250109101952.443769-1-arighi@nvidia.com> On Thu, Jan 09, 2025 at 11:19:52AM +0100, Andrea Righi wrote: > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > index 621696269584..ffc636ccd54e 100644 > --- a/kernel/sched/idle.c > +++ b/kernel/sched/idle.c > @@ -452,19 +452,33 @@ static void wakeup_preempt_idle(struct rq *rq, struct task_struct *p, int flags) > static void put_prev_task_idle(struct rq *rq, struct task_struct *prev, struct task_struct *next) > { > dl_server_update_idle_time(rq, prev); > - scx_update_idle(rq, false); > + scx_update_idle(rq, false, true); > } > > static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool first) > { > update_idle_core(rq); > - scx_update_idle(rq, true); > + scx_update_idle(rq, true, true); > schedstat_inc(rq->sched_goidle); > next->se.exec_start = rq_clock_task(rq); > } > > struct task_struct *pick_task_idle(struct rq *rq) > { > + /* > + * The scx idle state is updated only when the CPU transitions > + * in/out of SCHED_IDLE, see put_prev_task_idle() and Idle thread != SCHED_IDLE > + * set_next_task_idle(). > + * > + * However, the CPU may also exit/enter the idle state while > + * running the idle task, for example waking up the CPU via > + * scx_bpf_kick_cpu() without dispatching a task on it. > + * > + * In this case we still need to trigger scx_update_idle() to > + * ensure a proper management of the scx idle state. > + */ > + if (rq->curr == rq->idle) > + scx_update_idle(rq, true, false); > return rq->idle; > } > > -- > 2.47.1 >