Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp652070ybz; Fri, 17 Apr 2020 07:43:05 -0700 (PDT) X-Google-Smtp-Source: APiQypItq9+aOR9VTg65DNzAU6nxLWCfLD+inBJVaJYpAHsfSH8ln4oIAEd7raZtPYtLpRwQ3UTe X-Received: by 2002:a17:906:3796:: with SMTP id n22mr3230809ejc.225.1587134585576; Fri, 17 Apr 2020 07:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587134585; cv=none; d=google.com; s=arc-20160816; b=ji/looScb2HrOMwdr1aK/B8tF7SW9WjvEveu6pMafzKk8h1fohkKP/5u0NoOwyW5Sb 9JabwoWU46lKKyys68c0oS8rdkIsw+v0K1Xa7gWhe2fLlTSJTd2Nx46VvC1PhJInVk03 O3HyB3bl2Fx7MuI6ZhLdIN32g8VpbB1s55L3rILqwFXnP5kHD2MQHiIWOE78eMG0OuWU 2+JhLNsQs7zOcnw0H2givtPSac8Fmod7D3PSmzoGfPUpC7hc/N3d5QxiTUkGc1QAViqH AIUc6lQzvI/2ybJVoShNlXWE7qwuDyu7IpFyP80ZKzrgFuwnfkcfSjmacc2yWbH9JQjw kboQ== 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:from:references:cc:to :subject; bh=RioTXWsf250tZPVSzXYcWWkYuJtp0/OrFMCzP04oaEY=; b=DcBPvQCVFHe/Y/yXNgSpPfgOdaBjfxtfN3vuxZbDz/0Hj//+q9w5BqsXAaFVr/l9QQ ddt0eIv1xkheVOsqHjFWh1+hGPpAwzpTYHZv1O6Xguyex7ahpvXsBucGW2EK4t/NnGhs uuLz3/D85M98rtbocyU+vgOalgVot20pIgq5wpF99uko1QaATyu6LfQeK2SxVjdmTq1F o7wFaCdUj9QH9xrxML77jZDx0/b9qAwtVMfFkQp2XLfCDbQ054qQ76ofUYiE4S6gCxzt Mvaii8Cfb/1WxNdI6uFOW0KwKaMiFoC5T67DqJwEE3GWBu0V6nHddsomFeJWouTU+j0n WQIQ== 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 a26si8103583edx.154.2020.04.17.07.42.41; Fri, 17 Apr 2020 07:43:05 -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 S1728037AbgDQOlA (ORCPT + 99 others); Fri, 17 Apr 2020 10:41:00 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:44814 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbgDQOlA (ORCPT ); Fri, 17 Apr 2020 10:41:00 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R871e4;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=39;SR=0;TI=SMTPD_---0TvqIRjz_1587134450; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TvqIRjz_1587134450) by smtp.aliyun-inc.com(127.0.0.1); Fri, 17 Apr 2020 22:40:52 +0800 Subject: Re: [PATCH v8 03/10] mm/lru: replace pgdat lru_lock with lruvec lock To: Johannes Weiner Cc: akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.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, Michal Hocko , Vladimir Davydov , Roman Gushchin , Chris Down , Thomas Gleixner , Vlastimil Babka , Qian Cai , Andrey Ryabinin , "Kirill A. Shutemov" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , David Rientjes , "Aneesh Kumar K.V" , swkhack , "Potyra, Stefan" , Mike Rapoport , Stephen Rothwell , Colin Ian King , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao , Wei Yang References: <1579143909-156105-1-git-send-email-alex.shi@linux.alibaba.com> <1579143909-156105-4-git-send-email-alex.shi@linux.alibaba.com> <20200116215222.GA64230@cmpxchg.org> <20200413180725.GA99267@cmpxchg.org> <8e7bf170-2bb5-f862-c12b-809f7f7d96cb@linux.alibaba.com> <20200414163114.GA136578@cmpxchg.org> <54af0662-cbb4-88c7-7eae-f969684025dd@linux.alibaba.com> <0bed9f1a-400d-d9a9-aeb4-de1dd9ccbb45@linux.alibaba.com> <20200416152830.GA195132@cmpxchg.org> From: Alex Shi Message-ID: <2403add7-d468-7615-22c5-3fafb1264d54@linux.alibaba.com> Date: Fri, 17 Apr 2020 22:39:59 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200416152830.GA195132@cmpxchg.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/4/16 下午11:28, Johannes Weiner 写道: > Hi Alex, > > On Thu, Apr 16, 2020 at 04:01:20PM +0800, Alex Shi wrote: >> >> >> 在 2020/4/15 下午9:42, Alex Shi 写道: >>> Hi Johannes, >>> >>> Thanks a lot for point out! >>> >>> Charging in __read_swap_cache_async would ask for 3 layers function arguments >>> pass, that would be a bit ugly. Compare to this, could we move out the >>> lru_cache add after commit_charge, like ksm copied pages? >>> >>> That give a bit extra non lru list time, but the page just only be used only >>> after add_anon_rmap setting. Could it cause troubles? >> >> Hi Johannes & Andrew, >> >> Doing lru_cache_add_anon during swapin_readahead can give a very short timing >> for possible page reclaiming for these few pages. >> >> If we delay these few pages lru adding till after the vm_fault target page >> get memcg charging(mem_cgroup_commit_charge) and activate, we could skip the >> mem_cgroup_try_charge/commit_charge/cancel_charge process in __read_swap_cache_async(). >> But the cost is maximum SWAP_RA_ORDER_CEILING number pages on each cpu miss >> page reclaiming in a short time. On the other hand, save the target vm_fault >> page from reclaiming before activate it during that time. > > The readahead pages surrounding the faulting page might never get > accessed and pile up to large amounts. Users can also trigger > non-faulting readahead with MADV_WILLNEED. > > So unfortunately, I don't see a way to keep these pages off the > LRU. They do need to be reclaimable, or they become a DoS vector. > > I'm currently preparing a small patch series to make swap ownership > tracking an integral part of memcg and change the swapin charging > sequence, then you don't have to worry about it. This will also > unblock Joonsoo's "workingset protection/detection on the anonymous > LRU list" patch series, since he is blocked on the same problem - he > needs the correct LRU available at swapin time to process refaults > correctly. Both of your patch series are already pretty large, they > shouldn't need to also deal with that. > That sounds great! BTW, the swapin target page will add into inactive_anon list and then activate after chaged. that left a minum time slot for this page to be reclaimed. May better activate it early? Also I have 2 clean up patches, which may or may not useful for you. will send it to you. :) Thanks Alex