Freezer: Handle uninterruptible tasks
Subsystems (6)
RFC PATCH 1/1 Freezer: Handle uninterruptible tasks
Hi,
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
This mechanism is used to prevent the situations in which the suspend process can deadlock with a task holding a lock needed by it from happening. However, AFAICS, the probability of that happening is very small and if the freezer is removed from the suspend code patch, then the suspend process will be exposed to deadlocking in this manner anyway.
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the TIF_FREEZE and TIF_SIGPENDING flags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
--- include/linux/freezer.h | 44 -------------------------------------------- include/linux/sched.h | 1 - kernel/fork.c | 2 -- kernel/power/process.c | 18 +++++++++++++++++- 4 files changed, 17 insertions(+), 48 deletions(-)
kernel/power/process.c +17 -1
@@ -105,6 +105,16 @@ static void cancel_freezing(struct task_ } } +static int has_mm (struct task_struct *p) +{ +return (p->mm && !(p->flags &PF_BORROWED_MM )); +} + +static int freezer_should_skip (struct task_struct *p) +{ +return (has_mm (p) && (p->state |TASK_UNINTERRUPTIBLE )); +} +static int try_to_freeze_tasks (int freeze_user_space) {struct task_struct *g, *p;
@@ -135,7 +145,7 @@ static int try_to_freeze_tasks(int freez* occuring. */ task_lock (p); -if (!p->mm || (p->flags &PF_BORROWED_MM )) { +if (!has_mm (p)) {task_unlock (p);continue ; }
@@ -144,8 +154,14 @@ static int try_to_freeze_tasks(int freez }else {freeze_task (p); } +/* +* task_lock() is necessary to prevent races with +* use_mm()/unuse_mm() from occuring. +*/ +task_lock (p);if (!freezer_should_skip (p)) todo++; +task_unlock (p); }while_each_thread (g, p);read_unlock (&tasklist_lock);yield ();/* Yield is okay here */
include/linux/freezer.h +0 -44
50 lines not on this page · raw message
include/linux/sched.h +0 -1
@@ -1275,7 +1275,6 @@ static inline void put_task_struct(struc#define PF_SPREAD_SLAB 0x02000000/* Spread some slab caches over cpuset */ #define PF_MEMPOLICY 0x10000000/* Non-default NUMA mempolicy */ #define PF_MUTEX_TESTER 0x20000000/* Thread belongs to the rt mutex tester */ -#define PF_FREEZER_SKIP 0x40000000/* Freezer should not count it as freezeable */ /* * Only the _current_ task can read/write to tsk->flags, but other
kernel/fork.c +0 -2
@@ -1424,9 +1424,7 @@ long do_fork(unsigned long clone_flags, }if (clone_flags &CLONE_VFORK ) { -freezer_do_not_count ();wait_for_completion (&vfork); -freezer_count ();if (unlikely (current->ptrace &PT_TRACE_VFORK_DONE )) { current->ptrace_message = nr;ptrace_notify ((PTRACE_EVENT_VFORK_DONE <<8 ) |SIGTRAP );
Quoted 12 lines · Rafael J. Wysocki
Hi,
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
This mechanism is used to prevent the situations in which the suspend process can deadlock with a task holding a lock needed by it from happening. However, AFAICS, the probability of that happening is very small and if the freezer is removed from the suspend code patch, then the suspend process will be exposed to deadlocking in this manner anyway.
Quoted 8 lines
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
This is a very interesting idea. Are you certain it is safe? That is, if a task is waiting for a mutex and sometime later the mutex becomes available, will the task then enter the freezer immediately -- before it can do any I/O or call any drivers?
If you can't make this guarantee, then you might as well simply not try to freeze any user task until it returns from kernel mode to user mode. And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I had in mind something more complicated. My idea was to define certain mutexes as "freezable", with the thought that it would be okay for a task in the freezer to own freezable mutexes. None of the mutexes needed by drivers or the PM core during a suspend transition should be freezable.
Presumably the VFS locks _would_ fall into the freezable category. In order for this to work, we would have to guarantee the following:
A thread blocked in the kernel waiting for some response from userspace is allowed to hold freezable mutexes but no other locks.
When a thread tries to acquire a freezable mutex, it is allowed to hold other freezable mutexes but no other locks.
When the freezer is running, any task that is blocked on a freezable mutex (maybe also any task that tries to acquire an unlocked freezable mutex) would immediately go into the freezer. So would any task waiting for a response from userspace.
I think this would solve the VFS-related problems (FUSE's and others). But obviously Raphael's approach is preferable, if it works.
Alan Stern
Quoted 12 lines · Rafael J. Wysocki
Hi,
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
This mechanism is used to prevent the situations in which the suspend process can deadlock with a task holding a lock needed by it from happening. However, AFAICS, the probability of that happening is very small and if the freezer is removed from the suspend code patch, then the suspend process will be exposed to deadlocking in this manner anyway.
Quoted 8 lines
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
This is a very interesting idea. Are you certain it is safe? That is, if a task is waiting for a mutex and sometime later the mutex becomes available, will the task then enter the freezer immediately -- before it can do any I/O or call any drivers?
If you can't make this guarantee, then you might as well simply not try to freeze any user task until it returns from kernel mode to user mode. And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I had in mind something more complicated. My idea was to define certain mutexes as "freezable", with the thought that it would be okay for a task in the freezer to own freezable mutexes. None of the mutexes needed by drivers or the PM core during a suspend transition should be freezable.
Presumably the VFS locks _would_ fall into the freezable category. In order for this to work, we would have to guarantee the following:
A thread blocked in the kernel waiting for some response from userspace is allowed to hold freezable mutexes but no other locks.
When a thread tries to acquire a freezable mutex, it is allowed to hold other freezable mutexes but no other locks.
When the freezer is running, any task that is blocked on a freezable mutex (maybe also any task that tries to acquire an unlocked freezable mutex) would immediately go into the freezer. So would any task waiting for a response from userspace.
I think this would solve the VFS-related problems (FUSE's and others). But obviously Raphael's approach is preferable, if it works.
Alan Stern
Hi!
Quoted 3 lines
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
...
Quoted 8 lines
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
I don't think we can do that. I suspect rename looks like:
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something else
If we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi.
Quoted 3 lines · On Saturday 07 July 2007 17:50:18 Pavel Machek wrote:
Hi!
Quoted 1 line
The main limitation of the freezer is that it cannot handle
uninterruptible
Quoted 1 line
Quoted 1 line
tasks. Namely, if there are uninterruptible tasks in the system, the
freezer
Quoted 3 lines
Quoted 1 line
returns an error, which makes it impossible to suspend the system.
...
Quoted 1 line
Unfortunately, this mechanism also leads to severe limitations, such as
that it
Quoted 3 lines
Quoted 3 lines
makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie.
such
Quoted 2 lines
Quoted 2 lines
that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but
the
Quoted 1 line
Quoted 1 line
freezer doesn't wait for them to enter the refrigerator. Nevertheless,
they
Quoted 4 lines
Quoted 1 line
will enter the refrigerator as soon as they change their state.
I don't think we can do that. I suspect rename looks like:
Quoted 8 lines
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something elseIf we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Renaming is a single syscall, so won't the process get frozen when the syscall finishes? The sys_sync will also help here - it will ensure the rename gets flushed before we start on freezing kernel threads.
Perhaps you've just found more logic for keeping the sys_sync there?
Regards,
Nigel
Signature · 2 lines
See http://www.tuxonice.net for Howtos, FAQs, mailing lists, wiki and bugzilla info.
Hi.
Quoted 3 lines · On Saturday 07 July 2007 17:50:18 Pavel Machek wrote:
Hi!
Quoted 1 line
The main limitation of the freezer is that it cannot handle
uninterruptible
Quoted 1 line
Quoted 1 line
tasks. Namely, if there are uninterruptible tasks in the system, the
freezer
Quoted 3 lines
Quoted 1 line
returns an error, which makes it impossible to suspend the system.
...
Quoted 1 line
Unfortunately, this mechanism also leads to severe limitations, such as
that it
Quoted 3 lines
Quoted 3 lines
makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie.
such
Quoted 2 lines
Quoted 2 lines
that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but
the
Quoted 1 line
Quoted 1 line
freezer doesn't wait for them to enter the refrigerator. Nevertheless,
they
Quoted 4 lines
Quoted 1 line
will enter the refrigerator as soon as they change their state.
I don't think we can do that. I suspect rename looks like:
Quoted 8 lines
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something elseIf we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Renaming is a single syscall, so won't the process get frozen when the syscall finishes? The sys_sync will also help here - it will ensure the rename gets flushed before we start on freezing kernel threads.
Perhaps you've just found more logic for keeping the sys_sync there?
Regards,
Nigel
Signature · 2 lines
See http://www.tuxonice.net for Howtos, FAQs, mailing lists, wiki and bugzilla info.
Hi!
Quoted 8 lines
Quoted 8 lines
I don't think we can do that. I suspect rename looks like:
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something else
Quoted 5 lines
Quoted 2 lines
If we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Renaming is a single syscall, so won't the process get frozen when the syscall finishes?
It would be frozen when syscall finishes. But if we freeze it at A) point, we have a problem.
Quoted 1 line
Perhaps you've just found more logic for keeping the
sys_syncthere?
No, I don't think so.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 10 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 8 lines
I don't think we can do that. I suspect rename looks like:
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something else
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Renaming is a single syscall, so won't the process get frozen when the syscall finishes?
It would be frozen when syscall finishes. But if we freeze it at A) point, we have a problem.
With this patch, we don't freeze it. :-)
We do something like "send a freeze request to this task, but don't care if it doesn't freeze".
Now, IMHO, the correctness here is the question of for how long a task can be in TASK_UNINTERRUPTIBLE it it's not stuck (eg. the resource needed is gone indefinitely, like in NFS) and I think that's not very long.
For example, if the tasks sleeps on a mutex, then it waits for another task to release the mutex (interrupt handlers don't use mutexes) and I don't know of any realistic scenario in which it can last in that state throughout freeze_processes().
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 10 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 8 lines
I don't think we can do that. I suspect rename looks like:
write directory entry in source
A) (uninterruptible wait for write)
write directory entry in destination
(uninterruptible wait for write)
write something else
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If we freeze some task in place "A)", we'll write to the disk when the directory write is finished :-(.
Renaming is a single syscall, so won't the process get frozen when the syscall finishes?
It would be frozen when syscall finishes. But if we freeze it at A) point, we have a problem.
With this patch, we don't freeze it. :-)
We do something like "send a freeze request to this task, but don't care if it doesn't freeze".
Now, IMHO, the correctness here is the question of for how long a task can be in TASK_UNINTERRUPTIBLE it it's not stuck (eg. the resource needed is gone indefinitely, like in NFS) and I think that's not very long.
For example, if the tasks sleeps on a mutex, then it waits for another task to release the mutex (interrupt handlers don't use mutexes) and I don't know of any realistic scenario in which it can last in that state throughout freeze_processes().
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 23 lines · Alan Stern
Quoted 12 lines · Rafael J. Wysocki
Hi,
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
This mechanism is used to prevent the situations in which the suspend process can deadlock with a task holding a lock needed by it from happening. However, AFAICS, the probability of that happening is very small and if the freezer is removed from the suspend code patch, then the suspend process will be exposed to deadlocking in this manner anyway.
Quoted 8 lines
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
Quoted 4 lines
This is a very interesting idea. Are you certain it is safe? That is, if a task is waiting for a mutex and sometime later the mutex becomes available, will the task then enter the freezer immediately -- before it can do any I/O or call any drivers?
Well, I _think_ it is safe, although I can't prove it.
Quoted 2 lines
If you can't make this guarantee, then you might as well simply not try to freeze any user task until it returns from kernel mode to user mode.
No, it's not that bad. The majority of user land tasks are not uninterruptible and if they are, then usually for a very short time only.
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to try_to_wake_up() and make it start to trigger after, for example, enabling the nonboot CPUs.
Quoted 16 lines
I had in mind something more complicated. My idea was to define certain mutexes as "freezable", with the thought that it would be okay for a task in the freezer to own freezable mutexes. None of the mutexes needed by drivers or the PM core during a suspend transition should be freezable.
Presumably the VFS locks _would_ fall into the freezable category. In order for this to work, we would have to guarantee the following:
A thread blocked in the kernel waiting for some response from userspace is allowed to hold freezable mutexes but no other locks.
When a thread tries to acquire a freezable mutex, it is allowed to hold other freezable mutexes but no other locks.
Quoted 7 lines
When the freezer is running, any task that is blocked on a freezable mutex (maybe also any task that tries to acquire an unlocked freezable mutex) would immediately go into the freezer. So would any task waiting for a response from userspace.
I think this would solve the VFS-related problems (FUSE's and others).
Well, the main difficluty with that would be to convince people to use it. ;-)
Quoted 1 line
But obviously Raphael's approach is preferable, if it works.
Right now, it sometimes fails to freeze all tasks that in theory should be freezable. Investigating.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 23 lines · Alan Stern
Quoted 12 lines · Rafael J. Wysocki
Hi,
The main limitation of the freezer is that it cannot handle uninterruptible tasks. Namely, if there are uninterruptible tasks in the system, the freezer returns an error, which makes it impossible to suspend the system.
This mechanism is used to prevent the situations in which the suspend process can deadlock with a task holding a lock needed by it from happening. However, AFAICS, the probability of that happening is very small and if the freezer is removed from the suspend code patch, then the suspend process will be exposed to deadlocking in this manner anyway.
Quoted 8 lines
Unfortunately, this mechanism also leads to severe limitations, such as that it makes the freezer unable to handle systems using FUSE in a reliable way.
This patch makes the freezer skip uninterruptible user space tasks (ie. such that have an mm of their own) when counting the tasks to be frozen. As a result, these tasks have the
TIF_FREEZEandTIF_SIGPENDINGflags set, but the freezer doesn't wait for them to enter the refrigerator. Nevertheless, they will enter the refrigerator as soon as they change their state.
Quoted 4 lines
This is a very interesting idea. Are you certain it is safe? That is, if a task is waiting for a mutex and sometime later the mutex becomes available, will the task then enter the freezer immediately -- before it can do any I/O or call any drivers?
Well, I _think_ it is safe, although I can't prove it.
Quoted 2 lines
If you can't make this guarantee, then you might as well simply not try to freeze any user task until it returns from kernel mode to user mode.
No, it's not that bad. The majority of user land tasks are not uninterruptible and if they are, then usually for a very short time only.
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to try_to_wake_up() and make it start to trigger after, for example, enabling the nonboot CPUs.
Quoted 16 lines
I had in mind something more complicated. My idea was to define certain mutexes as "freezable", with the thought that it would be okay for a task in the freezer to own freezable mutexes. None of the mutexes needed by drivers or the PM core during a suspend transition should be freezable.
Presumably the VFS locks _would_ fall into the freezable category. In order for this to work, we would have to guarantee the following:
A thread blocked in the kernel waiting for some response from userspace is allowed to hold freezable mutexes but no other locks.
When a thread tries to acquire a freezable mutex, it is allowed to hold other freezable mutexes but no other locks.
Quoted 7 lines
When the freezer is running, any task that is blocked on a freezable mutex (maybe also any task that tries to acquire an unlocked freezable mutex) would immediately go into the freezer. So would any task waiting for a response from userspace.
I think this would solve the VFS-related problems (FUSE's and others).
Well, the main difficluty with that would be to convince people to use it. ;-)
Quoted 1 line
But obviously Raphael's approach is preferable, if it works.
Right now, it sometimes fails to freeze all tasks that in theory should be freezable. Investigating.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Hi!
Quoted 9 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
I agree that it is relatively unlikely to trigger (if you avoid freezing the tasks that were uninterruptible for long), but it will trigger in error cases etc.
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 9 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
I agree that it is relatively unlikely to trigger (if you avoid freezing the tasks that were uninterruptible for long), but it will trigger in error cases etc.
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 12 lines · Pavel Machek
Hi!
Quoted 9 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Quoted 3 lines
I agree that it is relatively unlikely to trigger (if you avoid freezing the tasks that were uninterruptible for long), but it will trigger in error cases etc.
Yes, it will.
Quoted 11 lines
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
From the image/filesystems integrity standpoint, yes, that should be
sufficient.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 12 lines · Pavel Machek
Hi!
Quoted 9 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Quoted 3 lines
I agree that it is relatively unlikely to trigger (if you avoid freezing the tasks that were uninterruptible for long), but it will trigger in error cases etc.
Yes, it will.
Quoted 11 lines
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
From the image/filesystems integrity standpoint, yes, that should be
sufficient.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Hi!
Quoted 10 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.
Hmm, okay, I see how you meant it. Yes, it probably could work... but I'd say it is seriously ugly.
Imagine task waking up after complete image is written... we'd have to invalidate the image before aborting the suspend.
Actually, we could do better: we could just refuse to run those tasks after atomic snapshot... and hope we don't deadlock,because the uninterruptible task holds some important lock... but I still think it is too ugly.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 10 lines
Quoted 2 lines
And then you will face the problem of a user task doing I/O during hibernate after the atomic snapshot has been made.
I don't think that this is possible in normal conditions. It would be possible if, for example, the task were waiting for an unavailable resource and that resource became available after the hibernation image had been created. In that case, however, to do any damage, the task would have to cause some filesystem-related data to be flushed in the same syscall (ie. before returning to user space).
Quoted 5 lines
Such situations may be prevented by a mechanizm detecting if any uniterruptible and freezing task has been woken up after creating the image and aborting the hibernation in that cases. For this purpose, we only need to add an appropriate condition to
try_to_wake_up()and make it start to trigger after, for example, enabling the nonboot CPUs.
Hmm, okay, I see how you meant it. Yes, it probably could work... but I'd say it is seriously ugly.
Imagine task waking up after complete image is written... we'd have to invalidate the image before aborting the suspend.
Actually, we could do better: we could just refuse to run those tasks after atomic snapshot... and hope we don't deadlock,because the uninterruptible task holds some important lock... but I still think it is too ugly.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Pavel Machek <[email protected]> writes:
[snip]
Quoted 3 lines
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Any operation at all that has an external effect must not occur after the snapshot is made; otherwise, there will be random hard-to-find corruptions and other problems occurring as a result. Thus, for example, any writes (either directly or indirectly through e.g. a filesystem) to non-volatile storage, any network traffic, any communication with hardware like a printer must be prevented after the snapshot. It seems, though, that in general the kernel will have no way to know which operations are safe, and which are not safe.
(This is why the whole "proper filesystem snapshot support is the solution" argument is bogus.)
Signature · 1 line
Jeremy Maitin-Shepard
Quoted 8 lines · Jeremy Maitin-Shepard
Pavel Machek <[email protected]> writes:
[snip]
Quoted 3 lines
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Quoted 7 lines
Any operation at all that has an external effect must not occur after the snapshot is made; otherwise, there will be random hard-to-find corruptions and other problems occurring as a result. Thus, for example, any writes (either directly or indirectly through e.g. a filesystem) to non-volatile storage, any network traffic, any communication with hardware like a printer must be prevented after the snapshot.
You have forgotten one critical point: The writes to save the snapshot image must be allowed. That's what makes it really hard.
Alan Stern
Quoted 8 lines · Jeremy Maitin-Shepard
Pavel Machek <[email protected]> writes:
[snip]
Quoted 3 lines
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Quoted 7 lines
Any operation at all that has an external effect must not occur after the snapshot is made; otherwise, there will be random hard-to-find corruptions and other problems occurring as a result. Thus, for example, any writes (either directly or indirectly through e.g. a filesystem) to non-volatile storage, any network traffic, any communication with hardware like a printer must be prevented after the snapshot.
You have forgotten one critical point: The writes to save the snapshot image must be allowed. That's what makes it really hard.
Alan Stern
Quoted 17 lines · Alan Stern
Quoted 8 lines · Jeremy Maitin-Shepard
Pavel Machek <[email protected]> writes:
[snip]
Quoted 3 lines
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Quoted 7 lines
Any operation at all that has an external effect must not occur after the snapshot is made; otherwise, there will be random hard-to-find corruptions and other problems occurring as a result. Thus, for example, any writes (either directly or indirectly through e.g. a filesystem) to non-volatile storage, any network traffic, any communication with hardware like a printer must be prevented after the snapshot.
Quoted 2 lines
You have forgotten one critical point: The writes to save the snapshot image must be allowed. That's what makes it really hard.
Well, I didn't forget about that, although my language may have been a bit ambiguous. I was referring only to the operations that are done by normal (i.e. non-hibernate) portions of the system and which are not explicitly for the purpose of hibernating the system. It is very difficult to maintain this guarantee while also attempting to reuse the same infrastructure that is supposed to not be processing any "normal" requests in order to write the snapshot. The kdump approach handily avoids this problem by *not* reusing the same infrastructure while still allowing complete flexibility (i.e. not depending on a drivers/suspend/ide-simple).
Signature · 1 line
Jeremy Maitin-Shepard
Quoted 17 lines · Alan Stern
Quoted 8 lines · Jeremy Maitin-Shepard
Pavel Machek <[email protected]> writes:
[snip]
Quoted 3 lines
I don't know how to do that mechanism... but if we knew where to trap filesystem writes, we could simply freeze at that point, and at that point only, no?
Quoted 7 lines
Any operation at all that has an external effect must not occur after the snapshot is made; otherwise, there will be random hard-to-find corruptions and other problems occurring as a result. Thus, for example, any writes (either directly or indirectly through e.g. a filesystem) to non-volatile storage, any network traffic, any communication with hardware like a printer must be prevented after the snapshot.
Quoted 2 lines
You have forgotten one critical point: The writes to save the snapshot image must be allowed. That's what makes it really hard.
Well, I didn't forget about that, although my language may have been a bit ambiguous. I was referring only to the operations that are done by normal (i.e. non-hibernate) portions of the system and which are not explicitly for the purpose of hibernating the system. It is very difficult to maintain this guarantee while also attempting to reuse the same infrastructure that is supposed to not be processing any "normal" requests in order to write the snapshot. The kdump approach handily avoids this problem by *not* reusing the same infrastructure while still allowing complete flexibility (i.e. not depending on a drivers/suspend/ide-simple).
Signature · 1 line
Jeremy Maitin-Shepard