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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1401976841-3899-2-git-send-email-richard@nod.at>
Date:	Thu,  5 Jun 2014 16:00:41 +0200
From:	Richard Weinberger <richard@....at>
To:	hannes@...xchg.org
Cc:	mhocko@...e.cz, bsingharora@...il.com,
	kamezawa.hiroyu@...fujitsu.com, akpm@...ux-foundation.org,
	vdavydov@...allels.com, tj@...nel.org, handai.szj@...bao.com,
	rientjes@...gle.com, oleg@...hat.com, rusty@...tcorp.com.au,
	kirill.shutemov@...ux.intel.com, linux-kernel@...r.kernel.org,
	cgroups@...r.kernel.org, linux-mm@...ck.org,
	Richard Weinberger <richard@....at>
Subject: [RFC][PATCH] oom: Be less verbose if the oom_control event fd has listeners

Don't spam the kernel logs if the oom_control event fd has listeners.
In this case there is no need to print that much lines as user space
will anyway notice that the memory cgroup has reached its limit.

Signed-off-by: Richard Weinberger <richard@....at>
---
 include/linux/memcontrol.h |  6 ++++++
 mm/memcontrol.c            | 20 ++++++++++++++++++++
 mm/oom_kill.c              |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index b569b8b..506a1a9 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -131,6 +131,7 @@ int mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec);
 int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
 unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list);
 void mem_cgroup_update_lru_size(struct lruvec *, enum lru_list, int);
+extern int mem_cgroup_has_listeners(struct mem_cgroup *memcg);
 extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
 					struct task_struct *p);
 extern void mem_cgroup_replace_page_cache(struct page *oldpage,
@@ -358,6 +359,11 @@ mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
 {
 }
 
+static inline int mem_cgroup_has_listeners(struct mem_cgroup *memcg)
+{
+	return 0;
+}
+
 static inline void
 mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 {
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5177c6d..3864c6a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5777,6 +5777,26 @@ static void mem_cgroup_oom_unregister_event(struct mem_cgroup *memcg,
 	spin_unlock(&memcg_oom_lock);
 }
 
+/**
+ * mem_cgroup_has_listeners: Returns true in case we have one ore more
+ * listeners on our oom notifier event fd.
+ * @memcg: The memory cgroup that went over limit
+ */
+int mem_cgroup_has_listeners(struct mem_cgroup *memcg)
+{
+	int ret = 0;
+
+	if (!memcg)
+		goto out;
+
+	spin_lock(&memcg_oom_lock);
+	ret = !list_empty(&memcg->oom_notify);
+	spin_unlock(&memcg_oom_lock);
+
+out:
+	return ret;
+}
+
 static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)
 {
 	struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(sf));
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 3291e82..b5c9433 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -434,7 +434,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
 		return;
 	}
 
-	if (__ratelimit(&oom_rs))
+	if (__ratelimit(&oom_rs) && !mem_cgroup_has_listeners(memcg))
 		dump_header(p, gfp_mask, order, memcg, nodemask);
 
 	task_lock(p);
-- 
1.8.4.2

--
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