[Devel,RHEL7,COMMIT] ms/mm: memcontrol: remove ordering between pc->mem_cgroup and PageCgroupUsed

Submitted by Konstantin Khorenko on Jan. 16, 2017, 4:27 p.m.


Message ID 201701161627.v0GGRDli028706@finist_cl7.x64_64.work.ct
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Jan. 16, 2017, 4:27 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.vz7.27.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.vz7.27.10
commit 749786bd77767a1295b9a7cf89d60b8275ce237d
Author: Johannes Weiner <hannes@cmpxchg.org>
Date:   Mon Jan 16 20:27:12 2017 +0400

    ms/mm: memcontrol: remove ordering between pc->mem_cgroup and PageCgroupUsed
    There is a write barrier between setting pc->mem_cgroup and
    PageCgroupUsed, which was added to allow LRU operations to lookup the
    memcg LRU list of a page without acquiring the page_cgroup lock.
    But ever since commit 38c5d72f3ebe ("memcg: simplify LRU handling by new
    rule"), pages are ensured to be off-LRU while charging, so nobody else
    is changing LRU state while pc->mem_cgroup is being written, and there
    are no read barriers anymore.
    Remove the unnecessary write barrier.
    Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
    Acked-by: Michal Hocko <mhocko@suse.cz>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Vladimir Davydov <vdavydov@parallels.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    (cherry picked from commit 9a2385eef9f28fb5260c48c45fc8fe01f1da70a6)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
 mm/memcontrol.c | 9 ---------
 1 file changed, 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cddfb93..2b04b1e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2977,14 +2977,6 @@  static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
 	pc->mem_cgroup = memcg;
-	/*
-	 * We access a page_cgroup asynchronously without lock_page_cgroup().
-	 * Especially when a page_cgroup is taken from a page, pc->mem_cgroup
-	 * is accessed after testing USED bit. To make pc->mem_cgroup visible
-	 * before USED bit, we need memory barrier here.
-	 * See mem_cgroup_add_lru_list(), etc.
- 	 */
-	smp_wmb();
 	if (lrucare) {
@@ -3520,7 +3512,6 @@  void mem_cgroup_split_huge_fixup(struct page *head)
 	for (i = 1; i < HPAGE_PMD_NR; i++) {
 		pc = head_pc + i;
 		pc->mem_cgroup = memcg;
-		smp_wmb();/* see __commit_charge() */
 		pc->flags = head_pc->flags & ~PCGF_NOCOPY_AT_SPLIT;