Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp480700rdb; Tue, 19 Sep 2023 00:50:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAg21eXBBQsMkNR/naC+5u2fyhFA6B3fhP95tAJ7tJSAWOFf/BUePlcAbsNxxUgzVDmYOA X-Received: by 2002:a17:902:be08:b0:1c0:c174:3695 with SMTP id r8-20020a170902be0800b001c0c1743695mr8287043pls.13.1695109820550; Tue, 19 Sep 2023 00:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695109820; cv=none; d=google.com; s=arc-20160816; b=SAvY3xEViF45cGpNFbHfDDfPazFti0LJ/+qXOrWTzK4SfuY4UhZHkXN2AmO/mWzajk SRKZY82luhp1UE1kyPuXAhtJHr1q5KOu30j4UiEh8ElFuHQkc3l/WV9S6wTncfKcAuOg zX4dfdqFOroSJzvsI7+fl2ND2tsO7SshS7Xky8ZvUqy6unZGlbl5AfUGIkvkoatvBNkR zF2pDTREerzZ3ZqIFMkzsrJDtHlPZT8wwAxeL0y9J+i6Go2iFfa/OOixO9rKgZIgdck1 F0ZeJ6TCX+QZoJA3fHV8+NZ7Go5Dm3WjiYxTf4VBrtzki8Ntkih0GAH4W3MrdUMCZyUP NnYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=nicKmWvq4HC3b2A8tboxe+xDzwa7dwbnPzFQcZT9wrg=; fh=0jAly0MiKJ/kbmheIqVHdEbVrsP5BHor2C4tGaC497c=; b=xIb9RlQl7DenOoNs/CIJp8d6Kn7SyMxTXhNo4eEGJS3IXwpugQ2VPeXJy0ZTZiCyq0 BYPlFihTE0RHJ/QVFDGwxhXFsKDj5sLTdlTNSgoZ7mBC+IqGelt5mLs6Zu07amlYb5eq JCkAtPokl35xko8WDs2M4v8yM3pYVYBAKsb+G33ZgzCqc5N2S8a1LlUsxGekvLCZKIZj j63xORKbKtRDoPMezE8mDan4ZskkXUI5/jkXObxaYqmyEg6YE1JZsdKzf7ja2uclxp4Q F31QrUlqkPPUvLc0wJ8XzO541On8pZslVF34pNjyvR6dof5vUgLxqncu0YmN1q+/uS2n Yv7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x11-20020a170902ec8b00b001c3886b091asi5170103plg.127.2023.09.19.00.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 00:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A96B48031F1F; Tue, 19 Sep 2023 00:47:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbjISHrr (ORCPT + 99 others); Tue, 19 Sep 2023 03:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbjISHrn (ORCPT ); Tue, 19 Sep 2023 03:47:43 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070BD116; Tue, 19 Sep 2023 00:47:34 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 38J7lGlh044063; Tue, 19 Sep 2023 15:47:16 +0800 (+08) (envelope-from Wenchao.Chen@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx05.spreadtrum.com [10.29.1.56]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4RqYZS4F8Kz2SK5DM; Tue, 19 Sep 2023 15:44:00 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx05.spreadtrum.com (10.29.1.56) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Sep 2023 15:47:15 +0800 From: Wenchao Chen To: CC: , , , , , , Wenchao Chen Subject: [PATCH V4 2/2] mmc: hsq: dynamic adjustment of hsq->depth Date: Tue, 19 Sep 2023 15:47:07 +0800 Message-ID: <20230919074707.25517-3-wenchao.chen@unisoc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230919074707.25517-1-wenchao.chen@unisoc.com> References: <20230919074707.25517-1-wenchao.chen@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx05.spreadtrum.com (10.29.1.56) X-MAIL: SHSQR01.spreadtrum.com 38J7lGlh044063 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 19 Sep 2023 00:47:57 -0700 (PDT) Increasing hsq_depth improves random write performance. Signed-off-by: Wenchao Chen --- drivers/mmc/host/mmc_hsq.c | 21 +++++++++++++++++++++ drivers/mmc/host/mmc_hsq.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c index 8556cacb21a1..869da6472a6d 100644 --- a/drivers/mmc/host/mmc_hsq.c +++ b/drivers/mmc/host/mmc_hsq.c @@ -21,6 +21,25 @@ static void mmc_hsq_retry_handler(struct work_struct *work) mmc->ops->request(mmc, hsq->mrq); } +static void mmc_hsq_modify_threshold(struct mmc_hsq *hsq) +{ + struct mmc_host *mmc = hsq->mmc; + struct mmc_request *mrq; + int need_change = 0; + int tag; + + mmc->hsq_depth = HSQ_NORMAL_DEPTH; + for (tag = 0; tag < HSQ_NUM_SLOTS; tag++) { + mrq = hsq->slot[tag].mrq; + if (mrq && mrq->data && + (mrq->data->blksz * mrq->data->blocks == 4096) && + (mrq->data->flags & MMC_DATA_WRITE) && (++need_change >= 2)) { + mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH; + break; + } + } +} + static void mmc_hsq_pump_requests(struct mmc_hsq *hsq) { struct mmc_host *mmc = hsq->mmc; @@ -42,6 +61,8 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq) return; } + mmc_hsq_modify_threshold(hsq); + slot = &hsq->slot[hsq->next_tag]; hsq->mrq = slot->mrq; hsq->qcnt--; diff --git a/drivers/mmc/host/mmc_hsq.h b/drivers/mmc/host/mmc_hsq.h index aa5c4543b55f..dd352a6ac32a 100644 --- a/drivers/mmc/host/mmc_hsq.h +++ b/drivers/mmc/host/mmc_hsq.h @@ -10,6 +10,11 @@ * flight to avoid a long latency. */ #define HSQ_NORMAL_DEPTH 2 +/* + * For 4k random writes, we allow hsq_depth to increase to 5 + * for better performance. + */ +#define HSQ_PERFORMANCE_DEPTH 5 struct hsq_slot { struct mmc_request *mrq; -- 2.17.1