From: Sergey Kononenko <sergk@sergk.org.ua>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] BSD acct: disk I/O accounting
Date: Tue, 22 Apr 2008 22:05:13 +0300 [thread overview]
Message-ID: <20080422220513.1e5f2736@vingilot.sergknet> (raw)
Hello,
This patch make acct use I/O statistics gathered when
TASK_IO_ACCOUNTING is enabled. getrusage() already uses that statistics,
but also will be helpful to get access to disk I/O statistics through
traditional BSD accounting interface, because many userspace scripts
that process such information not yet adapted to new taskstats API.
Patch against 2.6.25.
Signed-off-by: Sergey Kononenko <sergk@sergk.org.ua>
---
diff -uprN a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
--- a/include/linux/task_io_accounting_ops.h 2008-04-17 02:49:44.000000000 +0000
+++ b/include/linux/task_io_accounting_ops.h 2008-04-22 16:42:17.000000000 +0000
@@ -21,6 +21,11 @@ static inline unsigned long task_io_get_
return p->ioac.read_bytes >> 9;
}
+static inline unsigned long task_io_get_inbytes(const struct task_struct *p)
+{
+ return p->ioac.read_bytes;
+}
+
static inline void task_io_account_write(size_t bytes)
{
current->ioac.write_bytes += bytes;
@@ -35,6 +40,11 @@ static inline unsigned long task_io_get_
return p->ioac.write_bytes >> 9;
}
+static inline unsigned long task_io_get_oubytes(const struct task_struct *p)
+{
+ return p->ioac.write_bytes;
+}
+
static inline void task_io_account_cancelled_write(size_t bytes)
{
current->ioac.cancelled_write_bytes += bytes;
@@ -56,6 +66,11 @@ static inline unsigned long task_io_get_
return 0;
}
+static inline unsigned long task_io_get_inbytes(const struct task_struct *p)
+{
+ return 0;
+}
+
static inline void task_io_account_write(size_t bytes)
{
}
@@ -65,6 +80,11 @@ static inline unsigned long task_io_get_
return 0;
}
+static inline unsigned long task_io_get_oubytes(const struct task_struct *p)
+{
+ return 0;
+}
+
static inline void task_io_account_cancelled_write(size_t bytes)
{
}
diff -uprN a/kernel/acct.c b/kernel/acct.c
--- a/kernel/acct.c 2008-04-17 02:49:44.000000000 +0000
+++ b/kernel/acct.c 2008-04-22 16:42:17.000000000 +0000
@@ -55,6 +55,7 @@
#include <linux/times.h>
#include <linux/syscalls.h>
#include <linux/mount.h>
+#include <linux/task_io_accounting_ops.h>
#include <asm/uaccess.h>
#include <asm/div64.h>
#include <linux/blkdev.h> /* sector_div */
@@ -504,8 +505,8 @@ static void do_acct_process(struct pid_n
ac.ac_majflt = encode_comp_t(pacct->ac_majflt);
ac.ac_exitcode = pacct->ac_exitcode;
spin_unlock_irq(¤t->sighand->siglock);
- ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */
- ac.ac_rw = encode_comp_t(ac.ac_io / 1024);
+ ac.ac_io = encode_comp_t(task_io_get_inbytes(current) + task_io_get_oubytes(current));
+ ac.ac_rw = encode_comp_t(task_io_get_inblock(current) + task_io_get_oublock(current));
ac.ac_swaps = encode_comp_t(0);
/*
reply other threads:[~2008-04-22 19:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080422220513.1e5f2736@vingilot.sergknet \
--to=sergk@sergk.org.ua \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®