Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp283959lqp; Fri, 12 Apr 2024 19:00:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+N38fuOMt2bRXUlLuVh5eqEPbYbwHNkCQm2GiV11jA2t0uUwDXccoMRsOaYtKtfr21ZPKJTn5fYppsA/pwP6KpmkO+DM3LEdmtR6KXA== X-Google-Smtp-Source: AGHT+IEO87IruT30sF2rrMJaC4BaocUiRoQbEqFzHu7a4D6cyRs6wWQnhoeTkW/TDW+uRtEtU+nr X-Received: by 2002:a05:6808:ca:b0:3c5:edee:7acf with SMTP id t10-20020a05680800ca00b003c5edee7acfmr4953273oic.33.1712973602850; Fri, 12 Apr 2024 19:00:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712973602; cv=pass; d=google.com; s=arc-20160816; b=R2nb1WUjakSeoCyYmTiEP3FwCBgs1zHFY8IDrhtaRABSoGvIo/BAKenM8Uetv8DBuT xlQ0Q/DA4d/c7GPdlOyldXR5iy7D7IeA0m53HTLHZhpZv8HigNUCvna/gmLthcKk6R0U pM2n0RZ0M7bCD8NtODfWQrs0rln8vIQ2N/uPCscLjd1ZI/yNeuMlwrZ3knMP87LdMzp2 PoUINp6PUG0QSoM9T+OVSf6dWifWd3VBlD3fO7/ShB86L8urSr0I29EzgS32vIq7a8x1 YqUv+qO5SIdugTBtuKOxGjQW1yg/hwXa8XhrklFfBJwRgM7lOqt5fEawAMWMBqVDkykc u8jg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=iHYw/45l2IYqQGmqMhYdVFhLQhljXSUGFuzfVoN5CxY=; fh=5bajn1kmo2FZI9wvFID8pBbFodxCTS35a0WawSvaetY=; b=sLmhTSmOVnv4bp1w9t8xlyWCyKErLrXLNDQFIgOaTB+ciBZrU/heL/FTHXvn3R1d2p Z86K8RgwN+2DJXaFEEwXk80aQsXp9RNyG3hrRLXv1kG9zXH8FfE1Stg/I4ItswuD4PnB /ph150EXKtJGyy0pf4ZU2QGmQG9jEcn1vDpn28Aat7Y7iKyqESH2sYBeiFIcP62RjtEP FEjkSeKTJaeBP+9CmP/96WEegbGz4gB6RYhme3gfTMy9/5a//nFhhYpbT1BL6K+pI+2u pr2CFEWV5cZPDpla1WSSt3efr4Cj+Q/hoF6S7VnG6nsP6M/83DzyASAqBeusNojDtssD UfyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-143506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143506-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g7-20020ac87f47000000b00434a267ddafsi5325342qtk.588.2024.04.12.19.00.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 19:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-143506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143506-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9047D1C21378 for ; Sat, 13 Apr 2024 02:00:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7995612B95; Sat, 13 Apr 2024 01:59:54 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 A6B56D52F; Sat, 13 Apr 2024 01:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712973594; cv=none; b=WYw2iuPINSjBjWCkneWn7uukRpB0IbwPwnfcnvJwZlxqLt32YIqQyrtyX8jtJXQappStqtph5pA0U4Xqw0lXuFllIpnOEmspsFYTXUFuqdwBFyhEKNNJ0XYOQurO5Afb1m3sHFrluW6SdS8l+9v926NbTiIY0orNvC3+rEEHjZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712973594; c=relaxed/simple; bh=nnlDPjPKfEohwaKd9r81/1qp2ve/24ImVnOTGTeLfs0=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=gjtUGHB8wmIiB0osNQeeSHJJp5+F0DCyLLWIHJmajhc5z1R78CHVxK1Ueq1w+uA2V5FP33u6zUTQgWzvG+QWsF5Tfnfsj8cQiHdxKnEfeHmICJ82iflBwbLTqb2CTYbiJ1OsM3FtPhh9U9kLpRgrfIJOTDpFJDL1x43ROD36SeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VGc7h0fWvz4f3l95; Sat, 13 Apr 2024 09:59:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 8E6AD1A0175; Sat, 13 Apr 2024 09:59:48 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgBnOBET5xlmKg1bJw--.20969S3; Sat, 13 Apr 2024 09:59:48 +0800 (CST) Subject: Re: [PATCH RFC v2 2/6] blk-throttle: delay initialization until configuration To: Tejun Heo , Yu Kuai Cc: axboe@kernel.dk, chenhuacai@kernel.org, josef@toxicpanda.com, jhs@mojatatu.com, svenjoac@gmx.de, raven@themaw.net, pctammela@mojatatu.com, qde@naccy.de, zhaotianrui@loongson.cn, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, cgroups@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240406080059.2248314-1-yukuai1@huaweicloud.com> <20240406080059.2248314-3-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: <7531ba77-964a-169d-f55f-a8dcfcdbb450@huaweicloud.com> Date: Sat, 13 Apr 2024 09:59:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBnOBET5xlmKg1bJw--.20969S3 X-Coremail-Antispam: 1UD129KBjvJXoWrKr1rtF4xGFykXw18ZrWDArb_yoW8Jr4fpa y5Xa98tF4kXrZag3srZw1fZF9akr4xAFy8C3s8KrW5JF42vr4rKFnYg34YyF4fAF1I9r42 va18Grn8G3Wvka7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6Fyj6rWU JwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCT nIWIevJa73UjIFyTuYvjfUF0eHDUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, ?? 2024/04/13 1:59, Tejun Heo ะด??: > Hello, > > On Sat, Apr 06, 2024 at 04:00:55PM +0800, Yu Kuai wrote: >> @@ -1480,6 +1547,9 @@ void blk_throtl_cancel_bios(struct gendisk *disk) >> struct cgroup_subsys_state *pos_css; >> struct blkcg_gq *blkg; >> >> + if (!q->td) >> + return; > > So, this naked test is safe because the interface functions are shut down by > the time this function is called. > >> static inline bool blk_should_throtl(struct bio *bio) >> { >> - struct throtl_grp *tg = blkg_to_tg(bio->bi_blkg); >> + struct throtl_grp *tg; >> int rw = bio_data_dir(bio); >> >> + if (!bio->bi_bdev->bd_queue->td) >> + return false; > > and this one because ->td is set while the queue is frozen and this path > shouldn't be running while it gets set, right? Yes, this is called under bio_queue_enter() > > Can you please add comments explaining why those are safe? Otherwise, the > patch looks generally sane to me on the first glance. Can you please also > add how you tested the change? And I realized that there are no tests for bkl-throttle from blktests, and I'm using some other tests from our testers to cover basic functionality. Perhaps will it make sense to add some tests to blktests? Thanks, Kuai > > Thanks. >