lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 24 Oct 2008 17:05:26 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	Paul Menage <menage@...gle.com>, linux-kernel@...r.kernel.org
Subject: [patch] oom: print triggering task's cpuset and mems allowed

When cpusets are enabled, it's necessary to print the triggering task's
set of allowable nodes so the subsequently printed meminfo can be
interpreted correctly.

We also print the task's cpuset name for informational purposes.

Cc: Paul Menage <menage@...gle.com>
Signed-off-by: David Rientjes <rientjes@...gle.com>
---
 include/linux/cpuset.h |    7 +++++++
 kernel/cpuset.c        |   15 +++++++++++++++
 mm/oom_kill.c          |   22 ++++++++++++++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -79,6 +79,7 @@ extern void cpuset_track_online_nodes(void);
 extern int current_cpuset_is_being_rebound(void);
 
 extern void rebuild_sched_domains(void);
+extern int cpuset_get_name(struct task_struct *p, size_t len, char *buffer);
 
 #else /* !CONFIG_CPUSETS */
 
@@ -163,6 +164,12 @@ static inline void rebuild_sched_domains(void)
 	partition_sched_domains(1, NULL, NULL);
 }
 
+static inline int cpuset_get_name(struct task_struct *p, size_t len,
+				  char *buffer)
+{
+	return 0;
+}
+
 #endif /* !CONFIG_CPUSETS */
 
 #endif /* _LINUX_CPUSET_H */
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2339,6 +2339,21 @@ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
 	return nodes_intersects(tsk1->mems_allowed, tsk2->mems_allowed);
 }
 
+/**
+ * cpuset_get_name - grabs the name of @task's cpuset
+ * @task: pointer to task_struct of some task.
+ *
+ * Description: Place @task's cpuset name in @buffer and return the
+ * number of characters copied.  Must hold task_lock(task).
+ */
+int cpuset_get_name(struct task_struct *task, size_t len, char *buffer)
+{
+        struct dentry *dentry;
+        dentry = task_cs(task)->css.cgroup->dentry;
+        return snprintf(buffer, len,
+                        dentry ? (const char *)dentry->d_name.name : "/");
+}
+
 /*
  * Collection of memory_pressure is suppressed unless
  * this flag is enabled by writing "1" to the special
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -305,6 +305,27 @@ static void dump_tasks(const struct mem_cgroup *mem)
 	} while_each_thread(g, p);
 }
 
+#ifdef CONFIG_CPUSETS
+#define BUFFER_LEN	(256)
+
+static void print_task_cpuset(struct task_struct *p)
+{
+	char buffer[BUFFER_LEN];
+
+	if (cpuset_get_name(current, BUFFER_LEN, buffer) > 0) {
+		char nodelist[BUFFER_LEN];
+
+		nodelist_scnprintf(nodelist, BUFFER_LEN, current->mems_allowed);
+		printk(KERN_ERR "%s cpuset=%s mems_allowed=%s\n",
+		       current->comm, buffer, nodelist);
+	}
+}
+#else
+static inline void print_task_cpuset(struct task_struct *p)
+{
+}
+#endif
+
 /*
  * Send SIGKILL to the selected  process irrespective of  CAP_SYS_RAW_IO
  * flag though it's unlikely that  we select a process with CAP_SYS_RAW_IO
@@ -391,6 +412,7 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
 		printk(KERN_WARNING "%s invoked oom-killer: "
 			"gfp_mask=0x%x, order=%d, oomkilladj=%d\n",
 			current->comm, gfp_mask, order, current->oomkilladj);
+		print_task_cpuset(current);
 		dump_stack();
 		show_mem();
 		if (sysctl_oom_dump_tasks)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