Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\process.c Create Date:2022-07-28 09:57:39
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:try_to_freeze_tasks

Proto:static int try_to_freeze_tasks(bool user_only)

Type:int

Parameter:

TypeParameterName
booluser_only
36  bool wq_busy = false
39  bool wakeup = false
40  sleep_usecs = USEC_PER_MSEC
42  start = ktime_get_boottime - Returns monotonic time since boot in ktime_t format* This is similar to CLOCK_MONTONIC/ktime_get, but also includes the* time spent in suspend.
44  end_time = jiffies + msecs_to_jiffies: - convert milliseconds to jiffies*@m: time in milliseconds* conversion is done as follows:* - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)* - 'too large' values [that would result in larger than
46  If Not user_only Then freeze_workqueues_begin()
49  When (true) cycle
50  todo = 0
51  read_lock( & tasklist_lock)
56  If Not freezer_should_skip(p) Then todo++
59  read_unlock( & tasklist_lock)
61  If Not user_only Then
63  todo += wq_busy
66  If Not todo || These inlines deal with timer wrapping correctly. You are * strongly encouraged to use them* 1. Because people otherwise forget* 2. Because if the timer wrap changes in future you won't have to* alter your driver code.(jiffies, end_time) Then Break
69  If pm_wakeup_pending() Then
70  wakeup = true
71  Break
79  usleep_range(sleep_usecs / 2, sleep_usecs)
80  If sleep_usecs < 8 * USEC_PER_MSEC Then sleep_usecs *= 2
84  end = ktime_get_boottime - Returns monotonic time since boot in ktime_t format* This is similar to CLOCK_MONTONIC/ktime_get, but also includes the* time spent in suspend.
85  elapsed = Subtract two ktime_t variables. rem = lhs -rhs: (end, start)
86  elapsed_msecs = ktime_to_ms(elapsed)
88  If todo Then
89  Like KERN_CONT, pr_cont() should only be used when continuing* a line with no newline ('\n') enclosed. Otherwise it defaults* back to KERN_DEFAULT.("\n")
90  pr_err("Freezing of tasks %s after %d.%03d seconds (%d tasks refusing to freeze, wq_busy=%d):\n", wakeup ? "aborted" : "failed", elapsed_msecs / 1000, elapsed_msecs % 1000, todo - wq_busy, wq_busy)
96  If wq_busy Then show_workqueue_state - dump workqueue state* Called from a sysrq handler or try_to_freeze_tasks() and prints out* all busy workqueues and pools.
99  If Not wakeup || pm_debug_messages_on Then
102  If p != current process && Not freezer_should_skip(p) && freezing(p) && Not frozen(p) Then sched_show_task(p)
108  Else
109  Like KERN_CONT, pr_cont() should only be used when continuing* a line with no newline ('\n') enclosed. Otherwise it defaults* back to KERN_DEFAULT.("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000, elapsed_msecs % 1000)
113  Return If todo Then -EBUSY Else 0
Caller
NameDescribe
freeze_processesze_processes - Signal user space processes to enter the refrigerator.* The current thread will not be frozen. The same process that calls* freeze_processes must later call thaw_processes.* On success, returns 0
freeze_kernel_threadsze_kernel_threads - Make freezable kernel threads go to the refrigerator.* On success, returns 0. On failure, -errno and only the kernel threads are* thawed, so as to give a chance to the caller to do additional cleanups