* [RFC PATCH] accouting: account if a task was killed by OOM killer
@ 2010-01-11 6:40 Xiaotian Feng
2010-01-13 22:54 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Xiaotian Feng @ 2010-01-11 6:40 UTC (permalink / raw)
To: linux-kernel
Cc: Xiaotian Feng, Andrew Morton, Michal Schmidt, David Howells,
Serge Hallyn, Heiko Carstens, Frans Pop
This patch introduces a new accounting flag which is set when a task
was killed by OOM killer. taskstats can tell users when a job has been
killed by the oomkiller.
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Schmidt <mschmidt@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Frans Pop <elendil@planet.nl>
---
Documentation/accounting/taskstats-struct.txt | 2 +-
include/linux/acct.h | 1 +
include/linux/taskstats.h | 2 +-
kernel/acct.c | 2 ++
kernel/tsacct.c | 2 ++
5 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/accounting/taskstats-struct.txt b/Documentation/accounting/taskstats-struct.txt
index e7512c0..c3cf3cf 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -45,7 +45,7 @@ struct taskstats {
__u32 ac_exitcode; /* Exit status */
/* The accounting flags of a task as defined in <linux/acct.h>
- * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG.
+ * Defined values are AFORK, ASU, ACOMPAT, ACORE, AXSIG, and AXOOM.
*/
__u8 ac_flag; /* Record flags */
diff --git a/include/linux/acct.h b/include/linux/acct.h
index 882dc72..bbb5d7c 100644
--- a/include/linux/acct.h
+++ b/include/linux/acct.h
@@ -106,6 +106,7 @@ struct acct_v3
#define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
#define ACORE 0x08 /* ... dumped core */
#define AXSIG 0x10 /* ... was killed by a signal */
+#define AXOOM 0x20 /* ... was killed by OOM killer */
#ifdef __BIG_ENDIAN
#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 341dddb..9d57f68 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -47,7 +47,7 @@ struct taskstats {
__u32 ac_exitcode; /* Exit status */
/* The accounting flags of a task as defined in <linux/acct.h>
- * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG.
+ * Defined values are AFORK, ASU, ACOMPAT, ACORE, AXSIG, and AXOOM.
*/
__u8 ac_flag; /* Record flags */
__u8 ac_nice; /* task_nice */
diff --git a/kernel/acct.c b/kernel/acct.c
index a6605ca..5830423 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -632,6 +632,8 @@ void acct_collect(long exitcode, int group_dead)
pacct->ac_flag |= ACORE;
if (current->flags & PF_SIGNALED)
pacct->ac_flag |= AXSIG;
+ if (test_tsk_thread_flag(current, TIF_MEMDIE))
+ pacct->ac_flag |= AXOOM;
pacct->ac_utime = cputime_add(pacct->ac_utime, current->utime);
pacct->ac_stime = cputime_add(pacct->ac_stime, current->stime);
pacct->ac_minflt += current->min_flt;
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 00d59d0..46a816a 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -52,6 +52,8 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
stats->ac_flag |= ACORE;
if (tsk->flags & PF_SIGNALED)
stats->ac_flag |= AXSIG;
+ if (test_tsk_thread_flag(current, TIF_MEMDIE))
+ stats->ac_flag |= AXOOM;
stats->ac_nice = task_nice(tsk);
stats->ac_sched = tsk->policy;
stats->ac_pid = tsk->pid;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] accouting: account if a task was killed by OOM killer
2010-01-11 6:40 [RFC PATCH] accouting: account if a task was killed by OOM killer Xiaotian Feng
@ 2010-01-13 22:54 ` Andrew Morton
2010-01-14 10:59 ` Xiaotian Feng
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2010-01-13 22:54 UTC (permalink / raw)
To: Xiaotian Feng
Cc: linux-kernel, Michal Schmidt, David Howells, Serge Hallyn,
Heiko Carstens, Frans Pop
On Mon, 11 Jan 2010 14:40:34 +0800
Xiaotian Feng <dfeng@redhat.com> wrote:
> This patch introduces a new accounting flag which is set when a task
> was killed by OOM killer. taskstats can tell users when a job has been
> killed by the oomkiller.
>
Why is this useful? I'd be looking for a description of some
operational scenario where this feature is valuable to an operator?
The description is incomplete. The patch also alters the contents of
the BSD accounting records. That's a change to an ancient interface
and needs a bit of exposure and thought. Is it good to put such a
highly linux-specific and somewhat linux-version-specific field into
such a venerable userspace interface?
If we _do_ decide to change the BSD accounting records in this manner
then presumably a manpage will need to be updated. A cc to
linux-api@vger.kernel.org would be appropriate.
But I'm not very convinced about this whole idea at present, personally.
> include/linux/acct.h | 1 +
> include/linux/taskstats.h | 2 +-
> kernel/acct.c | 2 ++
> kernel/tsacct.c | 2 ++
I'm a bit surprised that getdelays.c doesn't print ac_flag.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] accouting: account if a task was killed by OOM killer
2010-01-13 22:54 ` Andrew Morton
@ 2010-01-14 10:59 ` Xiaotian Feng
0 siblings, 0 replies; 3+ messages in thread
From: Xiaotian Feng @ 2010-01-14 10:59 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, Michal Schmidt, David Howells, Serge Hallyn,
Heiko Carstens, Frans Pop
On 01/14/2010 06:54 AM, Andrew Morton wrote:
> On Mon, 11 Jan 2010 14:40:34 +0800
> Xiaotian Feng<dfeng@redhat.com> wrote:
>
>> This patch introduces a new accounting flag which is set when a task
>> was killed by OOM killer. taskstats can tell users when a job has been
>> killed by the oomkiller.
>>
>
> Why is this useful? I'd be looking for a description of some
> operational scenario where this feature is valuable to an operator?
>
users of taskstats need to know if a job is killed by OOM killer, then
perform some automation jobs or notifications.
But current taskstats logs AXSIG if a job is killed by signal, so users
will be confused by SIGKILL, SIGTERM or OOM killer.
> The description is incomplete. The patch also alters the contents of
> the BSD accounting records. That's a change to an ancient interface
> and needs a bit of exposure and thought. Is it good to put such a
> highly linux-specific and somewhat linux-version-specific field into
> such a venerable userspace interface?
>
> If we _do_ decide to change the BSD accounting records in this manner
> then presumably a manpage will need to be updated. A cc to
> linux-api@vger.kernel.org would be appropriate.
The BSD accounting part is not necessary, I just made it same as
taskstats, we can drop BSD accounting part.
>
> But I'm not very convinced about this whole idea at present, personally.
>
>> include/linux/acct.h | 1 +
>> include/linux/taskstats.h | 2 +-
>> kernel/acct.c | 2 ++
>> kernel/tsacct.c | 2 ++
>
> I'm a bit surprised that getdelays.c doesn't print ac_flag.
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-14 11:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 6:40 [RFC PATCH] accouting: account if a task was killed by OOM killer Xiaotian Feng
2010-01-13 22:54 ` Andrew Morton
2010-01-14 10:59 ` Xiaotian Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox