| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 1 | /* Slow work private definitions | 
 | 2 |  * | 
 | 3 |  * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved. | 
 | 4 |  * Written by David Howells (dhowells@redhat.com) | 
 | 5 |  * | 
 | 6 |  * This program is free software; you can redistribute it and/or | 
 | 7 |  * modify it under the terms of the GNU General Public Licence | 
 | 8 |  * as published by the Free Software Foundation; either version | 
 | 9 |  * 2 of the Licence, or (at your option) any later version. | 
 | 10 |  */ | 
 | 11 |  | 
 | 12 | #define SLOW_WORK_CULL_TIMEOUT (5 * HZ)	/* cull threads 5s after running out of | 
 | 13 | 					 * things to do */ | 
 | 14 | #define SLOW_WORK_OOM_TIMEOUT (5 * HZ)	/* can't start new threads for 5s after | 
 | 15 | 					 * OOM */ | 
 | 16 |  | 
 | 17 | #define SLOW_WORK_THREAD_LIMIT	255	/* abs maximum number of slow-work threads */ | 
 | 18 |  | 
 | 19 | /* | 
 | 20 |  * slow-work.c | 
 | 21 |  */ | 
| David Howells | f13a48b | 2009-12-01 15:36:11 +0000 | [diff] [blame] | 22 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 23 | extern struct slow_work *slow_work_execs[]; | 
 | 24 | extern pid_t slow_work_pids[]; | 
 | 25 | extern rwlock_t slow_work_execs_lock; | 
 | 26 | #endif | 
 | 27 |  | 
 | 28 | extern struct list_head slow_work_queue; | 
 | 29 | extern struct list_head vslow_work_queue; | 
 | 30 | extern spinlock_t slow_work_queue_lock; | 
 | 31 |  | 
 | 32 | /* | 
| David Howells | f13a48b | 2009-12-01 15:36:11 +0000 | [diff] [blame] | 33 |  * slow-work-debugfs.c | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 34 |  */ | 
| David Howells | f13a48b | 2009-12-01 15:36:11 +0000 | [diff] [blame] | 35 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 36 | extern const struct file_operations slow_work_runqueue_fops; | 
 | 37 |  | 
 | 38 | extern void slow_work_new_thread_desc(struct slow_work *, struct seq_file *); | 
 | 39 | #endif | 
 | 40 |  | 
 | 41 | /* | 
 | 42 |  * Helper functions | 
 | 43 |  */ | 
 | 44 | static inline void slow_work_set_thread_pid(int id, pid_t pid) | 
 | 45 | { | 
| David Howells | a53f4f9 | 2010-03-29 13:08:52 +0100 | [diff] [blame] | 46 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 47 | 	slow_work_pids[id] = pid; | 
 | 48 | #endif | 
 | 49 | } | 
 | 50 |  | 
 | 51 | static inline void slow_work_mark_time(struct slow_work *work) | 
 | 52 | { | 
| David Howells | a53f4f9 | 2010-03-29 13:08:52 +0100 | [diff] [blame] | 53 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 54 | 	work->mark = CURRENT_TIME; | 
 | 55 | #endif | 
 | 56 | } | 
 | 57 |  | 
 | 58 | static inline void slow_work_begin_exec(int id, struct slow_work *work) | 
 | 59 | { | 
| David Howells | a53f4f9 | 2010-03-29 13:08:52 +0100 | [diff] [blame] | 60 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 61 | 	slow_work_execs[id] = work; | 
 | 62 | #endif | 
 | 63 | } | 
 | 64 |  | 
 | 65 | static inline void slow_work_end_exec(int id, struct slow_work *work) | 
 | 66 | { | 
| David Howells | a53f4f9 | 2010-03-29 13:08:52 +0100 | [diff] [blame] | 67 | #ifdef CONFIG_SLOW_WORK_DEBUG | 
| David Howells | 8fba10a | 2009-11-19 18:10:51 +0000 | [diff] [blame] | 68 | 	write_lock(&slow_work_execs_lock); | 
 | 69 | 	slow_work_execs[id] = NULL; | 
 | 70 | 	write_unlock(&slow_work_execs_lock); | 
 | 71 | #endif | 
 | 72 | } |