Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1319437rwb; Sun, 18 Sep 2022 05:16:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DMFTfgIeOCHZEd6zXbr4Yp+gJEatGhYFcgB3j6MquKlZ3n4sey+1zYZOYNppwvLFeDvLm X-Received: by 2002:a05:6402:44c:b0:445:f2f1:4add with SMTP id p12-20020a056402044c00b00445f2f14addmr11524769edw.257.1663503418187; Sun, 18 Sep 2022 05:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663503418; cv=none; d=google.com; s=arc-20160816; b=Cei3UaNFNgBKi3zX3f5CeHgCY4JRS8shgdEmBWtEUTAB9JJsyIdVPcEOVvWcvCWT1D /iQxWPCFpw4DRoxD4rDYn1Tf376vba2nqMbmCF20xcLv6TufZuh/kiozW5pZ2k27iqRf oHCif3klbNddo+k83+butea3VKS6dAVSCpvYRpKaC11yl+nIpE11MVhSfMxOoeBkPT8u rJ1HUu2JJVKrVK/Jq7DksaAYABfJaXcpmtg9D3ST0L8/KjG/fofMVgeQ20cVu5gGhqaK DX6IQVLYBpIFETcqkpyxQz6+vC3YNgmjJvJzJI4P87yKKtcKqc5+tzVOXaVfcr63G5hB yWRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:date:message-id:from:references:cc:to :dkim-signature:subject; bh=RV6OPhI8PJKT5vEl51soNB+bv12n4mODtQRF3wFhIqY=; b=gXN2ZIkhNYzumCyOMd9sciW2fi+V5aAx8S6ckq4zuD6bKa2seZ6TU8QAd15CfXzLwx 2WBMvUVA1rfFLzwE9C7MLSCfJuHSSOZLee+YsFca94YIiGartXHnZeM36D5RvCmJEjC4 +zTi4IF8r51vSGbe+tgfYWW41lTBrjzq0R0DhTrgMERCsnIPHgZMgMP4zCQQP02NdK4q tsE1Ap2n7ZV2bhjNoxfOA7R4Fcq/qIL97CXnyzwqyK/bfjjheWqAj7L0RjwC/6r3vKQ/ kG4NmDjQhiWw2cTVbgGRaDLMxldYO7r7h7UPEad1Ahcxdk5ZlrggMAsHYYyK+Y4huwun sc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=r0jOjpGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he40-20020a1709073da800b0077edef76646si19485608ejc.366.2022.09.18.05.16.32; Sun, 18 Sep 2022 05:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=r0jOjpGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbiIRLjY (ORCPT + 99 others); Sun, 18 Sep 2022 07:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiIRLjB (ORCPT ); Sun, 18 Sep 2022 07:39:01 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D10D27DD3; Sun, 18 Sep 2022 04:38:57 -0700 (PDT) Subject: Re: [PATCH v3 3/5] md/raid10: prevent unnecessary calls to wake_up() in fast path DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1663501136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RV6OPhI8PJKT5vEl51soNB+bv12n4mODtQRF3wFhIqY=; b=r0jOjpGO8JWFpzyL87wflqGOOqZrFuTd+sgMqSwQYNhIjWVUzwtE8Ef+COLFd6hA1lJ7vK 0xp+K3NbPqmaHIeX7UKBk9wyujRiABMED+ddpV5W7uOWrxhXag35+0glUENMi6ORwA62P2 LxzlXkH4FqrFD/lc8mzIiCsmJvTA5eg= To: Yu Kuai , song@kernel.org, logang@deltatee.com, pmenzel@molgen.mpg.de Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com References: <20220916113428.774061-1-yukuai1@huaweicloud.com> <20220916113428.774061-4-yukuai1@huaweicloud.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Guoqing Jiang Message-ID: <5f2b0c5d-209b-9c0c-ff22-781542d5517e@linux.dev> Date: Sun, 18 Sep 2022 19:38:50 +0800 MIME-Version: 1.0 In-Reply-To: <20220916113428.774061-4-yukuai1@huaweicloud.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS 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 On 9/16/22 7:34 PM, Yu Kuai wrote: > From: Yu Kuai > > Currently, wake_up() is called unconditionally in fast path such as > raid10_make_request(), which will cause lock contention under high > concurrency: > > raid10_make_request > wake_up > __wake_up_common_lock > spin_lock_irqsave > > Improve performance by only call wake_up() if waitqueue is not empty > in allow_barrier() and raid10_make_request(). > > Signed-off-by: Yu Kuai > --- > drivers/md/raid10.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index df435d693637..cf452c25e1e5 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -274,6 +274,12 @@ static void put_buf(struct r10bio *r10_bio) > lower_barrier(conf); > } > > +static void wake_up_barrier(struct r10conf *conf) > +{ > + if (wq_has_sleeper(&conf->wait_barrier)) > + wake_up(&conf->wait_barrier); > +} > + > static void reschedule_retry(struct r10bio *r10_bio) > { > unsigned long flags; > @@ -1015,7 +1021,7 @@ static void allow_barrier(struct r10conf *conf) > { > if ((atomic_dec_and_test(&conf->nr_pending)) || > (conf->array_freeze_pending)) > - wake_up(&conf->wait_barrier); > + wake_up_barrier(conf); > } > > static void freeze_array(struct r10conf *conf, int extra) > @@ -1891,7 +1897,7 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio) > __make_request(mddev, bio, sectors); > > /* In case raid10d snuck in to freeze_array */ > - wake_up(&conf->wait_barrier); > + wake_up_barrier(conf); > return true; > } > Acked-by: Guoqing Jiang Thanks, Guoqing