From mboxrd@z Thu Jan 1 00:00:00 1970 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=1795979438; b=q58UaQRDDbOMRQFIN674kVbwjNc3MebyR03jV0CpR5lq59TyjY6kmszMXFLyNtzzzzwA PDcgyuHVj9sFACZa7snt5KVLdGw3arpib4ahDQZZPBdsLzZtDpEVOh75xrkvnysGF7zPi mbRL2v3kCmfUtAVMBdgXRE5JAAgcwAjMQlkArqSwiOptOjSrI1sSoRVvZiJ1flWqah5tP nzxywRjf2k27ojmn9jxKSXFao+3oUHrXR8O98Q7g7Amdpk7o/OYpj5M8uJXejGxdUr6Ba qJ2taAaxl6syMG5m3cVZ/yeZgEDT70uF0VoHEyHZuE/hch9Mr4LFqQAjxqRc49MJ9Gw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795979438; h=Received:DKIM-Signature:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=klg+tUhTup52UOVun7jgtIw6hAhw/+mzeUdZoEbq4dQ=; b=kci1niqWJveOi/NQ833APNoZkmge5I4vg/dy+yamjQZRJ3mrXJMbhCET0gXS3sV/lGKX iFNIj97hFCBZcJs7odm2uMlT4LuwRB6GQSi8xIq9obA54F16ynU2jL9/M7MYdYVPWyDIE iLKsZ1cN0g3/R2ywKZkjm7Aj80631c+lH7BKfQnoaVssOaYhJhNkC5RRNlv82XLcZ5SEp sZDZ8kXg0ouzxU8Cy4MWmKUvPjOusOLyy/UDxwH21IrPIvSg6C/KthRKwm9+kIl+ND0pu 5g85EJytCfVC22t2PqsmFTaCjPpM233U9sr5FJG8kT43XD0rg5pbMbo1+qx2YaNaNqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E2Ey9Ur1; 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 E085D606A680; Sun, 29 Nov 2026 19:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E2Ey9Ur1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1937B1F00899; Sun, 29 Nov 2026 19:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795979437; bh=klg+tUhTup52UOVun7jgtIw6hAhw/+mzeUdZoEbq4dQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=E2Ey9Ur1Fsot+RAE49TP+YgPaGRfVbCEIxOHDlpwX63xEzd8xppJobWaMntkv7cRo RxniXcCgX/4msmaamsolzUh4kqGZ12JarfJTnL6nBUa8Rn7ZqD6YRv3/53c5OypC5L 6te/4dfP3EmcgocVKNADBHjBbH9o2MXIQ50r4aw7HPWknHmQiohOjrHYHhH1hG2uSf +KnbhKBGGG+H7lb/bzvOq3kcLOnYchaSx+AtVIKY+qiBH2zjUZGOq9D0MA6jDmbMmY teX/uy93xx/iuwbmBN7jwuZIOE3G4OQvGb745fRBny/8jGAW0zzXipYlnUSE98EfHB cgJj3syulesUw== Date: Sun, 29 Nov 2026 09:10:36 -1000 Message-ID: From: Tejun Heo To: Tao Cui Cc: josef@toxicopanda.com, axboe@kernel.dk, ast@kernel.org, alexei.starovoitov@gmail.com, 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: [RFC PATCH v14 1/4] blk-iocost: add BPF struct_ops cost model support In-Reply-To: <20261118131029.797007-2-cui.tao@linux.dev> References: <20261118131029.797007-1-cui.tao@linux.dev> <20261118131029.797007-2-cui.tao@linux.dev> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, Tao. On Wed, Nov 18, 2026 at 09:10:26PM +0800, Tao Cui wrote: > + const struct iocost_model_ops *attached; > + struct bpf_link *attached_link; > + /* either NULL (linear) or ->attached */ > + const struct iocost_model_ops __rcu *bpf_model; Can you put these inside #ifdef CONFIG_BLK_CGROUP_IOCOST_BPF and go through helpers with stubs where they're used outside the struct_ops code, e.g. in ioc_cost_model_write()? > @@ -2657,6 +2723,41 @@ static u64 calc_vtime_cost(struct bio *bio, struct ioc_gq *iocg, bool is_merge) ... > + cost = model->calc_cost(bio, is_merge ? IOCOST_CALC_MERGE : 0); > + return min(cost, VTIME_PER_SEC); Maybe calc_vtime_cost() and calc_vtime_cost_builtin() can take IOCOST_CALC_ flags from the callers instead of the is_merge bool? Also, what's the justification for capping the cost at VTIME_PER_SEC? > @@ -3535,11 +3680,12 @@ static u64 ioc_cost_model_prfill(struct seq_file *sf, ... > - seq_printf(sf, "%s ctrl=%s model=linear " > + seq_printf(sf, "%s ctrl=%s model=%s " > "rbps=%llu rseqiops=%llu rrandiops=%llu " > "wbps=%llu wseqiops=%llu wrandiops=%llu " > "flushiops=%llu\n", ctrl and the coefficients describe the linear model and don't mean anything while a BPF model is selected. Can you add a name[] member to iocost_model_ops and print that instead when the model is bpf? Something like: 252:1 model=bpf name= > +static void ioc_bpf_unreg(void *kdata, struct bpf_link *link) > +{ ... > + /* del_gendisk() is in progress or done. ioc_rqos_exit() detaches. */ > + bdev = blkdev_get_no_open(new_decode_dev(ops->dev), false); > + if (!bdev) > + return; Looking the device up by dev_t again here is what makes iocost hold its own reference on the map and handle the window after the bdev is unhashed. I wonder whether it'd be simpler to make .unreg the only detach path: - .reg keeps the device reference it already has and stores the pointer in a private member of iocost_model_ops, like hid_bpf_ops->hdev. .unreg reaches the queue through it and drops the reference. - ioc_rqos_exit() runs under rq_qos_mutex and can't detach the link directly, but it can queue a work item which calls link->ops->detach() so that the usual .unreg runs. It'd need to hold the link for that, maybe with bpf_link_inc_not_zero(). The link holds the map until .unreg has run, so iocost wouldn't need its own reference on it. The device reference would be there only for .unreg calls which run after rq_qos_exit(), from the work item or from a link close racing the removal. Can you add a comment explaining that? Thanks. -- tejun