Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

freezer: don't unnecessarily set PF_NOFREEZE explicitly

Some drivers set PF_NOFREEZE in their kthread functions which is
completely unnecessary and racy - some part of freezer code doesn't
consider cases where PF_NOFREEZE is set asynchronous to freezer
operations.

In general, there's no reason to allow setting PF_NOFREEZE explicitly.
Remove them and change the documentation to note that setting
PF_NOFREEZE directly isn't allowed.

-v2: Dropped change to twl4030-irq.c as it no longer uses PF_NOFREEZE.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: "Gustavo F. Padovan" <padovan@profusion.mobi>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: wwang <wei_wang@realsil.com.cn>

Tejun Heo 3a7cbd50 50fb4f7f

+1 -7
+1 -1
Documentation/power/freezing-of-tasks.txt
··· 67 67 68 68 Kernel threads are not freezable by default. However, a kernel thread may clear 69 69 PF_NOFREEZE for itself by calling set_freezable() (the resetting of PF_NOFREEZE 70 - directly is strongly discouraged). From this point it is regarded as freezable 70 + directly is not allowed). From this point it is regarded as freezable 71 71 and must call try_to_freeze() in a suitable place. 72 72 73 73 IV. Why do we do that?
-2
drivers/bluetooth/btmrvl_main.c
··· 475 475 476 476 init_waitqueue_entry(&wait, current); 477 477 478 - current->flags |= PF_NOFREEZE; 479 - 480 478 for (;;) { 481 479 add_wait_queue(&thread->wait_q, &wait); 482 480
-2
drivers/mfd/twl6030-irq.c
··· 138 138 static const unsigned max_i2c_errors = 100; 139 139 int ret; 140 140 141 - current->flags |= PF_NOFREEZE; 142 - 143 141 while (!kthread_should_stop()) { 144 142 int i; 145 143 union {
-2
drivers/staging/rts_pstor/rtsx.c
··· 466 466 struct rtsx_chip *chip = dev->chip; 467 467 struct Scsi_Host *host = rtsx_to_host(dev); 468 468 469 - current->flags |= PF_NOFREEZE; 470 - 471 469 for (;;) { 472 470 if (wait_for_completion_interruptible(&dev->cmnd_ready)) 473 471 break;