public inbox for [email protected]
 help / color / mirror / Atom feed
From: Tejun Heo <[email protected]>
To: Hao Xu <[email protected]>
Cc: Jens Axboe <[email protected]>, Zefan Li <[email protected]>,
	Johannes Weiner <[email protected]>,
	Pavel Begunkov <[email protected]>,
	[email protected], [email protected],
	Joseph Qi <[email protected]>,
	Waiman Long <[email protected]>
Subject: Re: [PATCH for-5.15 v2] io_uring: consider cgroup setting when binding sqpoll cpu
Date: Fri, 27 Aug 2021 07:26:00 -1000	[thread overview]
Message-ID: <YSkgKN/[email protected]> (raw)
In-Reply-To: <[email protected]>

Hello,

On Fri, Aug 27, 2021 at 10:13:15PM +0800, Hao Xu wrote:
> +static int io_sq_bind_cpu(int cpu)
> +{
> +	if (!test_cpu_in_current_cpuset(cpu))
> +		pr_warn("sqthread %d: bound cpu not allowed\n", current->pid);
> +	else
> +		set_cpus_allowed_ptr(current, cpumask_of(cpu));
> +
> +	return 0;
> +}
...
> @@ -8208,8 +8217,10 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
>  			int cpu = p->sq_thread_cpu;
>  
>  			ret = -EINVAL;
> -			if (cpu >= nr_cpu_ids || !cpu_online(cpu))
> +			if (cpu >= nr_cpu_ids || !cpu_online(cpu) ||
> +			    !test_cpu_in_current_cpuset(cpu))
>  				goto err_sqpoll;

Given that sq_thread is user-like thread and belongs to the right cgroup,
I'm not quite sure what the above achieves - the affinities can break
anytime, so one-time check doesn't really solve the problem. All it seems to
add is warning messages. What's the expected behavior when an io thread
can't run on the target cpu anymore?

Thanks.

-- 
tejun

  parent reply	other threads:[~2021-08-27 17:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 14:13 [PATCH for-5.15 v2] io_uring: consider cgroup setting when binding sqpoll cpu Hao Xu
2021-08-27 14:18 ` Jens Axboe
2021-08-27 16:57   ` Hao Xu
2021-08-27 17:03     ` Hao Xu
2021-08-27 17:09       ` Jens Axboe
2021-08-28  7:10         ` Hao Xu
2021-08-27 17:26 ` Tejun Heo [this message]
2021-08-28  7:29   ` Hao Xu

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=YSkgKN/[email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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