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 B267A2C21C6 for ; Thu, 4 Dec 2025 11:29:55 +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=1764847798; cv=none; b=uVsFXTMA7CstuKv+KgI68OiQBCnko2V7yw757716Rz/gkRdDCjHHCEyCEABfzKigylqP+c6hIjBfmfXVpFIBG56a0UzTB0YVwfNdkBJC75GzmJYX9PqOdEY4dMjFVGYwbKMzxI3wFzghLVVVqQDWnRm8WlL306moMBUACqZMBQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764847798; c=relaxed/simple; bh=FwVT8bvyYD1+fC6WMsLrQ80x6d1coQOAd7AAc/kJMng=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FLxz1Q8qrrMjO1qtohzjRIQN8e3vTUw0hSwH8lqICdtvbWNaPZolWmcn1MhRXayzmNVGTYCwUA3orVSRX6YR1Gx1Ls6tB60Nzaat4ME2HNpwinXnOUUkLT3r8YzWOQMSlurmXu5CWwcebC/CMQ+1dNFAVo8uAn3h5pPgPBHWDC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (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=G+4t5UEp; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (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="G+4t5UEp" 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=CHDOu01Y5n54BMecfO+4h0WDmvVCfpk3Ri2pXxPUnqA=; b=G+4t5UEpH/9nz9Mfs5oThVcuz3 4gtc5OqDr8YNjk16bQfvV+kmlOIPL5KKkxv3eAu6FK1yJ/bb75Mx8Cmp6SrQ+I3kROXq2CCTaGRI/ R88BG5IAXNnFq/qW0IEDO9jrxeWzMSzf2MD6hfBsM64+K0407tRBLBJ7JTT/CuB7zkusCJzmRe0IQ dmiVYdtzkmILJcHFfbjg9qpXc9mhYFDWP0FjfJJ6YZl0A/Vsm0/239Z28Qrg0N9EMLDGkYt0fdK8d YvpRM24K8ZC+LjqE+UQ9kSoJAH2ViWLzZuY1Eqg5vAaVMpkatJsc0pw4aoXeZ39y4YyKT2Ow+R633 uSa56YqQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vR6fM-00000003uzA-35I9; Thu, 04 Dec 2025 10:34:29 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id F16BD3004B8; Thu, 04 Dec 2025 12:29:47 +0100 (CET) Date: Thu, 4 Dec 2025 12:29:47 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: mingo@redhat.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, pierre.gondois@arm.com, kprateek.nayak@amd.com, qyousef@layalina.io, hongyan.xia2@arm.com, christian.loehle@arm.com, luis.machado@arm.com Subject: Re: [PATCH 4/6 v8] sched/fair: Add push task mechanism for fair Message-ID: <20251204112947.GK2528459@noisy.programming.kicks-ass.net> References: <20251202181242.1536213-1-vincent.guittot@linaro.org> <20251202181242.1536213-5-vincent.guittot@linaro.org> 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: <20251202181242.1536213-5-vincent.guittot@linaro.org> On Tue, Dec 02, 2025 at 07:12:40PM +0100, Vincent Guittot wrote: > +/* > + * See if the non running fair tasks on this rq can be sent on other CPUs > + * that fits better with their profile. > + */ > +static bool push_fair_task(struct rq *rq) > +{ > + struct task_struct *next_task; > + int prev_cpu, new_cpu; > + struct rq *new_rq; > + > + next_task = pick_next_pushable_fair_task(rq); > + if (!next_task) > + return false; > + > + if (is_migration_disabled(next_task)) > + return true; > + > + /* We might release rq lock */ > + get_task_struct(next_task); > + > + prev_cpu = rq->cpu; > + > + new_cpu = select_task_rq_fair(next_task, prev_cpu, 0); > + > + if (new_cpu == prev_cpu) > + goto out; > + > + new_rq = cpu_rq(new_cpu); > + > + if (double_lock_balance(rq, new_rq)) { > + /* The task has already migrated in between */ > + if (task_cpu(next_task) != rq->cpu) { > + double_unlock_balance(rq, new_rq); > + goto out; > + } > + > + deactivate_task(rq, next_task, 0); > + set_task_cpu(next_task, new_cpu); > + activate_task(new_rq, next_task, 0); > + > + resched_curr(new_rq); > + > + double_unlock_balance(rq, new_rq); > + } Why not use move_queued_task() ? > + > +out: > + put_task_struct(next_task); > + > + return true; > +} > + > +static void push_fair_tasks(struct rq *rq) > +{ > + /* push_fair_task() will return true if it moved a fair task */ > + while (push_fair_task(rq)) > + ; If we're going to be looping on that, why not also loop in pick_next_pushable_task() like: list_for_each_entity(p, &rq->cfs.pushable_tasks, pushable_tasks) { if (!is_migration_disabled(p)) { list_del(&p->pushable_tasks); return p; } } return NULL; Because as is, I think you'll fail the moment there's a migrate_disable() tasks at the head of things.