slow-work.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #define SLOW_WORK_CULL_TIMEOUT (5 * HZ) /* cull threads 5s after running out of
  12. * things to do */
  13. #define SLOW_WORK_OOM_TIMEOUT (5 * HZ) /* can't start new threads for 5s after
  14. * OOM */
  15. #define SLOW_WORK_THREAD_LIMIT 255 /* abs maximum number of slow-work threads */
  16. /*
  17. * slow-work.c
  18. */
  19. #ifdef CONFIG_SLOW_WORK_PROC
  20. extern struct slow_work *slow_work_execs[];
  21. extern pid_t slow_work_pids[];
  22. extern rwlock_t slow_work_execs_lock;
  23. #endif
  24. extern struct list_head slow_work_queue;
  25. extern struct list_head vslow_work_queue;
  26. extern spinlock_t slow_work_queue_lock;
  27. /*
  28. * slow-work-proc.c
  29. */
  30. #ifdef CONFIG_SLOW_WORK_PROC
  31. extern const struct file_operations slow_work_runqueue_fops;
  32. extern void slow_work_new_thread_desc(struct slow_work *, struct seq_file *);
  33. #endif
  34. /*
  35. * Helper functions
  36. */
  37. static inline void slow_work_set_thread_pid(int id, pid_t pid)
  38. {
  39. #ifdef CONFIG_SLOW_WORK_PROC
  40. slow_work_pids[id] = pid;
  41. #endif
  42. }
  43. static inline void slow_work_mark_time(struct slow_work *work)
  44. {
  45. #ifdef CONFIG_SLOW_WORK_PROC
  46. work->mark = CURRENT_TIME;
  47. #endif
  48. }
  49. static inline void slow_work_begin_exec(int id, struct slow_work *work)
  50. {
  51. #ifdef CONFIG_SLOW_WORK_PROC
  52. slow_work_execs[id] = work;
  53. #endif
  54. }
  55. static inline void slow_work_end_exec(int id, struct slow_work *work)
  56. {
  57. #ifdef CONFIG_SLOW_WORK_PROC
  58. write_lock(&slow_work_execs_lock);
  59. slow_work_execs[id] = NULL;
  60. write_unlock(&slow_work_execs_lock);
  61. #endif
  62. }