Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4746563rdb; Fri, 15 Sep 2023 11:00:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPxB1WyEPY2b/irJkblrcMj1qdEnAl5YV9zCgsJnPeBZ952OVQpfHEgqTHXZcW0RwKhXRe X-Received: by 2002:a05:6a20:3d06:b0:15a:1817:c493 with SMTP id y6-20020a056a203d0600b0015a1817c493mr3060092pzi.39.1694800804251; Fri, 15 Sep 2023 11:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694800804; cv=none; d=google.com; s=arc-20160816; b=c7SZzAQze382GPPk1/Sga+AWhmnasZJvTHR9mNA210TEJfwdZtwONmM5r9NZ93GZEz sIbZL2JIN55jsaah1UdVl6ggQ6kbVW+CU7SEhQvzbVs5J/3WZ9AEPRS4xctdrdncO3j1 pq3DBwGBSiAyFCEkOfKmL7OlaoMPOWXrrkON8yEU5Xo7MV5i6lKvtZuHcmvLiTSWfo07 pgndL+JJYIkRf3bUpFV6fGYfSxd/qJ+RYLd74Mo1tmOqc0H9ICWfzKt2GUpIf/ISv6Td aUVxdFRLPxECfzEnKV7+TSKV6UmLd+++xTLhoy19ozZ1IKo5A4yOytD5Y/UB/967i8eb bnbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cxNDW2pc+qfPc4Lym4jAA6BiSnYn/+cC5qiOO1I7v58=; fh=YUiQ8+pDsfM5G21pNMEmVpCce5fb8IMXlvmjjoiquVI=; b=ESgUKVbPDvUDQPnzs1siYjbrOw9hIIzXz7aJsIy80EG0Vco4RVqJHftmeDrKZm2eZP k+6Bu7g3njvAY2gSwvy/wAh2OtLXOvw8yOrECJp9/1RJDk9U+g/Rcuw0YmtxC69Ma57V pmk2LtIbHnbqJRKIXfwryq38eCWnpHouycp3J2+tSi+u8E9JTIcgpTBpNR1JL3KDnPvZ lGf4wmwUnI+3K6Z1LVqQBxk44awHriF/vyBZx0GCxZVEhgDPFIJ61zueNhL/2M8xO+CG 8lq6XJHkQh0UMDGwegK/KCwW4ks2cfSHSEe+P/crzQs9mOhHNm6gF5nP10PlKSu17YcX eXfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EYsmCAt4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e19-20020a056a001a9300b0068fcb9a7349si3745393pfv.349.2023.09.15.11.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EYsmCAt4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6F71C82295E0; Fri, 15 Sep 2023 04:38:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234349AbjIOLiW (ORCPT + 99 others); Fri, 15 Sep 2023 07:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233993AbjIOLiV (ORCPT ); Fri, 15 Sep 2023 07:38:21 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45CDB1FE5; Fri, 15 Sep 2023 04:38:16 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-773a0f36b4bso103957285a.0; Fri, 15 Sep 2023 04:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694777895; x=1695382695; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cxNDW2pc+qfPc4Lym4jAA6BiSnYn/+cC5qiOO1I7v58=; b=EYsmCAt4Ae1rhTl1lpZruHr2QmE5Tx0KCM+KMMNppJEqcAlBcPYul6CHq47Hn99RuO wv3vMspgxjrQv9RU5gRvdKi6SLqMCQQvR+XVhRcWhpV5H/VCRaPeBH2nILn7tySw7NfH FtvmO7KraB1e5P2bUqK5GLhDYU8YyWjA+lSO+SM4wOM+u0gUC5cr82tH4rDPDkGxRDSA EV1CkBIWCGevGkCEsQ278dJ9F6GNaMNeJRBvzomCVf53LBUM6+uFC3Xyr2u7sxdZMxHs FDOfe4rWQJeUZ4j5Bj6rlRo9XyzAAZBDM2XPsv32uAobPeB75QbEMzq+ZWrvZGcuzLaj tjGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694777895; x=1695382695; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cxNDW2pc+qfPc4Lym4jAA6BiSnYn/+cC5qiOO1I7v58=; b=r0WOB15X8qW3dy4aoOmhfTrxBKIrxiJ+X/7VxUhMrXtzWxHlvR7mY0uueWT0E7myqw U0mh132WhfA7aA+fkEDdWBwLNk6mHCNHePcVk7zs6MfnE0XQcjbSIEeHqKqABKaRtJx/ VzN34AZcJgbIpTOBwLCPKtRCxGQ37v763Wf0UtBzTvGxzLk210ya/O9J2jala82JtSXe yazGrq/Ss9uFUYtNZ09cFW3ymu8ec5d9qf4/YQkNqt1HfQof+4uwQ5r9xuNf/Di63VoG D119ds0gCzUiAmabwPSpox2TymF2WqzVr/6yMRXl3yDovTgzow8ZsHhgd3MBHAbrd9ut qrig== X-Gm-Message-State: AOJu0Ywqm/7CzdaMsfLb32wiR5H5lTkv3cyseYuC86z6Bd8rQtEy1w6z em3E4wVak8F+fTf9xYp7PGxpkffxLN5wn1lQe4OkoWqZkwg= X-Received: by 2002:a0c:f14b:0:b0:647:35b7:4955 with SMTP id y11-20020a0cf14b000000b0064735b74955mr1440923qvl.52.1694777895308; Fri, 15 Sep 2023 04:38:15 -0700 (PDT) MIME-Version: 1.0 References: <20230829020451.9828-1-wenchao.chen@unisoc.com> <20230829020451.9828-3-wenchao.chen@unisoc.com> In-Reply-To: From: Wenchao Chen Date: Fri, 15 Sep 2023 19:38:04 +0800 Message-ID: Subject: Re: [PATCH V3 2/2] mmc: hsq: dynamic adjustment of hsq->depth To: Ulf Hansson Cc: Wenchao Chen , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, zhenxiong.lai@unisoc.com, yuelin.tang@unisoc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 04:38:23 -0700 (PDT) On Thu, 14 Sept 2023 at 20:57, Ulf Hansson wrote: > > On Tue, 29 Aug 2023 at 04:05, Wenchao Chen wrote: > > > > Increasing hsq_depth improves random write performance. > > > > Signed-off-by: Wenchao Chen > > --- > > drivers/mmc/host/mmc_hsq.c | 27 +++++++++++++++++++++++++++ > > drivers/mmc/host/mmc_hsq.h | 5 +++++ > > 2 files changed, 32 insertions(+) > > > > diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c > > index 8556cacb21a1..0984c39108ba 100644 > > --- a/drivers/mmc/host/mmc_hsq.c > > +++ b/drivers/mmc/host/mmc_hsq.c > > @@ -21,6 +21,31 @@ 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; > > + struct hsq_slot *slot; > > + int need_change = 0; > > Rather than using a variable to keep track of this, why not just do > the below here? > > mmc->hsq_depth = HSQ_NORMAL_DEPTH; > > > + int tag; > > + > > + for (tag = 0; tag < HSQ_NUM_SLOTS; tag++) { > > + slot = &hsq->slot[tag]; > > + mrq = slot->mrq; > > + if (mrq && mrq->data && > > + (mrq->data->blksz * mrq->data->blocks == 4096) && > > + (mrq->data->flags & MMC_DATA_WRITE)) > > + need_change++; > > And following above, then we can do the below here: > mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH; > break; > > That should simplify and make this more efficient too, right? > Yes, you are right. But need_change = 2, it means more reqs are allowed. Alternatively, modify it like this: mmc->hsq_depth = (need_change > 1) ? HSQ_PERFORMANCE_DEPTH : HSQ_NORMAL_DEPTH; > > + else > > + break; > > + } > > + > > + if (need_change > 1) > > + mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH; > > + else > > + mmc->hsq_depth = HSQ_NORMAL_DEPTH; > > +} > > + > > [...] > > Kind regards > Uffe