From patchwork Tue Dec 10 11:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11282031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDAB7112B for ; Tue, 10 Dec 2019 11:48:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A7672073B for ; Tue, 10 Dec 2019 11:48:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A7672073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D90006B2C25; Tue, 10 Dec 2019 06:48:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D1B7B6B2C26; Tue, 10 Dec 2019 06:48:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94056B2C27; Tue, 10 Dec 2019 06:48:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 991596B2C25 for ; Tue, 10 Dec 2019 06:48:04 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 4BEC64DA4 for ; Tue, 10 Dec 2019 11:48:04 +0000 (UTC) X-FDA: 76249058088.12.owner77_465794b5fdf10 X-Spam-Summary: 2,0,0,9a33c9d7ccb1ce2e,d41d8cd98f00b204,alex.shi@linux.alibaba.com,:cgroups@vger.kernel.org:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:tj@kernel.org:hughd@google.com:khlebnikov@yandex-team.ru:daniel.m.jordan@oracle.com:yang.shi@linux.alibaba.com:willy@infradead.org:shakeelb@google.com:hannes@cmpxchg.org:alex.shi@linux.alibaba.com:mhocko@kernel.org:vdavydov.dev@gmail.com,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1345:1359:1431:1437:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:2901:2914:3138:3139:3140:3141:3142:3353:3865:3867:3868:4321:5007:6119:6261:6737:7514:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13161:13229:13846:14096:14181:14394:14721:14915:21060:21080:21450:21451:21627:21966:21990:30054:30070,0,RBL:115.124.30.44:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL :0,DNSBL X-HE-Tag: owner77_465794b5fdf10 X-Filterd-Recvd-Size: 3792 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 11:48:02 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0TkX6Iwu_1575978474; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TkX6Iwu_1575978474) by smtp.aliyun-inc.com(127.0.0.1); Tue, 10 Dec 2019 19:47:55 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, hannes@cmpxchg.org Cc: Alex Shi , Michal Hocko , Vladimir Davydov Subject: [PATCH v5 8/8] mm/lru: debug checking for page memcg moving and lock_page_memcg Date: Tue, 10 Dec 2019 19:46:24 +0800 Message-Id: <1575978384-222381-9-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575978384-222381-1-git-send-email-alex.shi@linux.alibaba.com> References: <1575978384-222381-1-git-send-email-alex.shi@linux.alibaba.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The extra irq disable/enable and BUG_ON checking costs 5% readtwice performance on a 2 socket * 26 cores * HT box. Need to remove them later? Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Andrew Morton Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/compaction.c | 4 ++++ mm/memcontrol.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index 0907eec3db84..7f750a9100af 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -972,6 +972,10 @@ static bool too_many_isolated(pg_data_t *pgdat) compact_lock_irqsave(&lruvec->lru_lock, &flags, cc); locked_lruvec = lruvec; +#ifdef CONFIG_MEMCG + if (!mem_cgroup_disabled()) + VM_BUG_ON_PAGE(lruvec_memcg(lruvec) != page->mem_cgroup, page); +#endif /* Try get exclusive access under lock */ if (!skip_updated) { skip_updated = true; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4a92689c37d6..833df0ce1bc1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1255,6 +1255,10 @@ struct lruvec *lock_page_lruvec_irq(struct page *page) lruvec = mem_cgroup_lruvec(memcg, page_pgdat(page)); spin_lock_irq(&lruvec->lru_lock); +#ifdef CONFIG_MEMCG + if (!mem_cgroup_disabled()) + VM_BUG_ON_PAGE(lruvec_memcg(lruvec) != page->mem_cgroup, page); +#endif return lruvec; } @@ -1267,6 +1271,10 @@ struct lruvec *lock_page_lruvec_irqsave(struct page *page, unsigned long *flags) lruvec = mem_cgroup_lruvec(memcg, page_pgdat(page)); spin_lock_irqsave(&lruvec->lru_lock, *flags); +#ifdef CONFIG_MEMCG + if (!mem_cgroup_disabled()) + VM_BUG_ON_PAGE(lruvec_memcg(lruvec) != page->mem_cgroup, page); +#endif return lruvec; } @@ -2015,6 +2023,11 @@ struct mem_cgroup *lock_page_memcg(struct page *page) if (unlikely(!memcg)) return NULL; + /* temporary lockdep checking, need remove */ + local_irq_save(flags); + might_lock(&memcg->move_lock); + local_irq_restore(flags); + if (atomic_read(&memcg->moving_account) <= 0) return memcg;