Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30602622rwd; Thu, 6 Jul 2023 08:09:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlRcU7nkM+lv/yASNZuR4OVfEswDT40ggfRmtEI18mMFCokokeIn7ic7YPNqN8pnYOfXhk X-Received: by 2002:a17:90a:6984:b0:262:edb9:bf44 with SMTP id s4-20020a17090a698400b00262edb9bf44mr1530938pjj.19.1688656176534; Thu, 06 Jul 2023 08:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688656176; cv=none; d=google.com; s=arc-20160816; b=QD6JqHDnOcvvhE8swFRPpBjnpga7qSGEyHyB6bxfArSb9Xq9J3caMRfmfDb0/vnBa+ hPI+LP0perQYSqKju4ngrMTql0tmem/Iq2ZQ1acsVqVHw4qi7H2BtT67+WYSWu8GPDlX 5loc6AuAOW6f/wL40fdQldLS9bbo3gMZRDUFCoAqIgW/g9x+dRa7X+ChT2uIiwELEe0g muvtGI4qwlLg9TmjFOmyd7AsY5W0AxyY52iXlBQY+ZlrBQ0jZiriH8HlUsq4/c0ZX9SX L0+kawJfF+ULm61VXo75/l97srLJV1LSyP6fmlEl94gCMZiPeOhnDbaCRVu+o30G6GsN a6wQ== 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=8Y/8f2lfLrDkDpzbIdRTJODIMHeTXUm4sDd+CCLcns8=; fh=dkrf+xUcGDCwU2wfRcP2x2SNulUoamZoteMgK92qt9s=; b=bpmTQ6z7G3w4OWi3a+nVhFaMgE9V0/A2O8QGuYGj3r8BqAEgnVjf5hE/Io0bnBMQhc g0ghrYXNEjMzJL/o90hsV/1oqo3UmeLgB9W91qPanZZO7pNA8LPp+5sH9szTNAO0AM00 NFQk2+E1ddP/nqCtnzmugmQdUYNlvcKhrvihZdkWLDphwz6iD/eWa6qNBD102cF3K5O6 UcqF441IcmMXm+8zmfwasZrKfNsNdhnlcNV4t64ZRgh0FTjzf9DBFMykmujjTBQakR48 RpKMb9LF8zglJ43CAbQOBrtv+uR49bV5ffpIbatSJ4Y48Te66gTK7Mr0ikf/64OIrkeb +mEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kR2LSKOS; 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 lw15-20020a17090b180f00b0026360db338fsi1896959pjb.107.2023.07.06.08.09.21; Thu, 06 Jul 2023 08:09:36 -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=kR2LSKOS; 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 S229968AbjGFOYX (ORCPT + 99 others); Thu, 6 Jul 2023 10:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231630AbjGFOYU (ORCPT ); Thu, 6 Jul 2023 10:24:20 -0400 Received: from out-60.mta1.migadu.com (out-60.mta1.migadu.com [IPv6:2001:41d0:203:375::3c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A23D19B2 for ; Thu, 6 Jul 2023 07:24:18 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688653455; 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=8Y/8f2lfLrDkDpzbIdRTJODIMHeTXUm4sDd+CCLcns8=; b=kR2LSKOSVZBPkevElfkY3NNfjrZ4OLGqrCyp34k+Af+3dbc9oaLe4IgXU4yNN+n845r0Tz T2QOpwr106hAC1hVe1ghZU8n7wprM+DDW49FGftdmkuk/OjokKtttdg7sEthcLnfrAecOn Fhoyz+KzyVan+FQsXSWhp+mHBCaY4/Y= Date: Thu, 6 Jul 2023 22:23:49 +0800 MIME-Version: 1.0 Subject: Re: [PATCH v2 1/4] blk-mq: use percpu csd to remote complete instead of per-rq csd Content-Language: en-US To: Christoph Hellwig Cc: axboe@kernel.dk, ming.lei@redhat.com, tj@kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou References: <20230629110359.1111832-1-chengming.zhou@linux.dev> <20230629110359.1111832-2-chengming.zhou@linux.dev> <20230706130735.GA13089@lst.de> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <20230706130735.GA13089@lst.de> 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 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 2023/7/6 21:07, Christoph Hellwig wrote: > On Thu, Jun 29, 2023 at 07:03:56PM +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. >> >> 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. > > Please trim your commit logs to 73 characters per line so that they > are readable in git log output. Ok, will fix in the next version. > >> 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; >> + call_single_data_t *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); >> } > > No need for the list and csd variables here as they are only used > once. Yes, should I change like below? Looks like much long code. :-) if (llist_add(&rq->ipi_list, &per_cpu(blk_cpu_done, cpu))) smp_call_function_single_async(cpu, &per_cpu(blk_cpu_csd, cpu)); > > But I think this code has a rpboem when it is preemptd between > the llist_add and smp_call_function_single_async. We either need a > get_cpu/put_cpu around them, or instroduce a structure with the list > and csd, and then you can use one pointer from per_cpu and still ensure > the list and csd are for the same CPU. > cpu = rq->mq_ctx->cpu; So it's certainly the same CPU, right? Thanks!