Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp655549pxb; Thu, 26 Aug 2021 11:14:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUdysL/wQNqoHyGe4Fm6STPfLF6yBjLmLD2hDDEQISnHtCg2kxn9ln+ESsQ+dL+lXsNO84 X-Received: by 2002:a17:906:840f:: with SMTP id n15mr5726440ejx.460.1630001675614; Thu, 26 Aug 2021 11:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630001675; cv=none; d=google.com; s=arc-20160816; b=LMGry8mnFyFDCVcCMo+JMNsYJ+VjjMK5tT88euj34Pi8Q5bUVJupPMHYrJAGHud8SM u6Rv9DgNgoSskaRmihm/Alwwbm6cQBcIMf5ed6MJy7DN1vamu6EYh3tFS7yZb4URF2M6 6V1nXfabkQW3C5nwLRFnFZDFmKr7Btdk/hcALcHX+A5ZjaNLFlViIIdLfK5Mg0IbkNiV 4bX8jsdL/gQmIHygrS6+HBa955sGWkxFoRHKi+ex8u+k6wOJcAYYW1Xm7PZE2H9lhs6b VPj7CqmgSFgqjF/IO1Vc8dHDxirJuqWmQJ1MJVVX/KtzDAEZ8hE1pjLvfJEbiNgXYw2Z daGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=j0mt7AWcGZvt97QcESxgo4rDmKH0RfGdg9W8LlCYkLQ=; b=hf79MWgj/+paPDKEguahEb//3UzSShfGIetVexhW2BFuGUEORmK63P62zHnC7XxVge fFZFLWCnFw4YnzPreIlaoAzGK7bQvhe0irUcdcTGVySJBBX7GJL7Xo3IEUqOsD+hOo/b UodwpYfqFCA3lH3xDzCgFJw9VW+qIfspLf7FEZundTkO2l1a0LcW6DVfjohxr+MvkJWE z1UvTf+nkJv2Wadnr0Of91nvePyXfsOhR/7AkBevLt75IxkWf0fvjr5zftz+WqrNvB1D XHW5Jxs0s3A2LkQWDlQeFsPH7gwh1vmQbyD1Eb9KU2meg0beSH8nHWiWlZ9PKipsWZtA y21A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si3480484eds.494.2021.08.26.11.14.06; Thu, 26 Aug 2021 11:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243280AbhHZSK0 (ORCPT + 99 others); Thu, 26 Aug 2021 14:10:26 -0400 Received: from mail-pj1-f51.google.com ([209.85.216.51]:39675 "EHLO mail-pj1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243092AbhHZSK0 (ORCPT ); Thu, 26 Aug 2021 14:10:26 -0400 Received: by mail-pj1-f51.google.com with SMTP id oc2-20020a17090b1c0200b00179e56772d6so7151541pjb.4; Thu, 26 Aug 2021 11:09:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=j0mt7AWcGZvt97QcESxgo4rDmKH0RfGdg9W8LlCYkLQ=; b=BVArMxorTUNQfUowQX36xKsqXt29xYa8KHRwvYfCYrPmJm+X7tg2wcPecmSBGcvKqc tREEZTQAX+JuVaKzOv+LVVVJjRoPcU708CTyWGpFYFHw+ptNL5QM/Al/0h55UaKbsN8k H0M6AaNk1x0IAnK0TZiOoYf9JoaEig/ZV9/hyXdUOY/+LreSbvlbL+PLhk9v4kj31Z2b 2ZocViT66GH56sPxNF8VxyVpHe/WlIXE492qvu0vvcD1XZfFqyyvC3shWC7ipkA85Ymk cS1OzMHz3kHrW8NhS+P+ADvl222kdWyFdFLbxqD2RH/IE5amEdGPUGGvgmhtCwlzhiaR HImA== X-Gm-Message-State: AOAM531MkX6v0GO/W63YTNzcYd8UHnJOjK6TzK1iPD6/TmFhE34okBES ySBXgAZgVFR0QrsuQEAiLmE= X-Received: by 2002:a17:90a:a404:: with SMTP id y4mr5929010pjp.52.1630001378136; Thu, 26 Aug 2021 11:09:38 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:22e3:6079:e5ce:5e45? ([2601:647:4000:d7:22e3:6079:e5ce:5e45]) by smtp.gmail.com with ESMTPSA id nk17sm3539792pjb.18.2021.08.26.11.09.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:09:37 -0700 (PDT) Subject: Re: [PATCH] block/mq-deadline: Speed up the dispatch of low-priority requests To: Zhen Lei , Jens Axboe , linux-block , linux-kernel@vger.kernel.org Cc: Damien Le Moal References: <20210826144039.2143-1-thunder.leizhen@huawei.com> From: Bart Van Assche Message-ID: Date: Thu, 26 Aug 2021 11:09:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210826144039.2143-1-thunder.leizhen@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/26/21 7:40 AM, Zhen Lei wrote: > lock protection needs to be added only in > dd_finish_request(), which is unlikely to cause significant performance > side effects. Not sure the above is correct. Every new atomic instruction has a measurable performance overhead. But I guess in this case that overhead is smaller than the time needed to sum 128 per-CPU variables. > Tested on my 128-core board with two ssd disks. > fio bs=4k rw=read iodepth=128 cpus_allowed=0-95 > Before: > [183K/0/0 iops] > [172K/0/0 iops] > > After: > [258K/0/0 iops] > [258K/0/0 iops] Nice work! > Fixes: fb926032b320 ("block/mq-deadline: Prioritize high-priority requests") Shouldn't the Fixes: tag be used only for patches that modify functionality? I'm not sure it is appropriate to use this tag for performance improvements. > struct deadline_data { > @@ -277,9 +278,9 @@ deadline_move_request(struct deadline_data *dd, struct dd_per_prio *per_prio, > } > > /* Number of requests queued for a given priority level. */ > -static u32 dd_queued(struct deadline_data *dd, enum dd_prio prio) > +static __always_inline u32 dd_queued(struct deadline_data *dd, enum dd_prio prio) > { > - return dd_sum(dd, inserted, prio) - dd_sum(dd, completed, prio); > + return dd->per_prio[prio].nr_queued; > } Please leave out "__always_inline". Modern compilers are smart enough to inline this function without using the "inline" keyword. > @@ -711,6 +712,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, > > prio = ioprio_class_to_prio[ioprio_class]; > dd_count(dd, inserted, prio); > + per_prio = &dd->per_prio[prio]; > + per_prio->nr_queued++; > > if (blk_mq_sched_try_insert_merge(q, rq, &free)) { > blk_mq_free_requests(&free); I think the above is wrong - nr_queued should not be incremented if the request is merged into another request. Please move the code that increments nr_queued past the above if-statement. Thanks, Bart.