From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sg-1-105.ptr.blmpb.com (sg-1-105.ptr.blmpb.com [118.26.132.105]) (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 3774B342CAD for ; Wed, 21 Jan 2026 03:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.105 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768967411; cv=none; b=R6axoadYwhDQc43Oq8UpONAKd2Y4WRvBLk/0+5gHiPD+5IDAGRWSbtwANzHDUafo3lXkGceVGdQcx0FHniJ85a6xDt3lRL65ZxDZCI3wPXkhds6RPXpRmQ4xIvtu+uVsVove+Zrr3BzdjDxVw/WbMAGwBhaT3bUPcLj8MNz1SpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768967411; c=relaxed/simple; bh=1CFrTy71+AS7opuJbsVJeHL6vjmHuwsAYBD2W9gPWTA=; h=Content-Disposition:References:Content-Type:To:Date:Mime-Version: In-Reply-To:Subject:Message-Id:Cc:From; b=bbc5hdr+2Oj24b2kfmuR+vUsXg3U2fagnGBip3sAn2PDzAA5+lUGJz7iIRJdeeUTrwOI1gHBmo5s0m0fi7FfO5OjlZrdmMDhlelTFfsfBAvcYMSCjMpqS1m/K01nulwZBc2FA1nDGsp7Vqc9GvzadvvgwHQyFdlLMOB/5bblx60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=ZJpdN08B; arc=none smtp.client-ip=118.26.132.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="ZJpdN08B" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1768967391; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=kFNzl/Dc2vNEz2rtweMtF9O7TIwtuVdVh4rPtGE7m/s=; b=ZJpdN08BHO/jwpybkZ9HLRwkjETgnn9sc/IP+78myqCg2cSB50XqMZrfbVEAJ53cnoLyzT 7YGjaZduap2EKoXVW1yk3ul8z3ZW2zEAgu87xspb1tUu36PiKyIfbAHJcYWFSktZXlBW9+ oX10sb9OARrNvLTG1z32ySQ9KmxPsAkx6wNkU1wrm5Rb82ji9jkqt1FAkP/5sYVXfa+BK7 GoEiSNTjjO37upeG9Yo3tUnM99HavQYOFFVK7HWEAxIr5gF6QcPuzmJmRl0/31R5XX2f8X wCmBqDakYCklZZbcbYV+EPnP2gJ6a5sVLwKst2L6v7LpCa8vXBF3RdQy+YVf8w== Content-Disposition: inline References: <20260120032549.186733-1-quzicheng@huawei.com> Content-Type: text/plain; charset=UTF-8 X-Lms-Return-Path: To: "Zicheng Qu" Date: Wed, 21 Jan 2026 11:49:18 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 In-Reply-To: <20260120032549.186733-1-quzicheng@huawei.com> X-Original-From: Aaron Lu Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] sched: Re-evaluate scheduling when migrating queued tasks out of throttled cgroups Message-Id: <20260121034918.GA1303836@bytedance.com> Cc: , , , , , , , , , , , , , , From: "Aaron Lu" On Tue, Jan 20, 2026 at 03:25:49AM +0000, Zicheng Qu wrote: > Consider the following sequence on a CPU configured with nohz_full: > > 1) A task P runs in cgroup A, and cgroup A becomes throttled due to CFS > bandwidth control. The gse (cgroup A) where the task P attached is > dequeued and the CPU switches to idle. > > 2) Before cgroup A is unthrottled, task P is migrated from cgroup A to > another cgroup B (not throttled). > > During sched_move_task(), the task P is observed as queued but not > running, and therefore no resched_curr() is triggered. > > 3) Since the CPU is nohz_full, it remains in do_idle() waiting for an > explicit scheduling event, i.e., resched_curr(). > > 4) Later, cgroup A is unthrottled. However, the task P has already been > migrated out of cgroup A, so unthrottle_cfs_rq() may observe > load_weight == 0 and return early without resched_curr() called. I suppose this is only possible when the unthrottled cfs_rq has been fully decayed, i.e. !cfs_rq->on_list is true? Because only in that case, it will skip the resched_curr() in the bottom of unthrottle_cfs_rq() for the scenario you have described. Looking at this logic, I feel the early return due to (!cfs_rq->load.weight) && (!cfs_rq->on_list) is strange, because the resched in bottom: /* Determine whether we need to wake up potentially idle CPU: */ if (rq->curr == rq->idle && rq->cfs.nr_queued) resched_curr(rq); should not depend on whether cfs_rq is fully decayed or not... I think it should be something like this: - complete the branch if no task enqueued but still on_list; - only resched_curr() if task gets enqueued diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e71302282671c..e09da54a5d117 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6009,9 +6009,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) /* update hierarchical throttle state */ walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq); - if (!cfs_rq->load.weight) { - if (!cfs_rq->on_list) - return; + if (!cfs_rq->load.weight && cfs_rq->on_list) { /* * Nothing to run but something to decay (on_list)? * Complete the branch. @@ -6025,7 +6023,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) assert_list_leaf_cfs_rq(rq); /* Determine whether we need to wake up potentially idle CPU: */ - if (rq->curr == rq->idle && rq->cfs.nr_queued) + if (rq->curr == rq->idle && cfs_rq->nr_queued) resched_curr(rq); } Thoughts? > At this point, the task P is runnable in cgroup B (not throttled), but > the CPU remains in do_idle() with no pending reschedule point. The > system stays in this state until an unrelated event (e.g. a new task > wakeup or any cases) that can trigger a resched_curr() breaks the > nohz_full idle state, and then the task P finally gets scheduled. > > The root cause is that sched_move_task() may classify the task as only > queued, not running, and therefore fails to trigger a resched_curr(), > while the later unthrottling path no longer has visibility of the > migrated task. > > Preserve the existing behavior for running tasks by issuing > resched_curr(), and explicitly invoke check_preempt_curr() for tasks > that were queued at the time of migration. This ensures that runnable > tasks are reconsidered for scheduling even when nohz_full suppresses > periodic ticks. > > Fixes: 29f59db3a74b ("sched: group-scheduler core") > Signed-off-by: Zicheng Qu > Reviewed-by: K Prateek Nayak I haven't been able to reproduce this but the change looks reasonable to me, so: Reviewed-by: Aaron Lu