io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hao Xu <haoxu@linux.alibaba.com>
To: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, Zefan Li <lizefan.x@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Pavel Begunkov <asml.silence@gmail.com>,
	io-uring@vger.kernel.org, cgroups@vger.kernel.org,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Waiman Long <longman@redhat.com>
Subject: Re: [PATCH for-5.15 v2] io_uring: consider cgroup setting when binding sqpoll cpu
Date: Sat, 28 Aug 2021 15:29:31 +0800	[thread overview]
Message-ID: <0ceebbaa-a5ce-1e85-4be2-95331bca34ef@linux.alibaba.com> (raw)
In-Reply-To: <YSkgKN/LviOvmeVH@slm.duckdns.org>

在 2021/8/28 上午1:26, Tejun Heo 写道:
> 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
A user of io_uring can pass a cpu id to the kernel to indicate which cpu
the sq_thread should be bound to.
> anytime, so one-time check doesn't really solve the problem. All it seems to
Yes, this a problem.
> add is warning messages. What's the expected behavior when an io thread
> can't run on the target cpu anymore?
A user binds sqthread to some cpu due to some reason which we may not
know, so if the target cpu isn't available anymore, I think cpuset of
sqthread should be as same as the task group's it sits, since we don't
know which cpu we should re-bind it to. And this is the current
behavior. I think Jens knows this question better than I do, Jens?

> 
> Thanks.
> 


      reply	other threads:[~2021-08-28  7:29 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
2021-08-28  7:29   ` Hao Xu [this message]

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=0ceebbaa-a5ce-1e85-4be2-95331bca34ef@linux.alibaba.com \
    --to=haoxu@linux.alibaba.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=io-uring@vger.kernel.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=tj@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;
as well as URLs for NNTP newsgroup(s).