Re: [PATCH] mm,oom: Do not unfreeze OOM victim thread.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tetsuo,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16-rc7 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Tetsuo-Handa/mm-oom-Do-not-unfreeze-OOM-victim-thread/20180330-215548
config: i386-randconfig-s1-201812 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:10:0,
                    from include/linux/interrupt.h:6,
                    from kernel/power/process.c:12:
   kernel/power/process.c: In function 'freeze_processes':
   kernel/power/process.c:154:17: error: too many arguments to function 'oom_killer_disable'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
                    ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> kernel/power/process.c:154:2: note: in expansion of macro 'if'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
     ^~
   In file included from kernel/power/process.c:13:0:
   include/linux/oom.h:109:13: note: declared here
    extern bool oom_killer_disable(void);
                ^~~~~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:10:0,
                    from include/linux/interrupt.h:6,
                    from kernel/power/process.c:12:
   kernel/power/process.c:154:17: error: too many arguments to function 'oom_killer_disable'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
                    ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> kernel/power/process.c:154:2: note: in expansion of macro 'if'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
     ^~
   In file included from kernel/power/process.c:13:0:
   include/linux/oom.h:109:13: note: declared here
    extern bool oom_killer_disable(void);
                ^~~~~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:10:0,
                    from include/linux/interrupt.h:6,
                    from kernel/power/process.c:12:
   kernel/power/process.c:154:17: error: too many arguments to function 'oom_killer_disable'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
                    ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> kernel/power/process.c:154:2: note: in expansion of macro 'if'
     if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
     ^~
   In file included from kernel/power/process.c:13:0:
   include/linux/oom.h:109:13: note: declared here
    extern bool oom_killer_disable(void);
                ^~~~~~~~~~~~~~~~~~

vim +/if +154 kernel/power/process.c

