Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4102980rdb; Thu, 14 Sep 2023 11:48:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJt5AmDJQEprEY4Yost1hPjGQ6q8Nf5HdLLRjfjes9QUH4P+fAr+zACGmZcKPq3EMSG/3I X-Received: by 2002:a05:6a00:248a:b0:68c:dcc:3578 with SMTP id c10-20020a056a00248a00b0068c0dcc3578mr6946110pfv.25.1694717335571; Thu, 14 Sep 2023 11:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694717335; cv=none; d=google.com; s=arc-20160816; b=cFe2RXnt7XdS16HD4yG3oN9erg9GN4QccxTZttb8N2ynx1EGIhKfsxlcWfDObfcM0Q zFalXA6lRsyPsEe584ZKxJ1SAG6INpQPtBemn2IquWgo+QgBdPx/f8LjCH8GS+NN7xkM YSY89JTmQZ+8/AyYvj4hyYCzdekbgu46PPVXVD0ua0yAmyY2Sg5pUpCozrWo2f9of4w4 Y6hlgLitkBVY08EnIyBYjvgpaxN2CiGrWKD5TCOlg3mmJ97m9zprX2GvD96LVl6RZ+0B 2MRe0HHJUIA9tkXql2ltP5MXiPOjsCr/RciZ/jDmT483F4YjCx+DW6DJr2aS1yyDHkvA RXMw== 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=RR3Rm3BvRcsogaZkU4Bg0Ejafb0av4o4WZ1/jDMEr44=; fh=PtafSWZr2I6lAPdGc91Sps2r+wsknXWblbd6hNk21EM=; b=URTGTRSHFm+iL3XBFJB/zoYSQAi+1DMu9Mz5K21cQR6859CuaNZvGOOuDQrtk/8+/K XLDBT29XDmjUomowJ8SkMchZNWVRKokPgYnevaE4HT87EIsVU+nrQ39IBxWENE7LIC5j OHwhj0cvM+FyVADBWiZDtsEhWV73TR1kg29H8dwHTzIOUpaKXe+/xU+NOjaftvLARfEX fra/ANOwyWnMJLZJMdbZcJFjtw/ScAntI7AobpKDKdo08Ha2peiHEo0quT3HMRAJh0i2 59wjTxrIveotVm6pRsDcZ0Ss0XLKQWCxclgkvjGKFRNXLakVZMWTZ/xUas9TtRFsWcCn 8P1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GT7YOe3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id cm24-20020a056a00339800b0068fa8499af1si2002100pfb.11.2023.09.14.11.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GT7YOe3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 51A5280BA7FB; Thu, 14 Sep 2023 05:57:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238471AbjINM5q (ORCPT + 99 others); Thu, 14 Sep 2023 08:57:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237706AbjINM5p (ORCPT ); Thu, 14 Sep 2023 08:57:45 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F9B21FD4 for ; Thu, 14 Sep 2023 05:57:41 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-d7b79a4899bso958975276.2 for ; Thu, 14 Sep 2023 05:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694696260; x=1695301060; 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=RR3Rm3BvRcsogaZkU4Bg0Ejafb0av4o4WZ1/jDMEr44=; b=GT7YOe3Yag96osS+kNebu+LJLVACEAtPbg9PB4bRLk0libnh1Zg72oQEJO54houkTx sPj//pX0rD48MNlrcLVt6OTGmRm1HcX7+6TI8Bt8RR1VkR/tKCiDtk+WbScktLOyYcLZ ZujbMWe2y6w1biWg+gVOgtmN+KnFQW8JsLm9K5VEqMPEhokovfYGcV9zxw7r7p8eCr0Q 7Suy8IRIIDPQhXt/UQirIVyVpAVr+7fHviQQ3rqGTn+PnZJgwfyN4Y7+gin1pVK8gl0H 2FzGEB/r3dlgTVs8zGNFjbeEE1Z6TcS2M8RJMT4k05MPfEY/PecRriGWQz/6SpM21m/I i62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694696260; x=1695301060; 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=RR3Rm3BvRcsogaZkU4Bg0Ejafb0av4o4WZ1/jDMEr44=; b=s3+WUZM64EsCKC0olRyucGWtrsBREZ5usbDP561Ysn6SbJK2+eG4O2r07tmi0N9MY9 IKrT9/XPDRkCMHSRRYJYfeu+XM/2KXNRWyqxdLYkf8CZbFCVJPRMOzbpGXB6p+J6Y4Zc /2x//YArnhbknnXzCQhv8YX1pO0kf0ulATZBxJm4raNfX2vuXn9BLyI84IBB3nZyTAcZ KjLFXDLE/ivdGCLQ4wvz6YDsNhPVYBoO8/0zVq1cJDZTDUmiNBtNb2ipMlSPJRzVbRM5 QQU04NJA9zt9U8JAVTYfclkZbyuyrZcoi30kqmEp/RS+p974vI5m/qh+MFhJSAXsP22v ZAYw== X-Gm-Message-State: AOJu0Ywgx/ji6BdpdsQm/E5gHXUWR80eY7XJA8kCoCVjrv+i4kBxTaPJ g6jcQwKfzU+mNgq9TQuM5XCCsOpcwAImhEm167p6Dw== X-Received: by 2002:a25:42ca:0:b0:d72:80bc:d3b2 with SMTP id p193-20020a2542ca000000b00d7280bcd3b2mr5130485yba.32.1694696260210; Thu, 14 Sep 2023 05:57:40 -0700 (PDT) MIME-Version: 1.0 References: <20230829020451.9828-1-wenchao.chen@unisoc.com> <20230829020451.9828-3-wenchao.chen@unisoc.com> In-Reply-To: <20230829020451.9828-3-wenchao.chen@unisoc.com> From: Ulf Hansson Date: Thu, 14 Sep 2023 14:57:04 +0200 Message-ID: Subject: Re: [PATCH V3 2/2] mmc: hsq: dynamic adjustment of hsq->depth To: Wenchao Chen Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, wenchao.chen666@gmail.com, zhenxiong.lai@unisoc.com, yuelin.tang@unisoc.com Content-Type: text/plain; charset="UTF-8" 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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 05:57:46 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.vger.email 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? > + else > + break; > + } > + > + if (need_change > 1) > + mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH; > + else > + mmc->hsq_depth = HSQ_NORMAL_DEPTH; > +} > + [...] Kind regards Uffe