Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1160827pxa; Thu, 6 Aug 2020 00:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsti7eYX1SmlEsCRODNaZ0kxeYNK5o/Aa9KIwWJ3mGkT9xTLTfch+XHTBzNlXRWfJWfoXS X-Received: by 2002:a17:906:f8d5:: with SMTP id lh21mr3191466ejb.360.1596699831334; Thu, 06 Aug 2020 00:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596699831; cv=none; d=google.com; s=arc-20160816; b=I66azcq5QxP73mfJNDvCkA4FhDVd8iie7u2AJWY5NOoWbfFxRDYPV8aczrU5ZfKb4B FxaIxPKUh+9qLmXNQ/jB8Dn6ntDX7LakSMdOzINtXA/RQsB6bsrFBiCn+sRV6XqJI8UY pjQQKM2jsi+FW9fWqwib6gaLAnKW+v/WehN/XMRzDFcyfcBHSJakd5UqP+lqG/keeXhA 11GXw3Q+41vN34V3ajoi8L3Oh9ECnA1xs6guO9xkGmJ+HKs8e0Ul3tw5OGXtM0L/rPuT mnYeikI//p8wlAJKZG4AKcc7Zfjd99aMDZGO3FQ6S1bfl7qHvT01GqqC4hI3NTg9quLX o8zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=/1wFBZPhJrtAlJMs0C9ryRN/bFDt0mBkjbiVcK99+yQ=; b=LEku0u/1tmpv8unbdv2e21zVY8M0cydmbAnGSgGHFN9Q+6bPj/rpJyMWZQlkIJt+zJ ydLwtX1+SEyDirs5WDVgunqr75gqa/GV3nUBhswGDqPzuVFP8zaVPQMKVT2cSsS0/BWi RnBpB94uCJwyvq+bEkjcUCMno+udI05BmNPVHljrLsy1akUulfPSBZ3lzXw9TyFkSqHb OOrHINdmbbpOnFDQ4mqA7u9W//PHbxaOBEWw0TNpRw46ApMizbrMTco5DrGTjYoDVuFx mSs57QPeLy/2oyQOREQd0WveFrssdFsAjaM/acrhfy2uzqn+mkY5n8JNuQlC0TEx6jQ6 8vgA== 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 cc9si2740559edb.430.2020.08.06.00.43.28; Thu, 06 Aug 2020 00:43:51 -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 S1728650AbgHFHmd (ORCPT + 99 others); Thu, 6 Aug 2020 03:42:33 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:48155 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgHFHmF (ORCPT ); Thu, 6 Aug 2020 03:42:05 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0U4uOac3_1596699708; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U4uOac3_1596699708) by smtp.aliyun-inc.com(127.0.0.1); Thu, 06 Aug 2020 15:41:49 +0800 Subject: Re: [PATCH v17 17/21] mm/lru: replace pgdat lru_lock with lruvec lock 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, yang.shi@linux.alibaba.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 Cc: Michal Hocko , Vladimir Davydov References: <1595681998-19193-1-git-send-email-alex.shi@linux.alibaba.com> <1595681998-19193-18-git-send-email-alex.shi@linux.alibaba.com> Message-ID: Date: Thu, 6 Aug 2020 15:41:28 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1595681998-19193-18-git-send-email-alex.shi@linux.alibaba.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Johannes, Michal, From page to its lruvec, a few memory access under lock cause extra cost. Would you like to save the per memcg lruvec pointer to page->private? Thanks Alex ?? 2020/7/25 ????8:59, Alex Shi ะด??: > /** > * mem_cgroup_page_lruvec - return lruvec for isolating/putting an LRU page > * @page: the page > @@ -1215,7 +1228,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); > /* > * Swapcache readahead pages are added to the LRU - and > * possibly migrated - before they are charged. > @@ -1236,6 +1250,51 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgd > return lruvec; > } > > +struct lruvec *lock_page_lruvec(struct page *page) > +{ > + struct lruvec *lruvec; > + struct pglist_data *pgdat = page_pgdat(page); > + > + rcu_read_lock(); > + lruvec = mem_cgroup_page_lruvec(page, pgdat); > + spin_lock(&lruvec->lru_lock); > + rcu_read_unlock(); > + > + lruvec_memcg_debug(lruvec, page); > + > + return lruvec; > +} > +