[PATCH 1/1 linux-next RESEND] task IO accounting: add conditional read/write counters

From: Fabian Frederick
Date: Tue Mar 03 2015 - 15:16:49 EST


This patch adds syscre and syscwe respectively effective read/write
syscall counters. We already had syscr/syscw which were
unconditionally incremented. Doing the difference between those
variables could give interesting statistics.

Signed-off-by: Fabian Frederick <fabf@xxxxxxxxx>
---
Documentation/filesystems/proc.txt | 16 ++++++++++++++++
fs/proc/base.c | 4 ++++
include/linux/sched.h | 2 ++
include/linux/task_io_accounting.h | 4 ++++
4 files changed, 26 insertions(+)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 6d37062..34fb7ee 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1541,6 +1541,22 @@ I/O counter: write syscalls
Attempt to count the number of write I/O operations, i.e. syscalls like
write() and pwrite().

+syscre
+------
+
+I/O counter: Effective read syscalls
+Attempt to count the number of effective read I/O operations,
+i.e. syscalls like read() and pread().
+
+
+syscwe
+------
+
+I/O counter: Effective write syscalls
+Attempt to count the number of effective write I/O operations,
+i.e. syscalls like read() and pread().
+
+

read_bytes
----------
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 7a3b82f..54a7c93 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2367,6 +2367,8 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh
"wchar: %llu\n"
"syscr: %llu\n"
"syscw: %llu\n"
+ "syscre: %llu\n"
+ "syscwe: %llu\n"
"read_bytes: %llu\n"
"write_bytes: %llu\n"
"cancelled_write_bytes: %llu\n",
@@ -2374,6 +2376,8 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh
(unsigned long long)acct.wchar,
(unsigned long long)acct.syscr,
(unsigned long long)acct.syscw,
+ (unsigned long long)acct.syscre,
+ (unsigned long long)acct.syscwe,
(unsigned long long)acct.read_bytes,
(unsigned long long)acct.write_bytes,
(unsigned long long)acct.cancelled_write_bytes);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6d77432..ec316ee 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -3020,11 +3020,13 @@ extern int task_can_switch_user(struct user_struct *up,
#ifdef CONFIG_TASK_XACCT
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
{
+ tsk->ioac.syscre++;
tsk->ioac.rchar += amt;
}

static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
{
+ tsk->ioac.syscwe++;
tsk->ioac.wchar += amt;
}

diff --git a/include/linux/task_io_accounting.h b/include/linux/task_io_accounting.h
index bdf855c..bc94291 100644
--- a/include/linux/task_io_accounting.h
+++ b/include/linux/task_io_accounting.h
@@ -18,6 +18,10 @@ struct task_io_accounting {
u64 syscr;
/* # of write syscalls */
u64 syscw;
+ /* # of effective read syscalls */
+ u64 syscre;
+ /* # of effective write syscalls */
+ u64 syscwe;
#endif /* CONFIG_TASK_XACCT */

#ifdef CONFIG_TASK_IO_ACCOUNTING
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/