commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
Here we take the same fix action by treating PF_IO_WORKERS as PF_KTHREAD
within klp_send_signal function.
Signed-off-by: Dong Kai <redacted>
---
note:
the io threads freeze issue links:
[1] https://lore.kernel.org/io-uring/YEgnIp43%2F6kFn8GL@kevinlocke.name/
[2] https://lore.kernel.org/io-uring/d7350ce7-17dc-75d7-611b-27ebf2cb539b@kernel.dk/
kernel/livepatch/transition.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Joe Lawrence <joe.lawrence@redhat.com> Date: 2021-03-25 02:52:52
On 3/24/21 9:48 PM, Dong Kai wrote:
commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
nit: s/freezeing/freezing
quoted hunk
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
Here we take the same fix action by treating PF_IO_WORKERS as PF_KTHREAD
within klp_send_signal function.
Signed-off-by: Dong Kai <redacted>
---
note:
the io threads freeze issue links:
[1] https://lore.kernel.org/io-uring/YEgnIp43%2F6kFn8GL@kevinlocke.name/
[2] https://lore.kernel.org/io-uring/d7350ce7-17dc-75d7-611b-27ebf2cb539b@kernel.dk/
kernel/livepatch/transition.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(PF_KTHREAD | PF_IO_WORKER) is open coded in soo many places maybe this
is a silly question, but...
If the livepatch code could use fake_signal_wake_up(), we could
consolidate the pattern in klp_send_signals() with the one in
freeze_task(). Then there would only one place for wake up / fake
signal logic.
I don't fully understand the differences in the freeze_task() version,
so I only pose this as a question and not v2 request.
As it is, this change seems logical to me, so:
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Thanks,
-- Joe
From: Miroslav Benes <mbenes@suse.cz> Date: 2021-03-25 09:26:56
On Thu, 25 Mar 2021, Dong Kai wrote:
commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
I suppose this could happen, but it will also affect the live patching
transition if the io threads do not react to signals.
Are you able to reproduce it easily? I mean, is there a testcase I could
use to take a closer look?
Here we take the same fix action by treating PF_IO_WORKERS as PF_KTHREAD
within klp_send_signal function.
From: Miroslav Benes <mbenes@suse.cz> Date: 2021-03-25 09:31:41
(PF_KTHREAD | PF_IO_WORKER) is open coded in soo many places maybe this is a
silly question, but...
If the livepatch code could use fake_signal_wake_up(), we could consolidate
the pattern in klp_send_signals() with the one in freeze_task(). Then there
would only one place for wake up / fake signal logic.
I don't fully understand the differences in the freeze_task() version, so I
only pose this as a question and not v2 request.
The plan was to remove our live patching fake signal completely and use
the new infrastructure Jens proposed in the past.
Something like
Let me verify it still works and there are all the needed pieces merged
for all the architectures we support (x86_64, ppc64le and s390x). I'll
send a proper patch then.
Miroslav
commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
Here we take the same fix action by treating PF_IO_WORKERS as PF_KTHREAD
within klp_send_signal function.
(PF_KTHREAD | PF_IO_WORKER) is open coded in soo many places maybe this is a
silly question, but...
If the livepatch code could use fake_signal_wake_up(), we could consolidate
the pattern in klp_send_signals() with the one in freeze_task(). Then there
would only one place for wake up / fake signal logic.
I don't fully understand the differences in the freeze_task() version, so I
only pose this as a question and not v2 request.
The plan was to remove our live patching fake signal completely and use
the new infrastructure Jens proposed in the past.
That would be great, I've actually been waiting for that to show up!
I would greatly prefer this approach if you deem it suitable for 5.12,
if not we'll still need the temporary work-around for live patching.
--
Jens Axboe
From: Joe Lawrence <joe.lawrence@redhat.com> Date: 2021-03-25 16:44:07
On 3/25/21 5:26 AM, Miroslav Benes wrote:
On Thu, 25 Mar 2021, Dong Kai wrote:
quoted
commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
I suppose this could happen, but it will also affect the live patching
transition if the io threads do not react to signals.
Are you able to reproduce it easily? I mean, is there a testcase I could
use to take a closer look?
If repro is only hypothetical at this point, perhaps we can artificially
create it in selftests? And useful to verify the future change you
mentioned in your other reply?
-- Joe
commit 15b2219facad ("kernel: freezer should treat PF_IO_WORKER like
PF_KTHREAD for freezing") is to fix the freezeing issue of IO threads
by making the freezer not send them fake signals.
Here live patching consistency model call klp_send_signals to wake up
all tasks by send fake signal to all non-kthread which only check the
PF_KTHREAD flag, so it still send signal to io threads which may lead to
freezeing issue of io threads.
I suppose this could happen, but it will also affect the live patching
transition if the io threads do not react to signals.
Are you able to reproduce it easily? I mean, is there a testcase I could
use to take a closer look?
Um... I tried but failed to reproduce this on real environment as i'm
not familiar with the io uring usage.
So i use a tricky way to verify this possibility by the following patch
which create a fake io thread in module and patch the func which is
always within thread running stack. Then the stack check will failed
when transition and trigger the klp_send_signal flow.
This example may not suitable, but you can get my point
Kai
Note: this patch export some symbols just for test via module because if
i create io thread via sysinit, it will receive SIGKILL signal[set by
zap_other_threads] when run init process and exit the loop, weird...
const char *buf, bool exec)
task_unlock(tsk);
perf_event_comm(tsk, exec);
}
+EXPORT_SYMBOL_GPL(__set_task_comm);
/*
* Calling this is the point of no return. None of the failures will be
(*fn)(void *), void *arg, int node)
}
return tsk;
}
+EXPORT_SYMBOL(create_io_thread);
/*
* Ok, this is the main fork-routine.
index 98191218d891..8151d17149a0 100644
--
>> Here we take the same fix action by treating PF_IO_WORKERS as PF_KTHREAD
>> within klp_send_signal function.
>
> Yes, this sounds reasonable.
>
> Miroslav
>
>> Signed-off-by: Dong Kai <dongkai11@huawei.com>
>> ---
>> note:
>> the io threads freeze issue links:
>> [1] https://lore.kernel.org/io-uring/YEgnIp43%2F6kFn8GL@kevinlocke.name/
>> [2] https://lore.kernel.org/io-uring/d7350ce7-17dc-75d7-611b-27ebf2cb539b@kernel.dk/
>>
>> kernel/livepatch/transition.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c
>> index f6310f848f34..0e1c35c8f4b4 100644
>> --- a/kernel/livepatch/transition.c
>> +++ b/kernel/livepatch/transition.c
>> @@ -358,7 +358,7 @@ static void klp_send_signals(void)
>> * Meanwhile the task could migrate itself and the action
>> * would be meaningless. It is not serious though.
>> */
>> - if (task->flags & PF_KTHREAD) {
>> + if (task->flags & (PF_KTHREAD | PF_IO_WORKER)) {
>> /*
>> * Wake up a kthread which sleeps interruptedly and
>> * still has not been migrated.
>
From: Miroslav Benes <mbenes@suse.cz> Date: 2021-03-26 08:40:04
On Thu, 25 Mar 2021, Jens Axboe wrote:
On 3/25/21 3:30 AM, Miroslav Benes wrote:
quoted
quoted
(PF_KTHREAD | PF_IO_WORKER) is open coded in soo many places maybe this is a
silly question, but...
If the livepatch code could use fake_signal_wake_up(), we could consolidate
the pattern in klp_send_signals() with the one in freeze_task(). Then there
would only one place for wake up / fake signal logic.
I don't fully understand the differences in the freeze_task() version, so I
only pose this as a question and not v2 request.
The plan was to remove our live patching fake signal completely and use
the new infrastructure Jens proposed in the past.
That would be great, I've actually been waiting for that to show up!
Sorry about that. I failed to notice that the infrastructure was merged
already. I'll send it soonish.
I would greatly prefer this approach if you deem it suitable for 5.12,
if not we'll still need the temporary work-around for live patching.
I noticed there is 20210326003928.978750-1-axboe@kernel.dk now, so I
suppose we should wait for that to land in mainline and simply do nothing
about PF_IO_WORKER for live patching.
Miroslav