From: Jens Axboe <axboe@kernel.dk>
To: Hao Xu <haoxu@linux.alibaba.com>,
Zefan Li <lizefan.x@bytedance.com>, Tejun Heo <tj@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org, cgroups@vger.kernel.org,
Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH for-5.15 v2] io_uring: consider cgroup setting when binding sqpoll cpu
Date: Fri, 27 Aug 2021 11:09:07 -0600 [thread overview]
Message-ID: <9028a8de-a290-a955-1eac-43bec6e8702d@kernel.dk> (raw)
In-Reply-To: <d413acfe-333a-9b7d-aba8-6e99db376fd6@linux.alibaba.com>
On 8/27/21 11:03 AM, Hao Xu wrote:
> 在 2021/8/28 上午12:57, Hao Xu 写道:
>> 在 2021/8/27 下午10:18, Jens Axboe 写道:
>>> On 8/27/21 8:13 AM, Hao Xu wrote:
>>>> Since sqthread is userspace like thread now, it should respect cgroup
>>>> setting, thus we should consider current allowed cpuset when doing
>>>> cpu binding for sqthread.
>>>
>>> In general, this looks way better than v1. Just a few minor comments
>>> below.
>>>
>>>> @@ -7000,6 +7001,16 @@ static bool io_sqd_handle_event(struct
>>>> io_sq_data *sqd)
>>>> return did_sig || test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
>>>> }
>>>> +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;
>>>> +}
>>>
>>> This should not be triggerable, unless the set changes between creation
>>> and the thread being created. Hence maybe the warn is fine. I'd probably
>>> prefer terminating the thread at that point, which would result in an
>>> -EOWNERDEAD return when someone attempts to wake the thread.
>>>
>>> Which is probably OK, as we really should not hit this path.
>> Actually I think cpuset change offen happen in container environment(
>> at leaset in my practice), eg. by resource monitor and balancer. So I
>> did this check to make sure we are still maintain sq_cpu logic at that
>> time as possible as we can. Though the problem is still there during
>> sqthread running time(the cpuset can change at anytime, which changes
>> the cpumask of sqthread)
> And because the cpumask of sqthread may be changed by the cgroup cpuset
> change at any time, so here I just print a warnning rather than
> terminating sqthread due to this 'normal thing'..
Do we even want the warning then? If it's an expected thing, seems very
annoying to warn about it.
--
Jens Axboe
next prev parent reply other threads:[~2021-08-27 17:09 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
[not found] ` <592ba01a-a128-f781-d920-2b480f91c451-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf@public.gmane.org>
2021-08-27 17:03 ` Hao Xu
2021-08-27 17:09 ` Jens Axboe [this message]
[not found] ` <9028a8de-a290-a955-1eac-43bec6e8702d-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2021-08-28 7:10 ` Hao Xu
2021-08-27 17:26 ` Tejun Heo
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=9028a8de-a290-a955-1eac-43bec6e8702d@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=haoxu@linux.alibaba.com \
--cc=io-uring@vger.kernel.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=lizefan.x@bytedance.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