mmc: core: SDXC speed class support
[linux-2.6.git] / include / linux / delayacct.h
index 9572cfa..6cee17c 100644 (file)
 #define _LINUX_DELAYACCT_H
 
 #include <linux/sched.h>
+#include <linux/slab.h>
+
+/*
+ * Per-task flags relevant to delay accounting
+ * maintained privately to avoid exhausting similar flags in sched.h:PF_*
+ * Used to set current->delays->flags
+ */
+#define DELAYACCT_PF_SWAPIN    0x00000001      /* I am doing a swapin */
+#define DELAYACCT_PF_BLKIO     0x00000002      /* I am waiting on IO */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
 
 extern int delayacct_on;       /* Delay accounting turned on/off */
-extern kmem_cache_t *delayacct_cache;
+extern struct kmem_cache *delayacct_cache;
 extern void delayacct_init(void);
 extern void __delayacct_tsk_init(struct task_struct *);
 extern void __delayacct_tsk_exit(struct task_struct *);
+extern void __delayacct_blkio_start(void);
+extern void __delayacct_blkio_end(void);
+extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
+extern __u64 __delayacct_blkio_ticks(struct task_struct *);
+extern void __delayacct_freepages_start(void);
+extern void __delayacct_freepages_end(void);
+
+static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
+{
+       if (p->delays)
+               return (p->delays->flags & DELAYACCT_PF_BLKIO);
+       else
+               return 0;
+}
 
 static inline void delayacct_set_flag(int flag)
 {
@@ -43,14 +66,59 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
 {
        /* reinitialize in case parent's non-null pointer was dup'ed*/
        tsk->delays = NULL;
-       if (unlikely(delayacct_on))
+       if (delayacct_on)
                __delayacct_tsk_init(tsk);
 }
 
-static inline void delayacct_tsk_exit(struct task_struct *tsk)
+/* Free tsk->delays. Called from bad fork and __put_task_struct
+ * where there's no risk of tsk->delays being accessed elsewhere
+ */
+static inline void delayacct_tsk_free(struct task_struct *tsk)
 {
        if (tsk->delays)
-               __delayacct_tsk_exit(tsk);
+               kmem_cache_free(delayacct_cache, tsk->delays);
+       tsk->delays = NULL;
+}
+
+static inline void delayacct_blkio_start(void)
+{
+       delayacct_set_flag(DELAYACCT_PF_BLKIO);
+       if (current->delays)
+               __delayacct_blkio_start();
+}
+
+static inline void delayacct_blkio_end(void)
+{
+       if (current->delays)
+               __delayacct_blkio_end();
+       delayacct_clear_flag(DELAYACCT_PF_BLKIO);
+}
+
+static inline int delayacct_add_tsk(struct taskstats *d,
+                                       struct task_struct *tsk)
+{
+       if (!delayacct_on || !tsk->delays)
+               return 0;
+       return __delayacct_add_tsk(d, tsk);
+}
+
+static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
+{
+       if (tsk->delays)
+               return __delayacct_blkio_ticks(tsk);
+       return 0;
+}
+
+static inline void delayacct_freepages_start(void)
+{
+       if (current->delays)
+               __delayacct_freepages_start();
+}
+
+static inline void delayacct_freepages_end(void)
+{
+       if (current->delays)
+               __delayacct_freepages_end();
 }
 
 #else
@@ -62,8 +130,24 @@ static inline void delayacct_init(void)
 {}
 static inline void delayacct_tsk_init(struct task_struct *tsk)
 {}
-static inline void delayacct_tsk_exit(struct task_struct *tsk)
+static inline void delayacct_tsk_free(struct task_struct *tsk)
+{}
+static inline void delayacct_blkio_start(void)
 {}
+static inline void delayacct_blkio_end(void)
+{}
+static inline int delayacct_add_tsk(struct taskstats *d,
+                                       struct task_struct *tsk)
+{ return 0; }
+static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
+{ return 0; }
+static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
+{ return 0; }
+static inline void delayacct_freepages_start(void)
+{}
+static inline void delayacct_freepages_end(void)
+{}
+
 #endif /* CONFIG_TASK_DELAY_ACCT */
 
 #endif