ANDROID: taskstats: track fsync syscalls
This adds a counter to the taskstats extended accounting fields, which
tracks the number of times fsync is called, and then plumbs it through
to the uid_sys_stats driver.
Bug: 120442023
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>
[AmitP: Refactored changes to align with changes from upstream commit
9a07000400 ("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>
[tkjos: Needed for storaged fsync accounting ("storaged --uid" and
"storaged --task").]
[astrachan: This is modifying a userspace interface and should probably
be reworked]
Signed-off-by: Alistair Strachan <astrachan@google.com>
This commit is contained in:
@@ -515,7 +515,7 @@ config MISC_RTSX
|
|||||||
|
|
||||||
config UID_SYS_STATS
|
config UID_SYS_STATS
|
||||||
bool "Per-UID statistics"
|
bool "Per-UID statistics"
|
||||||
depends on PROFILING && TASK_IO_ACCOUNTING
|
depends on PROFILING && TASK_XACCT && TASK_IO_ACCOUNTING
|
||||||
help
|
help
|
||||||
Per UID based cpu time statistics exported to /proc/uid_cputime
|
Per UID based cpu time statistics exported to /proc/uid_cputime
|
||||||
Per UID based io statistics exported to /proc/uid_io
|
Per UID based io statistics exported to /proc/uid_io
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ static void add_uid_tasks_io_stats(struct uid_entry *uid_entry,
|
|||||||
task_io_slot->write_bytes += compute_write_bytes(task);
|
task_io_slot->write_bytes += compute_write_bytes(task);
|
||||||
task_io_slot->rchar += task->ioac.rchar;
|
task_io_slot->rchar += task->ioac.rchar;
|
||||||
task_io_slot->wchar += task->ioac.wchar;
|
task_io_slot->wchar += task->ioac.wchar;
|
||||||
|
task_io_slot->fsync += task->ioac.syscfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_io_uid_tasks(struct uid_entry *uid_entry)
|
static void compute_io_uid_tasks(struct uid_entry *uid_entry)
|
||||||
@@ -452,6 +453,7 @@ static void add_uid_io_stats(struct uid_entry *uid_entry,
|
|||||||
io_slot->write_bytes += compute_write_bytes(task);
|
io_slot->write_bytes += compute_write_bytes(task);
|
||||||
io_slot->rchar += task->ioac.rchar;
|
io_slot->rchar += task->ioac.rchar;
|
||||||
io_slot->wchar += task->ioac.wchar;
|
io_slot->wchar += task->ioac.wchar;
|
||||||
|
io_slot->fsync += task->ioac.syscfs;
|
||||||
|
|
||||||
add_uid_tasks_io_stats(uid_entry, task, slot);
|
add_uid_tasks_io_stats(uid_entry, task, slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/namei.h>
|
#include <linux/namei.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched/xacct.h>
|
||||||
#include <linux/writeback.h>
|
#include <linux/writeback.h>
|
||||||
#include <linux/syscalls.h>
|
#include <linux/syscalls.h>
|
||||||
#include <linux/linkage.h>
|
#include <linux/linkage.h>
|
||||||
@@ -220,6 +220,7 @@ static int do_fsync(unsigned int fd, int datasync)
|
|||||||
if (f.file) {
|
if (f.file) {
|
||||||
ret = vfs_fsync(f.file, datasync);
|
ret = vfs_fsync(f.file, datasync);
|
||||||
fdput(f);
|
fdput(f);
|
||||||
|
inc_syscfs(current);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ static inline void inc_syscw(struct task_struct *tsk)
|
|||||||
{
|
{
|
||||||
tsk->ioac.syscw++;
|
tsk->ioac.syscw++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void inc_syscfs(struct task_struct *tsk)
|
||||||
|
{
|
||||||
|
tsk->ioac.syscfs++;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
|
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_syscw(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void inc_syscfs(struct task_struct *tsk)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _LINUX_SCHED_XACCT_H */
|
#endif /* _LINUX_SCHED_XACCT_H */
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ struct task_io_accounting {
|
|||||||
u64 syscr;
|
u64 syscr;
|
||||||
/* # of write syscalls */
|
/* # of write syscalls */
|
||||||
u64 syscw;
|
u64 syscw;
|
||||||
|
/* # of fsync syscalls */
|
||||||
|
u64 syscfs;
|
||||||
#endif /* CONFIG_TASK_XACCT */
|
#endif /* CONFIG_TASK_XACCT */
|
||||||
|
|
||||||
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
|
|||||||
dst->wchar += src->wchar;
|
dst->wchar += src->wchar;
|
||||||
dst->syscr += src->syscr;
|
dst->syscr += src->syscr;
|
||||||
dst->syscw += src->syscw;
|
dst->syscw += src->syscw;
|
||||||
|
dst->syscfs += src->syscfs;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
|
static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
|
||||||
|
|||||||
Reference in New Issue
Block a user