[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6f52b55-a991-1179-75cb-bf8fce8f6783@linux.dev>
Date: Thu, 6 Jul 2023 22:23:49 +0800
From: Chengming Zhou <chengming.zhou@...ux.dev>
To: Christoph Hellwig <hch@....de>
Cc: axboe@...nel.dk, ming.lei@...hat.com, tj@...nel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
Chengming Zhou <zhouchengming@...edance.com>
Subject: Re: [PATCH v2 1/4] blk-mq: use percpu csd to remote complete instead
of per-rq csd
On 2023/7/6 21:07, Christoph Hellwig wrote:
> On Thu, Jun 29, 2023 at 07:03:56PM +0800, chengming.zhou@...ux.dev wrote:
>> From: Chengming Zhou <zhouchengming@...edance.com>
>>
>> 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!
Powered by blists - more mailing lists