14 Dec, 2006

1 commit

  • 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: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Russell King
    Cc: David Howells
    Cc: Andi Kleen
    Cc: "Luck, Tony"
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

11 Dec, 2006

1 commit

  • 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: Randy Dunlap
    Acked-by: Dave Kleikamp
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

08 Dec, 2006

3 commits

  • Move the loop from thaw_processes() to a separate function and call it
    independently for kernel threads and user space processes so that the order
    of thawing tasks is clearly visible.

    Drop thaw_kernel_threads() which is never used.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Modify process thawing so that we can thaw kernel space without thawing
    userspace, and thaw kernelspace first. This will be useful in later
    patches, where I intend to get swsusp thawing kernel threads only before
    seeking to free memory.

    Signed-off-by: Nigel Cunningham
    Cc: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nigel Cunningham
     
  • Move process freezing functions from include/linux/sched.h to freezer.h, so
    that modifications to the freezer or the kernel configuration don't require
    recompiling just about everything.

    [akpm@osdl.org: fix ueagle driver]
    Signed-off-by: Nigel Cunningham
    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nigel Cunningham