Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795033208; b=jEspWWifnLsJTM61V/INtoMufuM/aFbfq9Sx7FBCAW6AulTM01SXU6AIdxFHxhJAs/zz MxZ3SqhAki2gRUzNuYHDnWpIBCwgHeJLJI3le7gmup7HvW1k7WkXP6/wcC62k817P8Gpq 9QiWVuI1tavIVhmGRhFsjN+v2XulgJOkLspWwF6J8VeWcIP6Y+3DH6DNdxnRX7z5rQ/Rg r5MDt7p0jMbVCV4EY+VswIrs3aVaObui7ENK3LpPZE1fq1SrUf/BXJwOAsuQn4JXfQhv6 9TqtYbqg0L0K94mdG0ygErSYTvkwXDHCBsUZbtpgRxBEsH8QC5W6nQ+MtBQ0gcEkbPw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795033208; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=p9vGCNXf23NTNHAh/hM3DT6KRJ57QWksEg4WX8iv4BI=; b=2PqsugmFdelRmqXVISNtBTmcUMkcBL9oYZ5qN/dqlhYpOIHOSiFftESatrSAHSwIGdDn qCqKOvnyhsHGoTnI0gyOQn6gOtDbE6kBff2dasX16jNpDNv7/RPr7wwfMubBu52Qd96xz rOo4ocpVXFwv2MD+ah632DndcfZXdhIsuWBjkIRSmhLNLECyNsV8uaxaZMY50pZqa6yt4 dUoEbwzah9SmH7HxrBPn+OAAdt8+QVUFKiIgoTw8ls39FmmAOHc2fgj00po0ZpSna3kKx 6FuvnAOeA3mFDuTPchqkncSxxIiIHriJmWxv2Khb7DljAFznogqDX05GI2sbsTmFvmg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vbiUi3Vc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50547606A33A; Wed, 18 Nov 2026 20:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vbiUi3Vc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23C851F000C4; Wed, 18 Nov 2026 20:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795033207; bh=p9vGCNXf23NTNHAh/hM3DT6KRJ57QWksEg4WX8iv4BI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vbiUi3Vc8UVbcNh1Fsh2x9oHN4cCRNrqV709g6eXozlkBgvr+QCBIGBneZNt39Vgn AjLG3H+DZtouB7qhZCnCvNIbSlYRSnzd0KIGIMDrIyAWYDEGqQGzuheUhd09VJZMsk diFYSnDKF4ZjAxYDiFOGnRUQ2Y6vM/INtk50XEyU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ingo Molnar , Peter Zijlstra , Muchun Song , Tejun Heo , Jens Axboe , Sasha Levin Subject: [PATCH 6.12 1684/1756] block: introduce init_wait_func() Date: Wed, 18 Nov 2026 16:03:31 +0100 Message-ID: <20261118150116.730207064@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Muchun Song [ Upstream commit 36d03cb3277e29beedb87b8efb1e4da02b26e0c0 ] There is already a macro DEFINE_WAIT_FUNC() to declare a wait_queue_entry with a specified waking function. But there is not a counterpart for initializing one wait_queue_entry with a specified waking function. So introducing init_wait_func() for this, which also could be used in iocost and rq-qos. Using default_wake_function() in rq_qos_wait() to wake up waiters, which could remove ->task field from rq_qos_wait_data. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Muchun Song Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20250208090416.38642-1-songmuchun@bytedance.com Signed-off-by: Jens Axboe Stable-dep-of: 0150554a3f38 ("blk-iocost: publish hweights as one atomic value") Signed-off-by: Sasha Levin --- block/blk-iocost.c | 3 +-- block/blk-rq-qos.c | 14 +++++++------- include/linux/wait.h | 6 ++++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 2a4d246fd9922..9496666b65b6a 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2722,8 +2722,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio) * All waiters are on iocg->waitq and the wait states are * synchronized using waitq.lock. */ - init_waitqueue_func_entry(&wait.wait, iocg_wake_fn); - wait.wait.private = current; + init_wait_func(&wait.wait, iocg_wake_fn); wait.bio = bio; wait.abs_cost = abs_cost; wait.committed = false; /* will be set true by waker */ diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index eb9618cd68adf..0b1245d368cd1 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -196,7 +196,6 @@ bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) struct rq_qos_wait_data { struct wait_queue_entry wq; - struct task_struct *task; struct rq_wait *rqw; acquire_inflight_cb_t *cb; void *private_data; @@ -218,7 +217,12 @@ static int rq_qos_wake_function(struct wait_queue_entry *curr, return -1; data->got_token = true; - wake_up_process(data->task); + /* + * autoremove_wake_function() removes the wait entry only when it + * actually changed the task state. We want the wait always removed. + * Remove explicitly and use default_wake_function(). + */ + default_wake_function(curr, mode, wake_flags, key); list_del_init_careful(&curr->entry); return 1; } @@ -244,11 +248,6 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data, cleanup_cb_t *cleanup_cb) { struct rq_qos_wait_data data = { - .wq = { - .func = rq_qos_wake_function, - .entry = LIST_HEAD_INIT(data.wq.entry), - }, - .task = current, .rqw = rqw, .cb = acquire_inflight_cb, .private_data = private_data, @@ -259,6 +258,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data, if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) return; + init_wait_func(&data.wq, rq_qos_wake_function); has_sleeper = !prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE); do { diff --git a/include/linux/wait.h b/include/linux/wait.h index 2b322a9b88a2b..10e46d5c31784 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -1207,14 +1207,16 @@ int autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, i #define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function) -#define init_wait(wait) \ +#define init_wait_func(wait, function) \ do { \ (wait)->private = current; \ - (wait)->func = autoremove_wake_function; \ + (wait)->func = function; \ INIT_LIST_HEAD(&(wait)->entry); \ (wait)->flags = 0; \ } while (0) +#define init_wait(wait) init_wait_func(wait, autoremove_wake_function) + typedef int (*task_call_f)(struct task_struct *p, void *arg); extern int task_call_func(struct task_struct *p, task_call_f func, void *arg); -- 2.53.0