[PATCH] freezer: add fake signal clearing back when thaw task
From: Lianwei Wang
Date: Mon Jan 21 2013 - 05:21:26 EST
The fake TIF_SIGPENDING is set during freeze userspace process, but it
is not cleared when thaw tasks after below commit:
34b087e freezer: kill unused set_freezable_with_signal()
This will cause the userspace task that wait_event_freezable and friends
return a wrong ERESTARTSYS. This is not good because it waste cpu time to
handle the fake signal.
Try to clear the TIF_SIGPENDING flag for userspace apps when wakeup the
frozen task to fix this issue.
Change-Id: I91c90ad2ee9a46c42e3b39a7384ec81e97bc0394
Signed-off-by: Lianwei Wang <lianwei.wang@xxxxxxxxx>
---
kernel/freezer.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/kernel/freezer.c b/kernel/freezer.c
index c38893b..09557f6 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -46,6 +46,16 @@ bool freezing_slow_path(struct task_struct *p)
}
EXPORT_SYMBOL(freezing_slow_path);
+static void fake_signal_clear(struct task_struct *p)
+{
+ unsigned long flags;
+
+ if (lock_task_sighand(p, &flags)) {
+ recalc_sigpending();
+ unlock_task_sighand(p, &flags);
+ }
+}
+
/* Refrigerator is place where frozen processes are stored :-). */
bool __refrigerator(bool check_kthr_stop)
{
@@ -74,6 +84,10 @@ bool __refrigerator(bool check_kthr_stop)
pr_debug("%s left refrigerator\n", current->comm);
+ if (!(current->flags & PF_KTHREAD))
+ if (test_tsk_thread_flag(current, TIF_SIGPENDING))
+ fake_signal_clear(current);
+
/*
* Restore saved task state before returning. The mb'd version
* needs to be used; otherwise, it might silently break
--
1.7.4.1
--e89a8fb204865e3a4704d6360f5c
Content-Type: application/octet-stream;
name="0001-freezer-add-fake-signal-clearing-back-when-thaw-task.patch"
Content-Disposition: attachment;
filename="0001-freezer-add-fake-signal-clearing-back-when-thaw-task.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hdfirqyj0
RnJvbSAxNzZmY2NlZTE3OGJjMDE4NWQ5Mjg1M2RkMmY1MjFjO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cnJlbnQsIFRJRl9TSUdQRU5ESU5HKSkKKwkJCWZha2Vfc2lnbmFsX2NsZWFyKGN1
cnJlbnQpOworCiAJLyoKIAkgKiBSZXN0b3JlIHNhdmVkIHRhc2sgc3RhdGUgYmVmb3JlIHJldHVy
bmluZy4gIFRoZSBtYidkIHZlcnNpb24KIAkgKiBuZWVkcyB0byBiZSB1c2VkOyBvdGhlcndpc2Us
IGl0IG1pZ2h0IHNpbGVudGx5IGJyZWFrCi0tIAoxLjcuNC4xCgo=
--e89a8fb204865e3a4704d6360f5c--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/