^1da177e4c Linus Torvalds    2005-04-16   11  
^1da177e4c Linus Torvalds    2005-04-16  @12  #include <linux/interrupt.h>
1a8670a29b Alexey Dobriyan   2009-09-21   13  #include <linux/oom.h>
^1da177e4c Linus Torvalds    2005-04-16   14  #include <linux/suspend.h>
^1da177e4c Linus Torvalds    2005-04-16   15  #include <linux/module.h>
b17b01533b Ingo Molnar       2017-02-08   16  #include <linux/sched/debug.h>
299300258d Ingo Molnar       2017-02-08   17  #include <linux/sched/task.h>
02aaeb9b95 Rafael J. Wysocki 2006-03-23   18  #include <linux/syscalls.h>
7dfb71030f Nigel Cunningham  2006-12-06   19  #include <linux/freezer.h>
be404f0212 Tejun Heo         2009-10-08   20  #include <linux/delay.h>
a0a1a5fd4f Tejun Heo         2010-06-29   21  #include <linux/workqueue.h>
1e73203cd1 Rafael J. Wysocki 2012-03-28   22  #include <linux/kmod.h>
bb3632c610 Todd E Brandt     2014-06-06   23  #include <trace/events/power.h>
50e7663233 Peter Zijlstra    2017-09-07   24  #include <linux/cpuset.h>
^1da177e4c Linus Torvalds    2005-04-16   25  
^1da177e4c Linus Torvalds    2005-04-16   26  /*
^1da177e4c Linus Torvalds    2005-04-16   27   * Timeout for stopping processes
^1da177e4c Linus Torvalds    2005-04-16   28   */
957d1282bb Li Fei            2013-02-01   29  unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC;
^1da177e4c Linus Torvalds    2005-04-16   30  
839e3407d9 Tejun Heo         2011-11-21   31  static int try_to_freeze_tasks(bool user_only)
^1da177e4c Linus Torvalds    2005-04-16   32  {
^1da177e4c Linus Torvalds    2005-04-16   33  	struct task_struct *g, *p;
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   34  	unsigned long end_time;
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   35  	unsigned int todo;
a0a1a5fd4f Tejun Heo         2010-06-29   36  	bool wq_busy = false;
f7b382b988 Abhilash Jindal   2016-01-31   37  	ktime_t start, end, elapsed;
18ad0c6297 Colin Cross       2013-05-06   38  	unsigned int elapsed_msecs;
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   39  	bool wakeup = false;
18ad0c6297 Colin Cross       2013-05-06   40  	int sleep_usecs = USEC_PER_MSEC;
438e2ce68d Rafael J. Wysocki 2007-10-18   41  
f7b382b988 Abhilash Jindal   2016-01-31   42  	start = ktime_get_boottime();
^1da177e4c Linus Torvalds    2005-04-16   43  
957d1282bb Li Fei            2013-02-01   44  	end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);
a0a1a5fd4f Tejun Heo         2010-06-29   45  
839e3407d9 Tejun Heo         2011-11-21   46  	if (!user_only)
a0a1a5fd4f Tejun Heo         2010-06-29   47  		freeze_workqueues_begin();
a0a1a5fd4f Tejun Heo         2010-06-29   48  
be404f0212 Tejun Heo         2009-10-08   49  	while (true) {
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   50  		todo = 0;
^1da177e4c Linus Torvalds    2005-04-16   51  		read_lock(&tasklist_lock);
a28e785a9f Michal Hocko      2014-10-21   52  		for_each_process_thread(g, p) {
839e3407d9 Tejun Heo         2011-11-21   53  			if (p == current || !freeze_task(p))
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   54  				continue;
d5d8c5976d Rafael J. Wysocki 2007-10-18   55  
5d8f72b55c Oleg Nesterov     2012-10-26   56  			if (!freezer_should_skip(p))
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   57  				todo++;
a28e785a9f Michal Hocko      2014-10-21   58  		}
^1da177e4c Linus Torvalds    2005-04-16   59  		read_unlock(&tasklist_lock);
a0a1a5fd4f Tejun Heo         2010-06-29   60  
839e3407d9 Tejun Heo         2011-11-21   61  		if (!user_only) {
a0a1a5fd4f Tejun Heo         2010-06-29   62  			wq_busy = freeze_workqueues_busy();
a0a1a5fd4f Tejun Heo         2010-06-29   63  			todo += wq_busy;
a0a1a5fd4f Tejun Heo         2010-06-29   64  		}
a0a1a5fd4f Tejun Heo         2010-06-29   65  
be404f0212 Tejun Heo         2009-10-08   66  		if (!todo || time_after(jiffies, end_time))
6161b2ce81 Pavel Machek      2005-09-03   67  			break;
be404f0212 Tejun Heo         2009-10-08   68  
a2867e08c8 Rafael J. Wysocki 2010-12-03   69  		if (pm_wakeup_pending()) {
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   70  			wakeup = true;
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   71  			break;
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   72  		}
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   73  
be404f0212 Tejun Heo         2009-10-08   74  		/*
be404f0212 Tejun Heo         2009-10-08   75  		 * We need to retry, but first give the freezing tasks some
18ad0c6297 Colin Cross       2013-05-06   76  		 * time to enter the refrigerator.  Start with an initial
18ad0c6297 Colin Cross       2013-05-06   77  		 * 1 ms sleep followed by exponential backoff until 8 ms.
be404f0212 Tejun Heo         2009-10-08   78  		 */
18ad0c6297 Colin Cross       2013-05-06   79  		usleep_range(sleep_usecs / 2, sleep_usecs);
18ad0c6297 Colin Cross       2013-05-06   80  		if (sleep_usecs < 8 * USEC_PER_MSEC)
18ad0c6297 Colin Cross       2013-05-06   81  			sleep_usecs *= 2;
be404f0212 Tejun Heo         2009-10-08   82  	}
^1da177e4c Linus Torvalds    2005-04-16   83  
f7b382b988 Abhilash Jindal   2016-01-31   84  	end = ktime_get_boottime();
f7b382b988 Abhilash Jindal   2016-01-31   85  	elapsed = ktime_sub(end, start);
f7b382b988 Abhilash Jindal   2016-01-31   86  	elapsed_msecs = ktime_to_ms(elapsed);
438e2ce68d Rafael J. Wysocki 2007-10-18   87  
11b2ce2ba9 Rafael J. Wysocki 2006-12-06   88  	if (todo) {
35536ae170 Michal Hocko      2015-02-11   89  		pr_cont("\n");
35536ae170 Michal Hocko      2015-02-11   90  		pr_err("Freezing of tasks %s after %d.%03d seconds "
a0a1a5fd4f Tejun Heo         2010-06-29   91  		       "(%d tasks refusing to freeze, wq_busy=%d):\n",
dbeeec5fe8 Rafael J. Wysocki 2010-10-04   92  		       wakeup ? "aborted" : "failed",
18ad0c6297 Colin Cross       2013-05-06   93  		       elapsed_msecs / 1000, elapsed_msecs % 1000,
a0a1a5fd4f Tejun Heo         2010-06-29   94  		       todo - wq_busy, wq_busy);
a0a1a5fd4f Tejun Heo         2010-06-29   95  
7b776af66d Roger Lu          2016-07-01   96  		if (wq_busy)
7b776af66d Roger Lu          2016-07-01   97  			show_workqueue_state();
7b776af66d Roger Lu          2016-07-01   98  
6c83b4818d Rafael J. Wysocki 2012-02-11   99  		if (!wakeup) {
6161b2ce81 Pavel Machek      2005-09-03  100  			read_lock(&tasklist_lock);
a28e785a9f Michal Hocko      2014-10-21  101  			for_each_process_thread(g, p) {
6c83b4818d Rafael J. Wysocki 2012-02-11  102  				if (p != current && !freezer_should_skip(p)
6c83b4818d Rafael J. Wysocki 2012-02-11  103  				    && freezing(p) && !frozen(p))
4f598458ea Xiaotian Feng     2010-03-10  104  					sched_show_task(p);
a28e785a9f Michal Hocko      2014-10-21  105  			}
6161b2ce81 Pavel Machek      2005-09-03  106  			read_unlock(&tasklist_lock);
6c83b4818d Rafael J. Wysocki 2012-02-11  107  		}
438e2ce68d Rafael J. Wysocki 2007-10-18  108  	} else {
35536ae170 Michal Hocko      2015-02-11  109  		pr_cont("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000,
18ad0c6297 Colin Cross       2013-05-06  110  			elapsed_msecs % 1000);
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  111  	}
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  112  
e7cd8a7227 Rafael J. Wysocki 2007-07-19  113  	return todo ? -EBUSY : 0;
6161b2ce81 Pavel Machek      2005-09-03  114  }
6161b2ce81 Pavel Machek      2005-09-03  115  
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  116  /**
2aede851dd Rafael J. Wysocki 2011-09-26  117   * freeze_processes - Signal user space processes to enter the refrigerator.
2b44c4db2e Colin Cross       2013-07-24  118   * The current thread will not be frozen.  The same process that calls
2b44c4db2e Colin Cross       2013-07-24  119   * freeze_processes must later call thaw_processes.
03afed8bc2 Tejun Heo         2011-11-21  120   *
03afed8bc2 Tejun Heo         2011-11-21  121   * On success, returns 0.  On failure, -errno and system is fully thawed.
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  122   */
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  123  int freeze_processes(void)
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  124  {
e7cd8a7227 Rafael J. Wysocki 2007-07-19  125  	int error;
11b2ce2ba9 Rafael J. Wysocki 2006-12-06  126  
247bc03742 Rafael J. Wysocki 2012-03-28  127  	error = __usermodehelper_disable(UMH_FREEZING);
1e73203cd1 Rafael J. Wysocki 2012-03-28  128  	if (error)
1e73203cd1 Rafael J. Wysocki 2012-03-28  129  		return error;
1e73203cd1 Rafael J. Wysocki 2012-03-28  130  
2b44c4db2e Colin Cross       2013-07-24  131  	/* Make sure this task doesn't get frozen */
2b44c4db2e Colin Cross       2013-07-24  132  	current->flags |= PF_SUSPEND_TASK;
2b44c4db2e Colin Cross       2013-07-24  133  
a3201227f8 Tejun Heo         2011-11-21  134  	if (!pm_freezing)
a3201227f8 Tejun Heo         2011-11-21  135  		atomic_inc(&system_freezing_cnt);
a3201227f8 Tejun Heo         2011-11-21  136  
33e4f80ee6 Rafael J. Wysocki 2017-06-12  137  	pm_wakeup_clear(true);
35536ae170 Michal Hocko      2015-02-11  138  	pr_info("Freezing user space processes ... ");
a3201227f8 Tejun Heo         2011-11-21  139  	pm_freezing = true;
ebb12db51f Rafael J. Wysocki 2008-06-11  140  	error = try_to_freeze_tasks(true);
2aede851dd Rafael J. Wysocki 2011-09-26  141  	if (!error) {
247bc03742 Rafael J. Wysocki 2012-03-28  142  		__usermodehelper_set_disable_depth(UMH_DISABLED);
35536ae170 Michal Hocko      2015-02-11  143  		pr_cont("done.");
2aede851dd Rafael J. Wysocki 2011-09-26  144  	}
35536ae170 Michal Hocko      2015-02-11  145  	pr_cont("\n");
2aede851dd Rafael J. Wysocki 2011-09-26  146  	BUG_ON(in_atomic());
2aede851dd Rafael J. Wysocki 2011-09-26  147  
c32b3cbe0d Michal Hocko      2015-02-11  148  	/*
c32b3cbe0d Michal Hocko      2015-02-11  149  	 * Now that the whole userspace is frozen we need to disbale
c32b3cbe0d Michal Hocko      2015-02-11  150  	 * the OOM killer to disallow any further interference with
7d2e7a22cf Michal Hocko      2016-10-07  151  	 * killable tasks. There is no guarantee oom victims will
7d2e7a22cf Michal Hocko      2016-10-07  152  	 * ever reach a point they go away we have to wait with a timeout.
c32b3cbe0d Michal Hocko      2015-02-11  153  	 */
7d2e7a22cf Michal Hocko      2016-10-07 @154  	if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
c32b3cbe0d Michal Hocko      2015-02-11  155  		error = -EBUSY;
c32b3cbe0d Michal Hocko      2015-02-11  156  
03afed8bc2 Tejun Heo         2011-11-21  157  	if (error)
03afed8bc2 Tejun Heo         2011-11-21  158  		thaw_processes();
2aede851dd Rafael J. Wysocki 2011-09-26  159  	return error;
2aede851dd Rafael J. Wysocki 2011-09-26  160  }
2aede851dd Rafael J. Wysocki 2011-09-26  161  

:::::: The code at line 154 was first introduced by commit
:::::: 7d2e7a22cf27e7569e6816ccc05dd74248048b30 oom, suspend: fix oom_killer_disable vs. pm suspend properly

:::::: TO: Michal Hocko <mhocko@xxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux