From patchwork Tue Nov 12 14:06:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11239363 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 C58F315AB for ; Tue, 12 Nov 2019 14:06:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 928DE21783 for ; Tue, 12 Nov 2019 14:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 928DE21783 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 9D2D36B0007; Tue, 12 Nov 2019 09:06:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 90D8E6B0008; Tue, 12 Nov 2019 09:06:51 -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 84D296B000C; Tue, 12 Nov 2019 09:06:51 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id 6A4476B0007 for ; Tue, 12 Nov 2019 09:06:51 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 377C1180AD80F for ; Tue, 12 Nov 2019 14:06:51 +0000 (UTC) X-FDA: 76147801422.11.A122617 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id D6906180F8B81 for ; Tue, 12 Nov 2019 14:06:50 +0000 (UTC) X-Spam-Summary: 2,0,0,af458d1fe34fc55b,d41d8cd98f00b204,alex.shi@linux.alibaba.com,: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:vbabka@suse.cz:dan.j.williams@intel.com:mhocko@suse.com:richard.weiyang@gmail.com:hannes@cmpxchg.org:arunks@codeaurora.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1431:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:2742:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3874:4321:4605:5007:6261:6737:7514:7903:9207:10004:11026:11473:11658:11914:12043:12048:12296:12297:12555:12895:12986:13069:13161:13229:13311:13357:13846:14040:14181:14384:14394:14721:14915:21060:21080:21451:21627:30054:30064,0,RBL:115.124.30.132:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5 ,0.5,0.5 X-HE-Tag: pigs15_58b6f160ff33e X-Filterd-Recvd-Size: 3381 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Nov 2019 14:06:49 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R571e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0ThuR20b_1573567598; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0ThuR20b_1573567598) by smtp.aliyun-inc.com(127.0.0.1); Tue, 12 Nov 2019 22:06:38 +0800 From: Alex Shi To: alex.shi@linux.alibaba.com, 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 Cc: Vlastimil Babka , Dan Williams , Michal Hocko , Wei Yang , Johannes Weiner , Arun KS Subject: [PATCH v2 1/8] mm/lru: add per lruvec lock for memcg Date: Tue, 12 Nov 2019 22:06:21 +0800 Message-Id: <1573567588-47048-2-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573567588-47048-1-git-send-email-alex.shi@linux.alibaba.com> References: <1573567588-47048-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: Currently memcg still use per node pgdat->lru_lock to guard its lruvec. That causes some lru_lock contention in a high container density system. If we can use per lruvec lock, that could relief much of the lru_lock contention. The later patches will replace the pgdat->lru_lock with lruvec->lru_lock and show the performance benefit by benchmarks. Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Vlastimil Babka Cc: Dan Williams Cc: Michal Hocko Cc: Mel Gorman Cc: Wei Yang Cc: Johannes Weiner Cc: Arun KS Cc: Konstantin Khlebnikov Cc: Hugh Dickins Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- include/linux/mmzone.h | 2 ++ mm/mmzone.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index bda20282746b..787a42d527a2 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -303,6 +303,8 @@ struct lruvec { atomic_long_t inactive_age; /* Refaults at the time of last reclaim cycle */ unsigned long refaults; + /* per lruvec lru_lock for memcg */ + spinlock_t lru_lock; #ifdef CONFIG_MEMCG struct pglist_data *pgdat; #endif diff --git a/mm/mmzone.c b/mm/mmzone.c index 4686fdc23bb9..3750a90ed4a0 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -91,6 +91,7 @@ void lruvec_init(struct lruvec *lruvec) enum lru_list lru; memset(lruvec, 0, sizeof(struct lruvec)); + spin_lock_init(&lruvec->lru_lock); for_each_lru(lru) INIT_LIST_HEAD(&lruvec->lists[lru]);