ANDROID: fs: sched: add a counter to track fsync
authorJin Qian <jinqian@google.com>
Thu, 2 Mar 2017 21:32:59 +0000 (13:32 -0800)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 18 Dec 2017 15:41:22 +0000 (21:11 +0530)
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>
[AmitP: Refactored changes to align with changes from upstream commit
        9a07000400c8 ("sched/headers: Move CONFIG_TASK_XACCT bits from <linux/sched.h> to <linux/sched/xacct.h>")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
fs/sync.c
include/linux/sched/xacct.h
include/linux/task_io_accounting.h
include/linux/task_io_accounting_ops.h

index 83ac79a960dd1aea9aa79932bbb08de662e7abab..12f2aa594c5035e45a31de3211c7c1080b732e07 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -9,7 +9,7 @@
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <linux/namei.h>
-#include <linux/sched.h>
+#include <linux/sched/xacct.h>
 #include <linux/writeback.h>
 #include <linux/syscalls.h>
 #include <linux/linkage.h>
@@ -219,6 +219,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 c078f0a94ceca7ddae6630fc6640f3553d5d8a42..9544c9d9d53465a6c6ee7aebf48c287fde4b5c41 100644 (file)
@@ -28,6 +28,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)
 {
@@ -44,6 +49,10 @@ 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
 
 #endif /* _LINUX_SCHED_XACCT_H */
index 6f6acce064dea535b0a4e6fe84d20a99a3c9a9dd..bb26108ca23c011524567ca3d6456858fc3b642f 100644 (file)
@@ -19,6 +19,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 bb5498bcdd961d2a998dd302b03074adc5ce29ef..733ab62ae14130dc62c8d62e48e45002aa149781 100644 (file)
@@ -97,6 +97,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,