From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Thomas Gleixner <tglx@linutronix.de>, Andrey Vagin <avagin@openvz.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
syzbot+5c54bd3eb218bb595aa9@syzkaller.appspotmail.com,
Dmitry Vyukov <dvyukov@google.com>,
Sebastian Siewior <bigeasy@linutronix.de>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Christian Brauner <brauner@kernel.org>,
Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>,
Pavel Emelyanov <xemul@openvz.org>
Subject: Re: [RFD] posix-timers: CRIU woes
Date: Thu, 11 May 2023 22:54:33 +0800 [thread overview]
Message-ID: <ece41415-868e-9068-c8ff-47f0f1b46997@virtuozzo.com> (raw)
In-Reply-To: <87ilczc7d9.ffs@tglx>
On 11.05.2023 21:42, Thomas Gleixner wrote:
> On Thu, May 11 2023 at 17:52, Pavel Tikhomirov wrote:
>> On 11.05.2023 17:36, Thomas Gleixner wrote:
>>> On Thu, May 11 2023 at 11:17, Pavel Tikhomirov wrote:
>>>> On 10.05.2023 16:16, Andrey Vagin wrote:
>>>>>>
>>>>>> So because of that half thought out user space ABI we are now up the
>>>>>> regression creek without a paddle, unless CRIU can accomodate to a
>>>>>> different restore mechanism to lift this restriction from the kernel.
>>>>>>
>>>>> If you give us a new API to create timers with specified id-s, we will
>>>>> figure out how to live with it. It isn't good to ask users to update
>>>>> CRIU to work on new kernels, but here are reasons and event improvements
>>>>> for CRIU, so I think it's worth it.
>>>>
>>>> I agree, any API to create timers with specified id-s would work for new
>>>> CRIU versions.
>>>
>>> The real question is whether this will cause any upheaval when a new
>>> kernel meets a non-updated CRIU stack.
>>
>> Creation of posix timer would hang forever in this loop
>> https://github.com/checkpoint-restore/criu/blob/33dd66c6fc93c47213aaa0447a94d97ba1fa56ba/criu/pie/restorer.c#L1185
>> if old criu is run on new kernel (without consecutive id allocation) AFAICS.
>
> Yes, because that "sanity" check
>
> if ((long)next_id > args->posix_timers[i].spt.it_id)
>
> which tries to establish whether the kernel provides timer IDs in strict
> increasing order does not work for that case.
Yes, this check is not perfect, but it does at least something: It
detects that posix timer creation missed needed id (if you start from 0
and increase by 1 each time you can not reach number > N before reaching
N).
>
> It "works" to detect the IDR case on older kernels by chance, but not
> under all circumstances. Assume the following case:
>
> Global IDR has a free slot at index 1
>
> Restore tries to create a timer for index 2
>
> That will also loop forever, unless some other process creates a timer
> and occupies the free slot at index 1, right?
Yes on old-old kernel, where there were no ids increasing on
create/delete, CRIU is broken, but CRIU does not support kernels earlier
than 3.11 (https://criu.org/Check_the_kernel#Basic) so probably we are fine.
git describe --contains 5ed67f05f66c
v3.10-rc1~171^2~9
>
> So this needs a fix anyway, which should be done so that the new kernel
> case is at least properly detected.
>
> But even then there is still the problem of "it worked before I upgraded
> the kernel".
>
> IOW, we are still up a creek without a paddle, unless you would be
> willing to utilize the existing CRIU bug to distribute the 'deal with
> new kernel' mechanics as a bug bounty :) >
> Fix for the loop termination below.
It fixes the loop for new kernel, I agree.
>
> Thanks,
>
> tglx
> ---
> criu/pie/restorer.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> --- a/criu/pie/restorer.c
> +++ b/criu/pie/restorer.c
> @@ -1169,10 +1169,10 @@ static int timerfd_arm(struct task_resto
> static int create_posix_timers(struct task_restore_args *args)
> {
> int ret, i;
> - kernel_timer_t next_id;
> + kernel_timer_t next_id, timer_id;
> struct sigevent sev;
>
> - for (i = 0; i < args->posix_timers_n; i++) {
> + for (i = 0, next_id = 0; i < args->posix_timers_n; i++) {
> sev.sigev_notify = args->posix_timers[i].spt.it_sigev_notify;
> sev.sigev_signo = args->posix_timers[i].spt.si_signo;
> #ifdef __GLIBC__
> @@ -1183,25 +1183,27 @@ static int create_posix_timers(struct ta
> sev.sigev_value.sival_ptr = args->posix_timers[i].spt.sival_ptr;
>
> while (1) {
> - ret = sys_timer_create(args->posix_timers[i].spt.clock_id, &sev, &next_id);
> + ret = sys_timer_create(args->posix_timers[i].spt.clock_id, &sev, &timer_id);
> if (ret < 0) {
> pr_err("Can't create posix timer - %d\n", i);
> return ret;
> }
>
> - if (next_id == args->posix_timers[i].spt.it_id)
> + if (timer_id != next_id) {
> + pr_err("Can't create timers, kernel don't give them consequently\n");
> + return -1;
> + }
> +
> + next_id++;
> +
> + if (timer_id == args->posix_timers[i].spt.it_id)
> break;
>
> - ret = sys_timer_delete(next_id);
> + ret = sys_timer_delete(timer_id);
> if (ret < 0) {
> - pr_err("Can't remove temporaty posix timer 0x%x\n", next_id);
> + pr_err("Can't remove temporaty posix timer 0x%x\n", timer_id);
> return ret;
> }
> -
> - if ((long)next_id > args->posix_timers[i].spt.it_id) {
> - pr_err("Can't create timers, kernel don't give them consequently\n");
> - return -1;
> - }
> }
> }
>
>
>
--
Best regards, Tikhomirov Pavel
Senior Software Developer, Virtuozzo.
next prev parent reply other threads:[~2023-05-11 14:56 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 18:48 [patch 00/20] posix-timers: Fixes and cleanups Thomas Gleixner
2023-04-25 18:48 ` [patch 01/20] posix-timers: Prevent RT livelock in itimer_delete() Thomas Gleixner
2023-05-04 17:06 ` Frederic Weisbecker
2023-05-04 18:20 ` Thomas Gleixner
2023-05-05 7:57 ` Thomas Gleixner
2023-06-01 19:00 ` [patch v2 " Thomas Gleixner
2023-06-01 20:16 ` [patch v2a " Thomas Gleixner
2023-06-05 10:59 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:48 ` [patch 02/20] posix-timers: Ensure timer ID search-loop limit is valid Thomas Gleixner
2023-05-05 14:50 ` Frederic Weisbecker
2023-05-05 22:58 ` Thomas Gleixner
2023-05-05 23:36 ` Thomas Gleixner
2023-05-08 21:57 ` Thomas Gleixner
2023-05-09 9:30 ` Thomas Gleixner
2023-05-09 12:50 ` Thomas Gleixner
2023-05-09 21:42 ` [RFD] posix-timers: CRIU woes Thomas Gleixner
2023-05-10 4:36 ` Pavel Tikhomirov
2023-05-10 8:30 ` Thomas Gleixner
2023-05-11 4:12 ` Pavel Tikhomirov
2023-05-11 7:56 ` Peter Zijlstra
2023-05-11 9:32 ` Thomas Gleixner
2023-05-11 10:13 ` David Laight
2023-05-10 8:16 ` Andrey Vagin
2023-05-11 3:17 ` Pavel Tikhomirov
2023-05-11 9:36 ` Thomas Gleixner
2023-05-11 9:52 ` Pavel Tikhomirov
2023-05-11 13:42 ` Thomas Gleixner
2023-05-11 14:54 ` Pavel Tikhomirov [this message]
2023-05-11 15:25 ` Pavel Tikhomirov
2023-05-12 1:21 ` Andrey Vagin
2023-05-31 17:38 ` Thomas Gleixner
2023-05-11 7:49 ` Cyrill Gorcunov
2023-05-10 0:42 ` [patch 02/20] posix-timers: Ensure timer ID search-loop limit is valid Andrey Vagin
2023-05-09 9:42 ` Frederic Weisbecker
2023-05-09 12:04 ` Thomas Gleixner
2023-05-09 12:38 ` Thomas Gleixner
2023-05-09 14:18 ` Frederic Weisbecker
2023-06-01 18:58 ` [patch v2 " Thomas Gleixner
2023-06-05 14:17 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 03/20] posix-timers: Clarify timer_wait_running() comment Thomas Gleixner
2023-05-09 9:50 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 04/20] posix-timers: Cleanup comments about timer ID tracking Thomas Gleixner
2023-05-09 9:58 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 05/20] posix-timers: Add comments about timer lookup Thomas Gleixner
2023-05-09 10:58 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 06/20] posix-timers: Annotate concurrent access to k_itimer::it_signal Thomas Gleixner
2023-05-09 11:04 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] posix-timers: Annotate concurrent access to k_itimer:: It_signal tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 07/20] posix-timers: Set k_itimer::it_signal to NULL on exit() Thomas Gleixner
2023-06-01 10:09 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] posix-timers: Set k_itimer:: It_signal " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 08/20] posix-timers: Remove pointless irqsafe from hash_lock Thomas Gleixner
2023-06-01 10:12 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 09/20] posix-timers: Split release_posix_timers() Thomas Gleixner
2023-06-01 10:25 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 10/20] posix-timers: Document sys_clock_getres() correctly Thomas Gleixner
2023-06-01 10:44 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 11/20] posix-timers: Document common_clock_get() correctly Thomas Gleixner
2023-06-01 11:00 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 12/20] posix-timers: Document sys_clock_getoverrun() Thomas Gleixner
2023-06-01 11:06 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 13/20] posix-timers: Document sys_clock_settime() permissions in place Thomas Gleixner
2023-06-01 11:22 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:50 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 14/20] posix-timers: Document nanosleep() details Thomas Gleixner
2023-06-01 12:30 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 15/20] posix-timers: Add proper comments in do_timer_create() Thomas Gleixner
2023-06-01 12:43 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 16/20] posix-timers: Comment SIGEV_THREAD_ID properly Thomas Gleixner
2023-06-01 12:47 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 17/20] posix-timers: Clarify posix_timer_rearm() comment Thomas Gleixner
2023-06-01 12:52 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 18/20] posix-timers: Clarify posix_timer_fn() comments Thomas Gleixner
2023-06-01 13:21 ` Frederic Weisbecker
2023-06-01 18:43 ` Thomas Gleixner
2023-06-01 19:07 ` Thomas Gleixner
2023-06-05 14:26 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-05 22:17 ` tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 19/20] posix-timers: Remove pointless comments Thomas Gleixner
2023-06-01 13:48 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-05 22:17 ` tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-04-25 18:49 ` [patch 20/20] posix-timers: Polish coding style in a few places Thomas Gleixner
2023-06-01 13:50 ` Frederic Weisbecker
2023-06-05 15:08 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2023-06-05 22:17 ` tip-bot2 for Thomas Gleixner
2023-06-18 20:49 ` tip-bot2 for Thomas Gleixner
2023-06-05 14:32 ` [patch 00/20] posix-timers: Fixes and cleanups Frederic Weisbecker
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=ece41415-868e-9068-c8ff-47f0f1b46997@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=aleksandr.mikhalitsyn@canonical.com \
--cc=anna-maria@linutronix.de \
--cc=avagin@openvz.org \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=dvyukov@google.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=peterz@infradead.org \
--cc=syzbot+5c54bd3eb218bb595aa9@syzkaller.appspotmail.com \
--cc=tglx@linutronix.de \
--cc=xemul@openvz.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
all inboxes | Powered by JetHome®