diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-09-26 14:32:27 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-10-16 17:28:52 -0400 |
commit | 2aede851ddf08666f68ffc17be446420e9d2a056 (patch) | |
tree | f63a0477c9fe618cd374065bac4cb5f172aaf7db /include | |
parent | 8f88893c05f2f677f18f2ce5591b4bed5d4a7535 (diff) |
PM / Hibernate: Freeze kernel threads after preallocating memory
There is a problem with the current ordering of hibernate code which
leads to deadlocks in some filesystems' memory shrinkers. Namely,
some filesystems use freezable kernel threads that are inactive when
the hibernate memory preallocation is carried out. Those same
filesystems use memory shrinkers that may be triggered by the
hibernate memory preallocation. If those memory shrinkers wait for
the frozen kernel threads, the hibernate process deadlocks (this
happens with XFS, for one example).
Apparently, it is not technically viable to redesign the filesystems
in question to avoid the situation described above, so the only
possible solution of this issue is to defer the freezing of kernel
threads until the hibernate memory preallocation is done, which is
implemented by this change.
Unfortunately, this requires the memory preallocation to be done
before the "prepare" stage of device freeze, so after this change the
only way drivers can allocate additional memory for their freeze
routines in a clean way is to use PM notifiers.
Reported-by: Christoph <cr2005@u-club.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/freezer.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 1effc8b56b4e..aa56cf31f7ff 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
@@ -49,6 +49,7 @@ extern int thaw_process(struct task_struct *p); | |||
49 | 49 | ||
50 | extern void refrigerator(void); | 50 | extern void refrigerator(void); |
51 | extern int freeze_processes(void); | 51 | extern int freeze_processes(void); |
52 | extern int freeze_kernel_threads(void); | ||
52 | extern void thaw_processes(void); | 53 | extern void thaw_processes(void); |
53 | 54 | ||
54 | static inline int try_to_freeze(void) | 55 | static inline int try_to_freeze(void) |
@@ -171,7 +172,8 @@ static inline void clear_freeze_flag(struct task_struct *p) {} | |||
171 | static inline int thaw_process(struct task_struct *p) { return 1; } | 172 | static inline int thaw_process(struct task_struct *p) { return 1; } |
172 | 173 | ||
173 | static inline void refrigerator(void) {} | 174 | static inline void refrigerator(void) {} |
174 | static inline int freeze_processes(void) { BUG(); return 0; } | 175 | static inline int freeze_processes(void) { return -ENOSYS; } |
176 | static inline int freeze_kernel_threads(void) { return -ENOSYS; } | ||
175 | static inline void thaw_processes(void) {} | 177 | static inline void thaw_processes(void) {} |
176 | 178 | ||
177 | static inline int try_to_freeze(void) { return 0; } | 179 | static inline int try_to_freeze(void) { return 0; } |