Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18599210rwd; Tue, 27 Jun 2023 20:43:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Wii2KVCgKHDlnh5LXtvU5aMRLIoDKQ9Ll0gjXZTfbKRI3SdMJs+lTDoXCAl50T+cxeG5g X-Received: by 2002:a05:6402:517b:b0:51a:5c1d:5c06 with SMTP id d27-20020a056402517b00b0051a5c1d5c06mr16584881ede.42.1687923796623; Tue, 27 Jun 2023 20:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687923796; cv=none; d=google.com; s=arc-20160816; b=C+SC8Rbyl4Hgq7yl8ncpNNWSxG0eoPCzcmAmz6CAA3rNrjErXuhLbHSi8wiOw6xFpI bFpILmTUm1S/2l+CHxgEt3tJa2MPpSIt1G7IciPQ4l+YMCHE7xpouPXJTM9SNLF7guS1 sQsx2EIW1fkfV+Z85nHvbZCCea9B0uJSJLh/iMT8mL6PFpTLafYSVitvwgMDFW2Rhzb9 ZALmPYldIHGOYoQG+ZU/+DBcPUM1pdKLMWCqDpslTA0u4Wpek/t+YQEcmMGpGJXAcgcn TXRX5CuWpLfWUJAV3+drUDAbH4dtmfGglfeXIZIF89iB+Uozv7VQku/syVhAoFXWe2so hDbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=CvyHRxWT3NfNdVro9WC1jCUTzuWhGmVGCy9untK/qc8=; fh=8OcIELGHVOp9EwhR2GoZK3HjCU2hxg09UwXuVkPVvhE=; b=ik1igolNkMRIk8/LmJQFBknIvJYCJqhMsIZ9aeP+RoX4sA8iO6pkqrMG/AP2gNZAVu IyRmzvsHBCFArc9HV/xOArLDC3QuNKVriRLoESM/D7Qs4r1JtSJUBQ6d5JUb5pnlwdKf td/Aa8w+TylI0cKzVT3xJ87TAaFAkTddbTOWpvULzq9nxTiDN6JiVrqK2EHHL1GR5Xws DXtaH/ku9cSISvto6I+safSZPdiBv2aWN7stJLaTb+qj9JWbKSdnh8zv3jCwqSeaJ6w+ tTRgiHoE/gnRDUT73Hm5qYaqa5Yl4iw2VYL2ZkbioMbWeLMLgbea5TVhTES9ZBqTa+/5 r0jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kGIJ0QSU; 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 d10-20020aa7ce0a000000b0051dad2d5095si1305708edv.444.2023.06.27.20.42.52; Tue, 27 Jun 2023 20:43:16 -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=kGIJ0QSU; 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 S229716AbjF1D2b (ORCPT + 99 others); Tue, 27 Jun 2023 23:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjF1D23 (ORCPT ); Tue, 27 Jun 2023 23:28:29 -0400 Received: from out-63.mta1.migadu.com (out-63.mta1.migadu.com [IPv6:2001:41d0:203:375::3f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB11B2D58 for ; Tue, 27 Jun 2023 20:28:27 -0700 (PDT) Message-ID: <9c038fe8-0361-c6fb-9b4e-7b74e0591ae9@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687922905; 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=CvyHRxWT3NfNdVro9WC1jCUTzuWhGmVGCy9untK/qc8=; b=kGIJ0QSU3psDqR3qm91xwn7RZ1cDqy6la2SKW6fxxfHOtrqE6uxD4m952Voj680gZH7sFX ktYug9A/Ai06sYCYGYiEzirZ5U9LxDlWZlCoz6cXu46fpPENFEnnBV7LGBApL0g0bfho6E 295RHpYaNghvPzw2IGnrIfDzw9B1fNU= Date: Wed, 28 Jun 2023 11:28:20 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 1/4] blk-mq: use percpu csd to remote complete instead of per-rq csd Content-Language: en-US To: Ming Lei Cc: axboe@kernel.dk, tj@kernel.org, hch@lst.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com References: <20230627120854.971475-1-chengming.zhou@linux.dev> <20230627120854.971475-2-chengming.zhou@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 2023/6/28 10:20, Ming Lei wrote: > On Tue, Jun 27, 2023 at 08:08:51PM +0800, chengming.zhou@linux.dev wrote: >> From: Chengming Zhou >> >> If request need to be completed remotely, we insert it into percpu llist, >> and smp_call_function_single_async() if llist is empty previously. >> >> We don't need to use per-rq csd, percpu csd is enough. And the size of >> struct request is decreased by 24 bytes. >> >> Signed-off-by: Chengming Zhou >> --- >> block/blk-mq.c | 12 ++++++++---- >> include/linux/blk-mq.h | 5 +---- >> 2 files changed, 9 insertions(+), 8 deletions(-) >> >> diff --git a/block/blk-mq.c b/block/blk-mq.c >> index decb6ab2d508..a36822479b94 100644 >> --- a/block/blk-mq.c >> +++ b/block/blk-mq.c >> @@ -43,6 +43,7 @@ >> #include "blk-ioprio.h" >> >> static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); >> +static DEFINE_PER_CPU(struct __call_single_data, blk_cpu_csd); > > It might be better to use call_single_data, given: > > /* Use __aligned() to avoid to use 2 cache lines for 1 csd */ > typedef struct __call_single_data call_single_data_t > __aligned(sizeof(struct __call_single_data)); > Good, I will change to use this. >> >> static void blk_mq_insert_request(struct request *rq, blk_insert_t flags); >> static void blk_mq_request_bypass_insert(struct request *rq, >> @@ -1156,13 +1157,13 @@ static void blk_mq_complete_send_ipi(struct request *rq) >> { >> struct llist_head *list; >> unsigned int cpu; >> + struct __call_single_data *csd; >> >> cpu = rq->mq_ctx->cpu; >> list = &per_cpu(blk_cpu_done, cpu); >> - if (llist_add(&rq->ipi_list, list)) { >> - INIT_CSD(&rq->csd, __blk_mq_complete_request_remote, rq); >> - smp_call_function_single_async(cpu, &rq->csd); >> - } >> + csd = &per_cpu(blk_cpu_csd, cpu); >> + if (llist_add(&rq->ipi_list, list)) >> + smp_call_function_single_async(cpu, csd); >> } > > This way is cleaner, and looks correct, given block softirq is guaranteed to be > scheduled to consume the list if one new request is added to this percpu list, > either smp_call_function_single_async() returns -EBUSY or 0. > If this llist_add() see the llist is empty, the consumer function in the softirq on the remote CPU must have consumed the llist, so smp_call_function_single_async() won't return -EBUSY ? Thanks.