Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2122930pxa; Mon, 24 Aug 2020 06:00:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykgVAIwpP8Y7togizHg6oiPeDtRcUFSWpDxtMSP2sHANX60UVQ1wHMrH8bNQ7kWPounhUG X-Received: by 2002:a17:906:8614:: with SMTP id o20mr5373582ejx.308.1598274035652; Mon, 24 Aug 2020 06:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598274035; cv=none; d=google.com; s=arc-20160816; b=V3fv9OfCMfT6yCNYsqjtCZs23uRtfOwHp58f5mOZjxgLXXYPFIPvrqMm3i48XLtndR tnLu/W4EmceEKilVlg2W8cXmWLfIthbk9sSecMsimUJo+vhiGq/4KcK2ic/1EMV7x89H IZPpiz616y2DF+ibbWlkFn1xCELKBNvKJKAUFtRS8uluc3x+fRD+dXEbFa7Xjlq7boRN /HeuEK83vuV5ljMV0jH824O87FY5B4mt0kbMWqEiQYl83doX62IrOzejQ/QSdBa4ZREk /Ie2BLWBwybSfEEQXX93r/Nz410pF7gXkmhHrUusozampd7lSWpEgIJHnISpa5gkxQFZ oUuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7Wcqmz6n4o7G8eHyhY0kHj5gqvcU64zHWvkaj2VRKhs=; b=ihyR7uE+JzQsZUgL4qFUQ5qcPwlvBEiXZBG7n5jocT7YqvgIGoyjRTSvaab04y588z iVbdIDxadayLvNWYSjZjHATm5f+XHMOpQNdF3kb0m6cnp5pXKE1VPDPYwbFtxi8YOPVp sGwKuX1Fv/9uXIvXY+UsriArVET077keOBln/iAam0OAj+KuF3Ow4waIkEp7h3XOYrMs 93EpQLGMGoNpK7cFXsJjjhTSrv2O03Yw1WenUi6GnDMEYvA0ccNB89jj0ni19d80FE5q cOua1Rl7njhPD+kYEVxihP/EqK+h39rUuBd1AfaTWJF2ZeaNe2sMLqlbq29OO7rW+9wq 06sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si2858506ejw.602.2020.08.24.06.00.12; Mon, 24 Aug 2020 06:00:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgHXMzc (ORCPT + 99 others); Mon, 24 Aug 2020 08:55:32 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:39562 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726968AbgHXMzW (ORCPT ); Mon, 24 Aug 2020 08:55:22 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R911e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0U6k9-bl_1598273712; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U6k9-bl_1598273712) by smtp.aliyun-inc.com(127.0.0.1); Mon, 24 Aug 2020 20:55:17 +0800 From: Alex Shi To: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com Cc: Michal Hocko Subject: [PATCH v18 12/32] mm/memcg: optimize mem_cgroup_page_lruvec Date: Mon, 24 Aug 2020 20:54:45 +0800 Message-Id: <1598273705-69124-13-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> References: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hugh Dickins Add READ_ONCE on page->mem_cgroup, since we will check it later. Also the page should not be PageTail(page), so add a check. Signed-off-by: Hugh Dickins Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: cgroups@vger.kernel.org --- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 505f54087e82..65c1e873153e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1321,7 +1321,8 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgd goto out; } - memcg = page->mem_cgroup; + VM_BUG_ON_PAGE(PageTail(page), page); + memcg = READ_ONCE(page->mem_cgroup); /* Readahead page is charged too, to see if other page uncharged */ VM_WARN_ON_ONCE_PAGE(!memcg, page); if (!memcg) -- 1.8.3.1