public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Chandan Babu R <chandanbabu@kernel.org>
Cc: linux-xfs@vger.kernel.org, cem@kernel.org
Subject: Re: [PATCH 2/2] repair/prefetch.c: Create one workqueue with multiple workers
Date: Tue, 4 Nov 2025 08:55:34 -0800	[thread overview]
Message-ID: <20251104165534.GH196370@frogsfrogsfrogs> (raw)
In-Reply-To: <20251104091439.1276907-2-chandanbabu@kernel.org>

On Tue, Nov 04, 2025 at 02:44:37PM +0530, Chandan Babu R wrote:
> When xfs_repair is executed with a non-zero value for ag_stride,
> do_inode_prefetch() create multiple workqueues with each of them having just
> one worker thread.
> 
> Since commit 12838bda12e669 ("libfrog: fix overly sleep workqueues"), a
> workqueue can process multiple work items concurrently. Hence, this commit
> replaces the above logic with just one workqueue having multiple workers.
> 
> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>

Yeah, this also makes sense to me.  I wonder if this odd code was some
sort of workaround for the pre-12838bd workqueue behavior?

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  repair/prefetch.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/repair/prefetch.c b/repair/prefetch.c
> index 5ecf19ae9..8cd3416fa 100644
> --- a/repair/prefetch.c
> +++ b/repair/prefetch.c
> @@ -1024,7 +1024,6 @@ do_inode_prefetch(
>  {
>  	int			i;
>  	struct workqueue	queue;
> -	struct workqueue	*queues;
>  	int			queues_started = 0;
>  
>  	/*
> @@ -1056,7 +1055,7 @@ do_inode_prefetch(
>  	/*
>  	 * create one worker thread for each segment of the volume
>  	 */
> -	queues = malloc(thread_count * sizeof(struct workqueue));
> +	create_work_queue(&queue, mp, thread_count);
>  	for (i = 0; i < thread_count; i++) {
>  		struct pf_work_args *wargs;
>  
> @@ -1067,8 +1066,7 @@ do_inode_prefetch(
>  		wargs->dirs_only = dirs_only;
>  		wargs->func = func;
>  
> -		create_work_queue(&queues[i], mp, 1);
> -		queue_work(&queues[i], prefetch_ag_range_work, 0, wargs);
> +		queue_work(&queue, prefetch_ag_range_work, 0, wargs);
>  		queues_started++;
>  
>  		if (wargs->end_ag >= mp->m_sb.sb_agcount)
> @@ -1078,9 +1076,7 @@ do_inode_prefetch(
>  	/*
>  	 * wait for workers to complete
>  	 */
> -	for (i = 0; i < queues_started; i++)
> -		destroy_work_queue(&queues[i]);
> -	free(queues);
> +	destroy_work_queue(&queue);
>  }
>  
>  void
> -- 
> 2.45.2
> 
> 

  parent reply	other threads:[~2025-11-04 16:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04  9:14 [PATCH 1/2] libfrog: Prevent unnecessary waking of worker thread when using bounded workqueues Chandan Babu R
2025-11-04  9:14 ` [PATCH 2/2] repair/prefetch.c: Create one workqueue with multiple workers Chandan Babu R
2025-11-04 10:59   ` Christoph Hellwig
2025-11-04 16:55   ` Darrick J. Wong [this message]
2025-11-06  4:01     ` Chandan Babu R
2025-11-04 10:58 ` [PATCH 1/2] libfrog: Prevent unnecessary waking of worker thread when using bounded workqueues Christoph Hellwig
2025-11-04 16:54 ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251104165534.GH196370@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=chandanbabu@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox