From nobody Sat Jul 25 05:25:58 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 A2C293ACA49 for ; Fri, 17 Jul 2026 12:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784292629; cv=none; b=cM4MfkLfHoNNRqmhq5A8Q1WRRy4/jPIYcoXTV1BPkNJevsU7WU1l+nad0zw4B4tZChpnQSfox4mL/4qvC3uBL2cQPzeCwC0MXY10g/ppTjEfthGwzoWTdom3esvUAIRhPfX3jWVms+nF/Du2YP1UbnbxX7juzIHRAOLsbC2lMr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784292629; c=relaxed/simple; bh=yHpHCxNOC5MlsnpDgYnYkeYbWsX6snYvQjK/qKOfYz0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=INyAP/fA8Lfo98Xrkx9BD3rHokrxCd6HUF6J4Hf05l3GqGM2FhcvHv6W4PbIZr4NLek/8VFuys/jI9iyH0qa3uMAQJ9aK7MQiWdGAELdw1itnZdVPtylCJW0kvSPB++Uc+TL+WaMpXyvhqKeaTp9k5ljmm1QZ4kacSbdk3oU9Ps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=NhrYqFgX; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="NhrYqFgX" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2cee9b74ee1so42759485ad.3 for ; Fri, 17 Jul 2026 05:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1784292628; x=1784897428; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ts6ItQRv/aSdCv0Y+lKO30HlVCBc9sllq/rXrxpJ0EM=; b=NhrYqFgXCgSL/0L1mTny9IynK1wzTBI1/cRMXwa6PyhtKFcrru+zvKUcobjefJDm3o xitmv7fs3kvkSj7KbijDlwyCX+OrarJcreXbT4PgYH1n7CfZV/pwOqQiFWgR+U/ENNXB FnY7ZfAccK6I7RzT63s1CdNAm7bWKHx/R2fB27VWzvuD1Haf/Ok0JizusW2H2s4h8fX+ ELAzAel7hdw+o5FS2atLFjgP/uwJfWDFrtD1WUgcWjKI2PPzgfmXvFx+3UsoASuiGnQd zwrISvkmdelWGGnrr/ollACPRurRnXFO0fJvwxqbJ+XFkBW4OfjWK+SY5+hrf6ZFxm01 Ungw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784292628; x=1784897428; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ts6ItQRv/aSdCv0Y+lKO30HlVCBc9sllq/rXrxpJ0EM=; b=VejBqrtx4ds01JpMU+8BrVdovAG9AzJ0mnsiRG7E1/Q8sXE3hjoJSycH+OaJxFSXEo 50l7j4VmyuSv3zTdDY2LninsoZ8kQE9US37gfOs6lZKD/9JdX19Q7mKQ0+nLhhw5CXHn TigoMrV6amnwO2rUfWJ8IUE/TpN468N+tRnmiqQM4jLXhOw2aifv9YAjahzLR9smXglE ss++aQBLUQtYfNPWvnJZ65R+KgiEDBflVxwrhKfYHJpXlUTobOiBDCmKJrcLz58wCZ00 s/43omPYxmiAwcbTK62ONTPxSYD0iMOKZKOJ/LCcJg1zMnJx4BnsVeuV3SxbZuyx2Rz2 8OXw== X-Forwarded-Encrypted: i=1; AHgh+Rp1umjtsqlf1ed3xoWEfUjWQqoQ9c7Us8GcgycTZG70ePIAwTXwyWrPFBxw0Ft/t4VStTB3qjwsKtT4k08=@vger.kernel.org X-Gm-Message-State: AOJu0YyK/pFPUPhSQjQdke5FYdfbwW7T62fV7R0hh6RtN4B5PtMf2BTj qKDOgMTvy+2osGly68mziaQCHKJd4PN6+FeWB7Q1AbCXhy2b7RdJ95aktHmLPfjUdAA= X-Gm-Gg: AfdE7clFdYmRXWCvrZBzZpWXERg+eaM6B2diJkywIG3tfMstWqVNdujRdQ32/FHfpyU vXpcj2G68x9NPIONfaAEtja6IsAQBVHVONpbHobEgU9ouTYjEf7CfPM7Fqy1yKBPJbD/rgr6xNu Sn8DCUNKGpDAt9nNt9S9p5zyDJAXt7jgtojXetul/v6C0SG6maN2qWTNW8LrwJ4oFJZXuGT6rg3 GZi1cxJg0RIJcHQekc+cX3iY5m1l957+FQUJ8BgQphurEsTVGPCU6hMm0cW2fZu+1tJDc4ITuAx KLlZ6k79Xje0vBIquGgiLCXecWqIlco3BzrKkI0yjij69r5A99wiufwJK9+/5MXSjrxw7wRkCUp KUjgs1MXA+FwNYtJIF4A7yAb3xSyNBa78mfLjZtoiY0jeBRpsbAtAeR3d18aV4ad+WUB77eJNdg == X-Received: by 2002:a05:6300:48:b0:3c3:994f:b4f5 with SMTP id adf61e73a8af0-3c3ad67a262mr2799204637.28.1784292627902; Fri, 17 Jul 2026 05:50:27 -0700 (PDT) Received: from localhost.localdomain ([147.136.157.3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517aad72csm808235a12.1.2026.07.17.05.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 05:50:27 -0700 (PDT) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: axboe@kernel.dk, guzebing1612@gmail.com Cc: yukuai@fygo.io, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tang Yizhou Subject: [PATCH] blk-wbt: Always change enable_state to MANUAL when setting latency Date: Fri, 17 Jul 2026 20:50:21 +0800 Message-ID: <20260717125021.88825-1-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tang Yizhou Commit 1e56f30a73f3 ("block: Make WBT latency writes honor enable state") compares only the boolean enabled state in the no-op check. Writing the current latency value while WBT is in WBT_STATE_ON_DEFAULT is therefore still skipped, and enable_state is not changed to WBT_STATE_ON_MANUAL. A subsequent elevator switch to BFQ then disables WBT through wbt_disable_default(), silently discarding the explicit sysfs setting: # enable_state =3D WBT_STATE_ON_DEFAULT, min_lat_nsec =3D 2000000 echo 2000 > /sys/block/nullb0/queue/wbt_lat_usec # skipped as a no-op echo bfq > /sys/block/nullb0/queue/scheduler cat /sys/block/nullb0/queue/wbt_lat_usec # 0, WBT disabled Skip the update only if the stored latency matches and enable_state already equals the exact target state: WBT_STATE_ON_MANUAL for a non-zero value, WBT_STATE_OFF_MANUAL for zero. A write that passes the check then reaches wbt_set_min_lat(), which performs the actual transition to the MANUAL state. Rename the helper to wbt_lat_changed() to improve readability. Fixes: 1e56f30a73f3 ("block: Make WBT latency writes honor enable state") Signed-off-by: Tang Yizhou Reviewed-by: Guzebing Reviewed-by: Yu Kuai --- block/blk-wbt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 953d400fd013..4f12a064286e 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -813,7 +813,14 @@ static void wbt_queue_depth_changed(struct rq_qos *rqo= s) wbt_update_limits(RQWB(rqos)); } =20 -static bool wbt_set_lat_changed(struct request_queue *q, u64 val) +/* + * Return true if writing @val would change the WBT state: + * 1) @val differs from the stored min_lat_nsec, or + * 2) @val matches, but enable_state is not the corresponding manual state + * (WBT_STATE_ON_MANUAL for non-zero @val, WBT_STATE_OFF_MANUAL for 0), + * so the write still has to update enable_state. + */ +static bool wbt_lat_changed(struct request_queue *q, u64 val) { struct rq_qos *rqos =3D wbt_rq_qos(q); struct rq_wb *rwb; @@ -825,7 +832,8 @@ static bool wbt_set_lat_changed(struct request_queue *q= , u64 val) if (rwb->min_lat_nsec !=3D val) return true; =20 - return rwb_enabled(rwb) !=3D !!val; + return rwb->enable_state !=3D + (val ? WBT_STATE_ON_MANUAL : WBT_STATE_OFF_MANUAL); } =20 static void wbt_exit(struct rq_qos *rqos) @@ -1021,7 +1029,7 @@ int wbt_set_lat(struct gendisk *disk, s64 val) val *=3D 1000ULL; =20 mutex_lock(&disk->rqos_state_mutex); - if (!wbt_set_lat_changed(q, val)) { + if (!wbt_lat_changed(q, val)) { mutex_unlock(&disk->rqos_state_mutex); goto out; } --=20 2.43.0