Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3158404rwj; Mon, 19 Dec 2022 14:04:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BLfSnZ8u1/0bn1ZI9+a0AO5TYvprOnZWe3qPilrHfTXLSHR591KHqApxkkEa06oGY0ygg X-Received: by 2002:a62:f906:0:b0:56e:d7f4:3bf9 with SMTP id o6-20020a62f906000000b0056ed7f43bf9mr39133808pfh.7.1671487442680; Mon, 19 Dec 2022 14:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671487442; cv=none; d=google.com; s=arc-20160816; b=Lz94ceAh0+DsDNFi0JKdmpumJxT4mLxpf2cQC9La54WpYs8n3tMgMHkopWZR5SMjBU BQxyY6JdoOkjcci315+8l/+B/VqxnN3yJrtgaHFs4F5t7x0WPByzn3pxwV8pllyalGAa w/s/OxrofmqcajOtZs7uigkF6FVL8q5i0vg3EyUvVo5jyGiNTw9V5RiDaKQaBelEMMwH snmWLik1H2MEnkOxoNH1x6fiJwm/cwgNhVnxy6ub4TzI98dNLINDUoMLrMin8xCANczK WcXkqF5Wo/mhwAWVuIaWIHM9w9uqtTlgfK0lqGmbHYrW+4MNJq+wNZmVI4ra7BH0ZoS4 mkpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=LZ6E54gQso9A3AZTU5M12wLSIgrxkuCsiZqbTjl9O+k=; b=rkti+7Qe4Al9EzRD2YGhqOpXfZi47i5omB7I721F639NyFKcVCAeYfh1LZtdVaMirB gQPIavgx7hHWlAXu0MDwqwM4fIj5c4pPyL0/gI18/hp/HjEfCGz7m+qLGBWjVRHXUS51 oC7MPJ0n7LsiP13hDClYsgBcjGoITP+3hz1cDDvTmApB/bXxLJwbiq+JmDhlUu3ftWMK kQlvHkp9YwQxpCr5tTUgYCjAlFeGETMLv5r6OfFiVtRVJu9hYEVoSC8N5qe+8BF5ha+D yE3BCmp8RMJvUIdv8l0zKuhMGMUnS8oonACQZyY9hmFWf/GE0R98WjTWPexby5w8pU9H cfkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="l3qDTyq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a621816000000b00576950b449asi11130073pfy.351.2022.12.19.14.03.53; Mon, 19 Dec 2022 14:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="l3qDTyq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232692AbiLSVWv (ORCPT + 70 others); Mon, 19 Dec 2022 16:22:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbiLSVWg (ORCPT ); Mon, 19 Dec 2022 16:22:36 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DBF13F3D; Mon, 19 Dec 2022 13:22:34 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id v3so7061109pgh.4; Mon, 19 Dec 2022 13:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=LZ6E54gQso9A3AZTU5M12wLSIgrxkuCsiZqbTjl9O+k=; b=l3qDTyq/WO1/cjtxD3IaspFo1xRvEv77I/YPtlYY0faD0+9e55S301Keu5ZRn2BOAJ /06AfNo/vBoHZij1MSCG6Uv5+1+IiiBAgy2JIhC7QTpbMY0cZlMcpdNFXzr6mc4GHd2n d2rHms6UaQeM/CfhVjMj5K5PTDHw9ItNUw8UjI+cv9LXwbrIi5iIogfGJOkiUHCkBSxG 3wkE9PfNcCfJoosdjppXgb4kwVXjOvgse+8quW9q5UjKI65S7hmjNgYCLObocfy4UJdu Y76S2/ind4Za8KgctFd1vblXIyRGQOhfNIEqIcwMDe9VPC82QSRH+yLCio90FvmxMza4 auhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LZ6E54gQso9A3AZTU5M12wLSIgrxkuCsiZqbTjl9O+k=; b=LEsrtlNPwtKgb8Ms9tcq7kqZN9LwfLsFIA4+pTFf0GOrnzdVA9rqDgF/fHuWUXlmOF qszc4Jbs3QYZ8UNtSk5dm74aC9Kc1SLU3yuHqVoHmKV7Bb6hfg0B/N88aWLsOlq7teMV R+klFN4Nsv3dOdWp5RUQG/FY6srgzdGOVns8g2TzrTeSD/DbANcrY/tnuGq7m86/VjH1 R3m4PceR4etqVWUFlR8x09ZsoPUU/mrKmykpxklqU/BFtLeeyKzum5uoT6LELWDVC9SV IaprLIizsuLFE5Ht+Rva8yVYvh2o5j2vVYSMeOBF38nwJtRPvVEk0520oBJD4WlOM9t0 Ckxg== X-Gm-Message-State: ANoB5pk1Tmy2/j3S42ZcWAvvnkQOOyoE3I1DNsAbK8UmlyLDqlPvEYhz OvW/XM3SP+gKHpEEzR9+dl8= X-Received: by 2002:a62:6445:0:b0:577:51b1:375e with SMTP id y66-20020a626445000000b0057751b1375emr46370720pfb.26.1671484953947; Mon, 19 Dec 2022 13:22:33 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id h18-20020aa79f52000000b00576df4543d4sm7038458pfr.166.2022.12.19.13.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 13:22:33 -0800 (PST) Sender: Tejun Heo Date: Mon, 19 Dec 2022 11:22:32 -1000 From: Tejun Heo To: Jinke Han Cc: josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com Subject: Re: [PATCH] blk-throtl: Introduce sync and async queues for blk-throtl Message-ID: References: <20221218111314.55525-1-hanjinke.666@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221218111314.55525-1-hanjinke.666@bytedance.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This looks generally fine to me. Some nits below. > +static inline struct bio *throtl_qnode_bio_peek(struct throtl_qnode *qn) > +{ > + struct bio *bio1, *bio2; > + > + /* qn for read ios */ > + if (qn->dispatch_sync_cnt == UINT_MAX) > + return bio_list_peek(&qn->bios[SYNC]); > + > + /* qn for write ios */ > + bio1 = bio_list_peek(&qn->bios[SYNC]); > + bio2 = bio_list_peek(&qn->bios[ASYNC]); > + > + if (bio1 && bio2) { > + if (qn->dispatch_sync_cnt == THROTL_SYNC_FACTOR) > + return bio2; > + return bio1; > + } > + > + return bio1 ?: bio2; > +} Wouldn't it be simpler to write: if (qn->dispatch_sync_count < THROTL_SYNC_FACTOR) return bio1 ?: bio2; else return bio2 ?: bio1; > +/** > + * throtl_qnode_bio_pop: pop a bio from a qnode > + * @qn: the qnode to pop a bio from > + * > + * For read io qn, just pop bio from sync queu and return. > + * For write io qn, the target queue to pop was determined by the dispatch_sync_cnt. > + * Try to pop bio from target queue, fetch the bio and return when it is not empty. > + * If the target queue empty, pop bio from other queue instead. > + */ > +static inline struct bio *throtl_qnode_bio_pop(struct throtl_qnode *qn) > +{ > + struct bio *bio; > + > + /* qn for read ios */ > + if (qn->dispatch_sync_cnt == UINT_MAX) > + return bio_list_pop(&qn->bios[SYNC]); > + > + /* try to dispatch sync io */ > + if (qn->dispatch_sync_cnt < THROTL_SYNC_FACTOR) { > + bio = bio_list_pop(&qn->bios[SYNC]); > + if (bio) { > + qn->dispatch_sync_cnt++; > + return bio; > + } > + bio = bio_list_pop(&qn->bios[ASYNC]); > + qn->dispatch_sync_cnt = 0; > + return bio; > + } > + > + /* try to dispatch async io */ > + bio = bio_list_pop(&qn->bios[ASYNC]); > + if (bio) { > + qn->dispatch_sync_cnt = 0; > + return bio; > + } > + bio = bio_list_pop(&qn->bios[SYNC]); > + > + return bio; > +} This also seems like it can be simplified a bit. Thanks. -- tejun