Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3429956rwj; Mon, 19 Dec 2022 18:48:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+MHPH5cA2vMwgDuA4Dp7cIkkNHQMEbBg8OCUSzuMDB9ha6SXNbxkjqhXAqTkrCXBv0Rj3 X-Received: by 2002:a62:18c8:0:b0:577:994c:d7ea with SMTP id 191-20020a6218c8000000b00577994cd7eamr43078132pfy.3.1671504491561; Mon, 19 Dec 2022 18:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671504491; cv=none; d=google.com; s=arc-20160816; b=fss9DHW7LFn2NQlxJGpCWK+EP1WtNeLlznIwG2ZTmNa3x8QnRYntQ4sGWbRUGO5Io4 /ULU427ZPz7xn+OkA/E1n5K65AP7SMoYP+ASp+48YpVVGST1irwRMYR5Br6giVd9fH6C BoPmA4j43yJy6skEEYNzNdizXX6hA9osLlwu7OzYXmrh3sJdtt+lXJ5Qx4oacGOl0iI6 HlL0xflaTUGf5g9VfzkYE6n18wMam1oJckE3fPACwVhka3xfKBEEOLXuIHGZsNxDjG+2 dimDUbF0sOl6tOtFCdzW8QcK7uTj5c4nmJ4ZaZXjXZ2fURQ9Ft+GpZD0laUuYGuNAtTq uB2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=XdsW29O/6Xn6rXQsu5aPcLciaxL4xlcszGahdv8fEa4=; b=TD9Cdhe1W91pGyfN7DjwcI+y5L5/sZgTJ2wiEoZFeikK9jJbE7m/jJ8Y+/mN/LaMXg 36vlB/hP8708xYjiiX2rFSepV3F3ywOeGWeCTs9aPhNm6xUGmgqqHIlvSiACidUc30Ty YLdK0r6msmUztgip69FIrJrlKNikQ3mJ2WgSelTw/4BAMJK6tyCDOvbaaeO5xPBhWEY3 SPinrQZZHQEFEks8IdeO4P7MCcC0cW4i0hVUGL2DnnPONpliN8asXdnYBSgbI65tsPBO lRjeVAoxokv2hzMvvlpECnRkYZZOQGOQ3QotV3gdLyGiGJCBL6WWpsxZncbIT6sA7vZ8 POzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JX+Yf4WH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w203-20020a627bd4000000b0056e3c566bfasi11297839pfc.201.2022.12.19.18.48.02; Mon, 19 Dec 2022 18:48:11 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JX+Yf4WH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232802AbiLTCit (ORCPT + 71 others); Mon, 19 Dec 2022 21:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232858AbiLTCik (ORCPT ); Mon, 19 Dec 2022 21:38:40 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C7F11A24 for ; Mon, 19 Dec 2022 18:38:13 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id f3so7472606pgc.2 for ; Mon, 19 Dec 2022 18:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=XdsW29O/6Xn6rXQsu5aPcLciaxL4xlcszGahdv8fEa4=; b=JX+Yf4WHK86OHRDqIF+sLMufhIcZDg+3+srs173HnZoa49DGsPAWF5Dr5GAckDMRWz FKHkNX+zSoaW4T6mj7PFoBB+R7aIPFkoDT6C/zaKh7Fr6YFcJKKB+3TP03RHpygnFjIk zT4pk334VL7ur7W5QNW3BqlUa/W794r2umr3pX1aAVp3AXfUJGFwSzJu8dGpw7ZCgTEG 4NVifBZ8i6VMj0URqFcOG+fZKYrG0HAfPsGfyCS0BgcNENC/nKgRAk4PMZc5vosOwenc Y434W1ZNjXPpGBrbmjcVPOpgMpveICUYsPsb8oI5lQrxmvtyQ5C3+4gEoXEATonYs6ZV 7YBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=XdsW29O/6Xn6rXQsu5aPcLciaxL4xlcszGahdv8fEa4=; b=PxSKoA2NYdZUkBxXFhrShonWkIBohoWg5dh7ty7L9xojcKnq59R6ovE7O41UftfzFB WHG1ZXbVZR6AaPn+4yey36VjanXXd2CdUKVezvtVHQEmK+8kHE8E+SF4gYhQQc4l3Z8C biztNhlawgs5feZIpx/5lDFmwbaIur7Q4wbBzscaeODZYloGSqkekTdvgdcXVxoFw+G3 vFQ1l2QB8Acw7Mh5sW60l6NFIe2oIg+Vb7GDGMSasP9tI/kQHx8zZCLeFCTVFgDokDR5 kmz5JuL/I4FNkli/rBGUUqHsnpMnRRvBFN0zP7hLfnu68+U40L4JGTqUu1yxY9Jgw7Gj oygw== X-Gm-Message-State: ANoB5pllkV+TBj6WqX3qLPm4KszcKsSGvDS4qfYUZLeyx5kz11XgLLPf grSYSm8g2nFSdHlqKuKZQU/6Ja8DGeiFjBg0iUU= X-Received: by 2002:aa7:956f:0:b0:576:e1f0:c812 with SMTP id x15-20020aa7956f000000b00576e1f0c812mr42718289pfq.30.1671503893422; Mon, 19 Dec 2022 18:38:13 -0800 (PST) Received: from [10.254.36.84] ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id 81-20020a621654000000b00574740c99e9sm7306038pfw.129.2022.12.19.18.38.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Dec 2022 18:38:12 -0800 (PST) Message-ID: <78028f86-4fb4-e24e-a01b-d1f8a51cff87@bytedance.com> Date: Tue, 20 Dec 2022 10:38:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [External] Re: [PATCH] blk-throtl: Introduce sync and async queues for blk-throtl To: Tejun Heo 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 References: <20221218111314.55525-1-hanjinke.666@bytedance.com> From: hanjinke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 在 2022/12/20 上午5:22, Tejun Heo 写道: > 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. > Indeed, I will make it more clear and send the v2. Thanks.