1. 24 5月, 2007 1 次提交
    • R
      freezer: close potential race between refrigerator and thaw_tasks · 33e1c288
      Rafael J. Wysocki 提交于
      If the freezing of tasks fails and a task is preempted in refrigerator()
      before calling frozen_process(), then thaw_tasks() may run before this task is
      frozen.  In that case the task will freeze and no one will thaw it.
      
      To fix this race we can call freezing(current) in refrigerator() along with
      frozen_process(current) under the task_lock() which also should be taken in
      the error path of try_to_freeze_tasks() as well as in thaw_process().
      Moreover, if thaw_process() additionally clears TIF_FREEZE for tasks that are
      not frozen, we can be sure that all tasks are thawed and there are no pending
      "freeze" requests after thaw_tasks() has run.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      33e1c288
  2. 14 12月, 2006 1 次提交
    • R
      [PATCH] PM: Fix SMP races in the freezer · 8a102eed
      Rafael J. Wysocki 提交于
      Currently, to tell a task that it should go to the refrigerator, we set the
      PF_FREEZE flag for it and send a fake signal to it.  Unfortunately there
      are two SMP-related problems with this approach.  First, a task running on
      another CPU may be updating its flags while the freezer attempts to set
      PF_FREEZE for it and this may leave the task's flags in an inconsistent
      state.  Second, there is a potential race between freeze_process() and
      refrigerator() in which freeze_process() running on one CPU is reading a
      task's PF_FREEZE flag while refrigerator() running on another CPU has just
      set PF_FROZEN for the same task and attempts to reset PF_FREEZE for it.  If
      the refrigerator wins the race, freeze_process() will state that PF_FREEZE
      hasn't been set for the task and will set it unnecessarily, so the task
      will go to the refrigerator once again after it's been thawed.
      
      To solve first of these problems we need to stop using PF_FREEZE to tell
      tasks that they should go to the refrigerator.  Instead, we can introduce a
      special TIF_*** flag and use it for this purpose, since it is allowed to
      change the other tasks' TIF_*** flags and there are special calls for it.
      
      To avoid the freeze_process()-refrigerator() race we can make
      freeze_process() to always check the task's PF_FROZEN flag after it's read
      its "freeze" flag.  We should also make sure that refrigerator() will
      always reset the task's "freeze" flag after it's set PF_FROZEN for it.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Andi Kleen <ak@muc.de>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      8a102eed
  3. 11 12月, 2006 1 次提交
    • R
      [PATCH] freezer.h uses task_struct fields · 5c543eff
      Randy Dunlap 提交于
      freezer.h uses task_struct fields so it should include sched.h.
      
        CC [M]  fs/jfs/jfs_txnmgr.o
      In file included from fs/jfs/jfs_txnmgr.c:49:
      include/linux/freezer.h: In function 'frozen':
      include/linux/freezer.h:9: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:9: error: 'PF_FROZEN' undeclared (first use in this function)
      include/linux/freezer.h:9: error: (Each undeclared identifier is reported only once
      include/linux/freezer.h:9: error: for each function it appears in.)
      include/linux/freezer.h: In function 'freezing':
      include/linux/freezer.h:17: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:17: error: 'PF_FREEZE' undeclared (first use in this function)
      include/linux/freezer.h: In function 'freeze':
      include/linux/freezer.h:26: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:26: error: 'PF_FREEZE' undeclared (first use in this function)
      include/linux/freezer.h: In function 'do_not_freeze':
      include/linux/freezer.h:34: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:34: error: 'PF_FREEZE' undeclared (first use in this function)
      include/linux/freezer.h: In function 'thaw_process':
      include/linux/freezer.h:43: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:43: error: 'PF_FROZEN' undeclared (first use in this function)
      include/linux/freezer.h:44: warning: implicit declaration of function 'wake_up_process'
      include/linux/freezer.h: In function 'frozen_process':
      include/linux/freezer.h:55: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:55: error: dereferencing pointer to incomplete type
      include/linux/freezer.h:55: error: 'PF_FREEZE' undeclared (first use in this function)
      include/linux/freezer.h:55: error: 'PF_FROZEN' undeclared (first use in this function)
      fs/jfs/jfs_txnmgr.c: In function 'freezing':
      include/linux/freezer.h:18: warning: control reaches end of non-void function
      make[2]: *** [fs/jfs/jfs_txnmgr.o] Error 1
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Acked-by: NDave Kleikamp <shaggy@linux.vnet.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      5c543eff
  4. 08 12月, 2006 3 次提交