From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796375202; b=wj4iy4+W5hVDJww0okzuDu3Vp5ansfF2/XgEFMHGKKi4S9uY0vB/4q3ZqHSoX7IJG7gP hiv8GBRIhGqEmgsaAc55NR/FIHV6QxjJ/VwBaOz9TzSt0IZqMGTVwYiNkcKHbpPz77lG7 aSlge+v3v/HOegraIZPZUDWzFxEspUsgzoOSYUIZzhf1YKmmbdSUw7fxKjDTyXIPk2D/r Sn1uEduHfUTFSKRseXWZAb3BQe1yR95LsOqAo9Kgs3jLz/2nB44WkcgP7ao1aseg3E0vs BiNUXoKeEXWpZspoHkq/aSmYrmTRxw5CqoCKvjnTPxSvTILsKYwK1ZzBG16pkTnKXaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375202; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Cc:Subject:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=W/iV7RUyjYYkt4mdEHzsnVymUSa9C+nnGiV1XtUNs6s=; b=k47CDSWU4Cezz3eIYBoCr0RucVKSZesBBIzxy7VW9rn5G7O8hRINGQcU5clBf57mvPuE yA+7oBH7s7vN3KfaeZDnCOdHspMNAF7omaBaJQTQ36FiSmsS+HYNPnkj+I+8fJTvGO4+d C9hXNmNUYJib743GQfcJwCJZpSNCfng3J5oHZS9nGThaPrMChylAsCwKWQo+tX3vKliRW Ym+eOde2IakFXoi2763zud732+1jPfpFQhjRfayRJpAmJ18Yhr+QXujH5588+KTaV9P1T JknYZhZXvetDzD5NAl64d64nyK0Yvhm8E1LX1QM5IC9g7rILel9bfjhuoeZ8V1PF/ew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ACyVgGag; arc=none smtp.remote-ip=95.215.58.233 Received: from mta1.migadu.com (out-233.mta1.migadu.com [95.215.58.233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5CD0606A330 for ; Fri, 4 Dec 2026 09:06:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5CD0606A330 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ACyVgGag X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=8nIVvTmIuPwn/13gB60j01zS9oA6G2FB/pVEJCO6Yes=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796375198; v=1; x=1796979998; b=ACyVgGagXmuXXpdmVupKULbbpiUNgDSHuO+fXg0Ezm8gA8eonEftGaRVStdjOsdzPeV0gFhr NlWN0IoUQX+BjxRak9CunZlrA2U36W0ylA8Lw8+Cuye2zUcAeM9arOj/MSI8gnukdcAAO7jVyq7 s5kFmvaYd1CSv9eskGfZ/1ik= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id c3612290d3ef0d98; Fri, 04 Dec 2026 09:06:38 +0000 X-Mizu-Trace-ID: c3612290d3ef0d98 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Fri, 4 Dec 2026 17:06:34 +0800 X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: cui.tao@linux.dev, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, andrii@kernel.org, eddyz87@gmail.com, daniel@iogearbox.net, linux-kselftest@vger.kernel.org, cuitao@kylinos.cn, ameryhung@gmail.com Subject: Re: [PATCH v15 0/4] blk-iocost: BPF struct_ops cost model To: tj@kernel.org, josef@toxicopanda.com, axboe@kernel.dk, ast@kernel.org, alexei.starovoitov@gmail.com References: <20261203150338.2625598-1-cui.tao@linux.dev> From: Tao Cui In-Reply-To: <20261203150338.2625598-1-cui.tao@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 2026/12/3 23:03, Tao Cui 写道: > From: Tao Cui > > This series lets a BPF program take over the cost model of one > device. The BPF model provides calc_cost() for charged IOs plus two > transfer coefficients for the completion-time sizing, io.cost.model > selects between the attached model and the builtin one, and enabling > and disabling the controller stays with io.cost.qos. > > The builtin model is a linear formula derived from a handful of device > parameters, and the right formula is device specific. A BPF model can > be adapted to the device and updated without rebuilding the kernel. > > The series is based on next-20261201. > > Changes since v14: > - p1: put the three BPF fields under CONFIG_BLK_CGROUP_IOCOST_BPF > with stub helpers, and pass IOCOST_CALC_* flags into > calc_vtime_cost() instead of a bool (review from tj) > - p1: iocost_model_ops gains a name[] member; io.cost.model prints > "model=bpf name=" and the docs cover the new key (review > from tj) > - p1: rework the attach/detach lifecycle: .reg() keeps the bdev > reference and stores the ops pointer in a private member, > .unreg() reaches the queue through it and drops the reference, > and ioc_rqos_exit() queues a work item running the usual > .unreg(); a NULL-link attach is rejected with -EOPNOTSUPP > (review from tj) > - p1: switching the cost model resets the per-iocg vtime state > accumulated under the old pricing: debts, delays and waiters are > dropped and vtime snaps to the activation target. An RCU grace > period before the reset ensures every bio priced by the outgoing > model is accounted for; the accounting also resets on attach and > on device removal, and the model write resets before freezing > the queue so it cannot stall behind the waiters it releases > (review from tj) > - p1: clamp a bio's completion-time payoff to vtime so that stale > costs from bios still in flight across a switch cannot push > done_vtime past vtime > - p2: drop the field documentation block that v14 added to the > iocost_ioc_tick tracepoint and return it to its v13 form (report > from bpf-ci) > - p3: mount cgroup2 in a private mount namespace, return negative > error codes from open_nullb_dev(), and preserve the working > directory across the setns() unwind (reports from sashiko and > bpf-ci) > - p3: add the upper-bound validate case, snapshot the stream > counters per phase so the assertions cover that phase alone, and > probe the tracepoint via kallsyms instead of tracefs > - p4: the coefficient readback under a BPF model shows only > "model=bpf" plus the model name, and the io.cost.model key table > lists name= > > The p1 lifecycle rework and the model-switch reset change the > reference semantics Alexei's ack covered (the bdev handoff, the > workfn eject, the new iocost_model_ops members and the NULL-link > rejection); a re-review would be appreciated. > Hmm,v15 turned out to be the worst posting of this series,three high-severity bugs in the lifecycle I had just reworked, one of them a recurrence of a defect already reported on RFC v7, and none of it caught before posting. Sorry for the noise, and v16 will address all of the reported problems. Thanks, Tao > Tested on next-20261201 (two qemu x86_64 VMs, rotational device): > the builtin model collapses two sequential 4K readers to ~2 MB/s, > switching to the attached BPF model completes the io.cost.model > write in 0.02s and recovers immediately, and switching back > collapses again; an overnight tidal run of 37 load cycles over 9.6h > completed 13M+ transactions with all 37 model switches in > 0.01-0.03s and nothing in dmesg. The selftests pass (3 tests, > 0 skipped). The final tree also rebuilds cleanly from the four > patches applied to a fresh next-20261201 tree, kernel and selftests > alike. > > Link: https://lore.kernel.org/r/20261118131029.797007-1-cui.tao@linux.dev # v14 > > Tao Cui (4): > blk-iocost: add BPF struct_ops cost model support > blk-iocost: add iocost_ioc_tick tracepoint for per-period device > summary > selftests/bpf: add iocost cost model test > docs: cgroup-v2: document the iocost BPF cost model attachment > > Documentation/admin-guide/cgroup-v2.rst | 56 +- > MAINTAINERS | 1 + > block/Kconfig | 4 + > block/blk-iocost.c | 705 ++++++++++++++- > include/trace/events/iocost.h | 43 + > tools/testing/selftests/bpf/config | 2 + > .../selftests/bpf/prog_tests/iocost_model.c | 1021 +++++++++++++++ > .../selftests/bpf/progs/iocost_model.c | 189 +++ > tools/testing/selftests/bpf/progs/iocost_ms.c | 206 +++ > 9 files changed, 2192 insertions(+), 35 deletions(-) > create mode 100644 tools/testing/selftests/bpf/prog_tests/iocost_model.c > create mode 100644 tools/testing/selftests/bpf/progs/iocost_model.c > create mode 100644 tools/testing/selftests/bpf/progs/iocost_ms.c > > -- > 2.53.0