Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2252393iof; Wed, 8 Jun 2022 00:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7htN5BheCJG71ZQWIvXsNk69bnVH+/PdZ3qoJCUxE+tIit4hhm7MdOflBLFDyiyKk2+T/ X-Received: by 2002:a17:902:f650:b0:15f:3a10:a020 with SMTP id m16-20020a170902f65000b0015f3a10a020mr32510806plg.61.1654673566117; Wed, 08 Jun 2022 00:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654673566; cv=none; d=google.com; s=arc-20160816; b=HvY+ZZxWtdSoTDlh7KR79mK5s3nR7SyC9Hjxsf3pwh55j6pmlCCvwq4MkiShYf5FVO twsP/a2tEzCzXGKEHpaIXKE/GPhoVyW6seTfzDWc7UH2tuz7c7i64/JvMGgE9keZi05G vnAtnFPbZjyfLDma3uMU3hI1a8SGkWbqSrNDnTXB2IYhVGCqBgTUgd5GshD99elRS4kT 47+rn5wJ5l4o0wLvQaxU6aIMWsPjipP3tCLsC1Ca65z3ACvRNC0UkHS7NEIozl6LcNKb JSxFyHviczAQxcWIbzNrbkoWq1IIhpvEz0yYUjzlbjfSBsb/Ax+OZN4CFpBVMJ4EM7fM JsWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=864l6KxjfsvZx9+/R2ExM+zlGNergMIc2oL7Gp+3Pwk=; b=khvFVnxEPiGZm7AxAwjkhVhVp4lzeuGmGXrZ3V0Ijzvl1B1iVLZERMtmtJu3HN/UN3 iUQqmrnLYLecGvlvkkgsXFsyx4WfA5MDfaamwyOGylfeHtNP+kFbVZ4xwvof0o5jn1Cb eu6/BwYtCXz/2HJ93W9EmnXsqiAyhIWw6/z3pXc0ClnWZbaGCmfdHCeuN9/9AyuET3mt MGRmdt4H7oD22QHE/1gUtLU348gPf2AlTlz4RQIl+fsNygJCkYFZbCyCXh3nCaIPBbW5 zlW3ugwtymHDpbLwE1KI96I4GaYrJ0xazby5zGFc7Q/UTewnRbKf4PVKjS1sbGYurytf 1eGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OapB7OXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 68-20020a630147000000b003fca9e4e3b7si26729761pgb.319.2022.06.08.00.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OapB7OXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 35E29203D25; Wed, 8 Jun 2022 00:05:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378466AbiFGVOf (ORCPT + 99 others); Tue, 7 Jun 2022 17:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376561AbiFGUQy (ORCPT ); Tue, 7 Jun 2022 16:16:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB45172C14; Tue, 7 Jun 2022 11:29:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 66D21B8237C; Tue, 7 Jun 2022 18:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D28FFC385A5; Tue, 7 Jun 2022 18:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654626565; bh=3xOZY2rZbOX3Q/5YOONZrsu9wJxQTj1y2E9gwJ19t04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OapB7OXBQu3rmJaaWomxLq/VJA0gNYWEEqMVGP+9QNSlq64LF5KKupyX5aBvQ5UQu /KE852lcqYt7r9Qqsp0TJ2jT00vWEFXIQ6/XFMzPRDe8mv2t1XdXiFOJgrdWRHqA84 FN2YTaCpM8H/C1k6mf5K6Ts6oAbohJk9HVuirSaY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 422/772] bfq: Relax waker detection for shared queues Date: Tue, 7 Jun 2022 19:00:14 +0200 Message-Id: <20220607165001.439896878@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 From: Jan Kara [ Upstream commit f950667356ce90a41b446b726d4595a10cb65415 ] Currently we look for waker only if current queue has no requests. This makes sense for bfq queues with a single process however for shared queues when there is a larger number of processes the condition that queue has no requests is difficult to meet because often at least one process has some request in flight although all the others are waiting for the waker to do the work and this harms throughput. Relax the "no queued request for bfq queue" condition to "the current task has no queued requests yet". For this, we also need to start tracking number of requests in flight for each task. This patch (together with the following one) restores the performance for dbench with 128 clients that regressed with commit c65e6fd460b4 ("bfq: Do not let waker requests skip proper accounting") because this commit makes requests of wakers properly enter BFQ queues and thus these queues become ineligible for the old waker detection logic. Dbench results: Vanilla 5.18-rc3 5.18-rc3 + revert 5.18-rc3 patched Mean 1237.36 ( 0.00%) 950.16 * 23.21%* 988.35 * 20.12%* Numbers are time to complete workload so lower is better. Fixes: c65e6fd460b4 ("bfq: Do not let waker requests skip proper accounting") Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20220519105235.31397-1-jack@suse.cz Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 5 +++-- block/bfq-iosched.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 963f9f549232..047368c23984 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2133,7 +2133,6 @@ static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq, if (!bfqd->last_completed_rq_bfqq || bfqd->last_completed_rq_bfqq == bfqq || bfq_bfqq_has_short_ttime(bfqq) || - bfqq->dispatched > 0 || now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC || bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq) return; @@ -2210,7 +2209,7 @@ static void bfq_add_request(struct request *rq) bfqq->queued[rq_is_sync(rq)]++; bfqd->queued++; - if (RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_sync(bfqq)) { + if (bfq_bfqq_sync(bfqq) && RQ_BIC(rq)->requests <= 1) { bfq_check_waker(bfqd, bfqq, now_ns); /* @@ -6563,6 +6562,7 @@ static void bfq_finish_requeue_request(struct request *rq) bfq_completed_request(bfqq, bfqd); } bfq_finish_requeue_request_body(bfqq); + RQ_BIC(rq)->requests--; spin_unlock_irqrestore(&bfqd->lock, flags); /* @@ -6796,6 +6796,7 @@ static struct bfq_queue *bfq_init_rq(struct request *rq) bfqq_request_allocated(bfqq); bfqq->ref++; + bic->requests++; bfq_log_bfqq(bfqd, bfqq, "get_request %p: bfqq %p, %d", rq, bfqq, bfqq->ref); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 07288b9da389..a1ec70af64c8 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -469,6 +469,7 @@ struct bfq_io_cq { struct bfq_queue *stable_merge_bfqq; bool stably_merged; /* non splittable if true */ + unsigned int requests; /* Number of requests this process has in flight */ }; /** -- 2.35.1