OSDN Git Service

ANDROID: sched: add a counter to track fsync
authorJin Qian <jinqian@google.com>
Thu, 2 Mar 2017 21:32:59 +0000 (13:32 -0800)
committerJin Qian <jinqian@google.com>
Tue, 14 Mar 2017 20:07:19 +0000 (13:07 -0700)
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>
fs/sync.c
include/linux/sched.h
include/linux/task_io_accounting.h
include/linux/task_io_accounting_ops.h

index dd5d171..452179e 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -218,6 +218,7 @@ static int do_fsync(unsigned int fd, int datasync)
        if (f.file) {
                ret = vfs_fsync(f.file, datasync);
                fdput(f);
+               inc_syscfs(current);
        }
        return ret;
 }
index 8be9f0d..5b250c9 100644 (file)
@@ -3227,6 +3227,11 @@ static inline void inc_syscw(struct task_struct *tsk)
 {
        tsk->ioac.syscw++;
 }
+
+static inline void inc_syscfs(struct task_struct *tsk)
+{
+       tsk->ioac.syscfs++;
+}
 #else
 static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
 {
@@ -3243,6 +3248,9 @@ static inline void inc_syscr(struct task_struct *tsk)
 static inline void inc_syscw(struct task_struct *tsk)
 {
 }
+static inline void inc_syscfs(struct task_struct *tsk)
+{
+}
 #endif
 
 #ifndef TASK_SIZE_OF
index bdf855c..2dd338f 100644 (file)
@@ -18,6 +18,8 @@ struct task_io_accounting {
        u64 syscr;
        /* # of write syscalls */
        u64 syscw;
+       /* # of fsync syscalls */
+       u64 syscfs;
 #endif /* CONFIG_TASK_XACCT */
 
 #ifdef CONFIG_TASK_IO_ACCOUNTING
index 4d090f9..1b505c8 100644 (file)
@@ -96,6 +96,7 @@ static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
        dst->wchar += src->wchar;
        dst->syscr += src->syscr;
        dst->syscw += src->syscw;
+       dst->syscfs += src->syscfs;
 }
 #else
 static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,