From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 05AF43ACA6C for ; Thu, 6 Aug 2026 18:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786041493; cv=none; b=oCP1ZKXU/JK//YrkuQvJ7c0OLar9+oZMCtybmmZaCCPvnCQIoAyVHAjBGEKd2dXoQkk0gqTPVBZpDDILqOgLPhDRDnnQFsJOh5zGbP2AwNKz6ybxUU1DWthBWUpoXTSw5f9IaxMdwBaSm2ZBKVGAyx11KXDgJ5uo2yaSgkT6vL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786041493; c=relaxed/simple; bh=MgdIR1gKCaB7HmkjICzTGmBtenY5gqEIgSXJG/amQ6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gnqNEzbKdMqpBSMLC5ishHbWmVdIpKVmVWnCVsyi4xOXmeJF9Y5ZgLcG+2weEKdO31TZANQjEgPtN7qS/ip3Wa8JjeFs/n1IYfX8qiaFtgCU4QLJIubuisnilGU/QdUNUYbxEk/rujBRxk+dZG16U3EacoGDoDSlO5PX7AXbQOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=XaXpJ6vH; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XaXpJ6vH" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786041480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0FJ71k4IbTtXKn0TabOcxFSTkx7pIeozk1jZbpeVTno=; b=XaXpJ6vHiElnALhknjfYZwX7U02IVS/L738rs68+A1PBPzbwRbK3uJgvJbNs45uDBAQ+p6 rr4Qivbp9AzILq1qvbHhhYLepJTJR3j6zRGzc2kVMIcK4vW1Pnn0XuWK43mOOLaO30Af01 BVxfVgh47Ae0Do/Rh/h9PeO2F94rmFk= From: Usama Arif To: axboe@kernel.dk, cgroups@vger.kernel.org, josef@toxicpanda.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org Cc: shakeel.butt@linux.dev, hannes@cmpxchg.org, riel@surriel.com, kernel-team@meta.com, Usama Arif Subject: [PATCH 2/3] blk-iocost: clear delay state when freeing policy data Date: Thu, 6 Aug 2026 11:37:19 -0700 Message-ID: <20260806183742.946953-3-usama.arif@linux.dev> In-Reply-To: <20260806183742.946953-1-usama.arif@linux.dev> References: <20260806183742.946953-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT iocg_kick_delay() turns sufficiently large debt into an explicit block-cgroup delay with blkcg_set_delay(), setting blkg->use_delay to -1 and incrementing blkcg->congestion_count. Clearing it again depends on iocg_kick_delay() running from the period timer, the waitq timer or the issue path. ioc_pd_free() removes the iocg from active_iocgs and cancels its waitq timer, and no further bios can arrive, so once it has run nothing is left which can reduce the debt and clear the delay. The blkcg stays marked congested for the rest of its life. blk_cgroup_congested() then returns true for every task in that cgroup and its descendants: page_cache_sync_ra() cuts readahead to a single page, page_cache_async_ra() skips it altogether, and __folio_throttle_swaprate() takes swap_avail_lock and schedules a throttle on anonymous folio allocation. Clear it explicitly, after the list removal and the synchronous hrtimer_cancel() so that neither timer processing nor an I/O path can re-arm it. The free callback can also see policy data which was never attached to a blkg, hence the pd->blkg check. Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost") Signed-off-by: Usama Arif --- block/blk-iocost.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index b60625613e095..64b92aa3e5d48 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3063,6 +3063,7 @@ static void iocg_release(struct rcu_head *rcu) static void ioc_pd_free(struct blkg_policy_data *pd) { struct ioc_gq *iocg = pd_to_iocg(pd); + struct blkcg_gq *blkg = pd_to_blkg(pd); struct ioc *ioc = iocg->ioc; unsigned long flags; @@ -3085,6 +3086,12 @@ static void ioc_pd_free(struct blkg_policy_data *pd) hrtimer_cancel(&iocg->waitq_timer); } + /* off ->active_iocgs and timer gone, so nothing can re-arm the delay */ + iocg->delay = 0; + iocg->indelay_since = 0; + if (blkg) + blkcg_clear_delay(blkg); + call_rcu(&pd->rcu_head, iocg_release); } -- 2.53.0-Meta