Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fd22067 authored by Jin Qian's avatar Jin Qian Committed by Alistair Strachan
Browse files

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: default avatarJin Qian <jinqian@google.com>
[AmitP: Refactored changes to align with changes from upstream commit
        9a070004 ("sched/headers: Move CONFIG_TASK_XACCT bits from <linux/sched.h> to <linux/sched/xacct.h>")]
Signed-off-by: default avatarAmit 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: default avatarAlistair Strachan <astrachan@google.com>
parent f4eeb5d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ config MISC_RTSX

config UID_SYS_STATS
	bool "Per-UID statistics"
	depends on PROFILING && TASK_IO_ACCOUNTING
	depends on PROFILING && TASK_XACCT && TASK_IO_ACCOUNTING
	help
	  Per UID based cpu time statistics exported to /proc/uid_cputime
	  Per UID based io statistics exported to /proc/uid_io
+2 −0
Original line number Diff line number Diff line
@@ -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->rchar += task->ioac.rchar;
	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)
@@ -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->rchar += task->ioac.rchar;
	io_slot->wchar += task->ioac.wchar;
	io_slot->fsync += task->ioac.syscfs;

	add_uid_tasks_io_stats(uid_entry, task, slot);
}
+2 −1
Original line number Diff line number Diff line
@@ -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>
@@ -220,6 +220,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;
}
+9 −0
Original line number Diff line number Diff line
@@ -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 */
+2 −0
Original line number Diff line number Diff line
@@ -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
Loading