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: <1406114656-16350-2-git-send-email-mgorman@suse.de>
Date:	Wed, 23 Jul 2014 12:24:15 +0100
From:	Mel Gorman <mgorman@...e.de>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Johannes Weiner <hannes@...xchg.org>,
	Michal Hocko <mhocko@...e.cz>, Mel Gorman <mgorman@...e.de>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Linux-MM <linux-mm@...ck.org>
Subject: [PATCH 1/2] mm: Avoid full RCU lookup of memcg for statistics updates

When updating memcg VM statistics like PGFAULT we take the rcu read
lock and lookup the memcg. For statistic updates this is overkill
when the process may not belong to a memcg. This patch adds a light
check to check if a memcg potentially exists. It's race-prone in that
some VM stats may be missed when a process first joins a memcg but
that is not serious enough to justify a constant performance penalty.

The exact impact of this is difficult to quantify because it's timing
sensitive, workload sensitive and sensitive to the RCU options set. However,
broadly speaking there should be less interference due to page fault
activity in both the number of RCU grace periods and their age.

Signed-off-by: Mel Gorman <mgorman@...e.de>
---
 include/linux/memcontrol.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index eb65d29..76fa97d 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -220,6 +220,14 @@ static inline void mem_cgroup_count_vm_event(struct mm_struct *mm,
 {
 	if (mem_cgroup_disabled())
 		return;
+	/*
+	 * For statistic updates it's overkill to take the RCU lock and do
+	 * a fully safe lookup of an associated memcg. Do a simple check
+	 * first. At worst, we miss a few stat updates when a process is
+	 * moved to a memcg for the first time.
+	 */
+	if (!rcu_access_pointer(mm->owner))
+		return;
 	__mem_cgroup_count_vm_event(mm, idx);
 }
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-- 
1.8.4.5

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