Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2761604ybh; Mon, 16 Mar 2020 09:12:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtEmLqWp78H/dZxo+DkU9gdorYtSI8p/740KLwguIqLXcqO4TfrHAVig0CdTnc+vJtSgKBr X-Received: by 2002:a05:6830:17d7:: with SMTP id p23mr49425ota.312.1584375166209; Mon, 16 Mar 2020 09:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584375166; cv=none; d=google.com; s=arc-20160816; b=cZQ8hL4iHwRHbPcosbNz9aE3jmCAfJlSOD8EjrjB2da7KDGAi6qLHXn9fPYGjI1H2w Bo/RbwP20yXv0b5eCeLuW+TPnFPATiyQmvy+DylR20KU8Ou57d3Hi/BiFq+x8PcAmvON Vh3QeY0vz/zIAqhgZABgQ3qoHm0MpPSjGhBJE0Afa0iysToEtNxbZO78EDOUZVC8Y9GO ZW/qGMXQuK6hdC4bt4nPhfOoxq5P2FWYCD2st+YJTGPxKRGieV6SHOUZOGnVP+3JnH8Q X9BmdjLgBvQF63+42JHgVntqhHSRQwImSHkaUXzW3G7sPRAlnx+be+CvrmAoLjT2ApKs 47Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Dey7Nfe81uVrTNj3sIdJJjvqn+aY0k6NabLHjTXVQgc=; b=D0RnAMqnkPKLiJncHCru33+SzyXpL0HSSYeizKidXkvueLQ+nVoDur4gWBFKwA0//o 6wscSEFDRKO9GPMnmPXdF6W8fyZir7d4cCgwNp95YtoWURLlV4wvsM9DgobozIk+MUVS kUvc0FTDz/QCYH0pzqcAD6ts5/cXRMCUlF+iVWKdazbN2j4BuJ4ACc1hujoTRJOtkB2u R5sk0FqYC+Hw5X+xg6EF681CaXMYJvfqyLPzQmPQoNRf1ou3EKXRCN1KHz92qVuqdvdX QueMtRDeLH5IYE7YaV2g+FKIYSknSBCiflzm4ELDlIOZUpnVforIAcj+6p6TFR4xJKth 7G6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=w8j9Cvld; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si157138otq.99.2020.03.16.09.12.32; Mon, 16 Mar 2020 09:12:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=w8j9Cvld; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbgCPQMP (ORCPT + 99 others); Mon, 16 Mar 2020 12:12:15 -0400 Received: from mail-qt1-f169.google.com ([209.85.160.169]:44914 "EHLO mail-qt1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731505AbgCPQMO (ORCPT ); Mon, 16 Mar 2020 12:12:14 -0400 Received: by mail-qt1-f169.google.com with SMTP id h16so14647804qtr.11 for ; Mon, 16 Mar 2020 09:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Dey7Nfe81uVrTNj3sIdJJjvqn+aY0k6NabLHjTXVQgc=; b=w8j9CvldLZ2D7h6Ij54OQbDHCt4dvW1qlF2jFOU6bKJC+FWYhlg4pTSX2slDSgpvaY v78RUSDf9i+oNhlrhP0t1jL20swq1QNObDXZgS27P0G87/LXhxi6DXwEkiLexmjT+qrz lFyhVr0W8yXnSMKFS4O/g1Fufe6olDpN5SGzmT3Nbgg3mG2iSNUSflfnduUKv1qDduuD Djsge/vuQ7qKZxohkayCmlUM209dzagcpISs2anbZ4Z5/juz+ipkV0+ORpBdJPNBTo6O 60Z6lguM1f39zHp3lQWFG2BTu4UPgpXXYVJeSD+N5dhyHDBIcK3iaDnSoRhiYb5frEOg FAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Dey7Nfe81uVrTNj3sIdJJjvqn+aY0k6NabLHjTXVQgc=; b=EZnxXDaKiN67D4aDi42777CNpK5UnZJ2AFntzNeMwEe7U6lxVaHazzI+0ykCXLEoR7 rY/weo/N7uqkWyzPf85//qvVqfO8hmxGK84Z0tUoaqgcprDx3P1XSBQ3hLPguEXC6243 lgqbucZPjiWYifwovIwi9NXSq16XIEQcUKtcJ6nbUT+5Np+VIthy+ybs6N3IJLocWZLV OSxOLiyNCWuvCKwL+8HfEHTS6BYwX+KjzO+oghNHR2s1zDzMoU8qCXgaCXaYgP9ii2Sy mlZyB0mHemhRqXaLO5n+TSqryxm1xtbjrgFwOjRktWAJbQB0MIyZJUzSZpLIVt+uNjOp jCZQ== X-Gm-Message-State: ANhLgQ3v9/2dwjCb0pDVrT88YuGK59sS6tpsq56eXyQRc0GzT5qqQOeV wOpCNXFk6cMdhbV2x3tIUKVKE2uiXlo= X-Received: by 2002:aed:2284:: with SMTP id p4mr763287qtc.329.1584375130425; Mon, 16 Mar 2020 09:12:10 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id u51sm105580qth.46.2020.03.16.09.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 09:12:09 -0700 (PDT) Date: Mon, 16 Mar 2020 12:12:08 -0400 From: Johannes Weiner To: Joonsoo Kim Cc: Andrew Morton , Linux Memory Management List , LKML , Michal Hocko , Hugh Dickins , Minchan Kim , Vlastimil Babka , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Subject: Re: [PATCH v2 2/9] mm/vmscan: protect the workingset on anonymous LRU Message-ID: <20200316161208.GB67986@cmpxchg.org> References: <1582175513-22601-1-git-send-email-iamjoonsoo.kim@lge.com> <1582175513-22601-3-git-send-email-iamjoonsoo.kim@lge.com> <20200312151423.GH29835@cmpxchg.org> <20200313195510.GA67986@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 16, 2020 at 04:05:30PM +0900, Joonsoo Kim wrote: > 2020년 3월 14일 (토) 오전 4:55, Johannes Weiner 님이 작성: > > The problem with executables is that when they are referenced, they > > get a *lot* of references compared to data pages. Think about an > > instruction stream and how many of those instructions result in data > > references. So when you see an executable page that is being accessed, > > it's likely being accessed at a high rate. They're much hotter, and > > that's why reference bits from VM_EXEC mappings carry more weight. > > Sound reasonable. > > But, now, I have another thought about it. I think that the root of the reason > of this check is that there are two different reference tracking models > on file LRU. If we assume that all file pages are mapped ones, this special > check isn't needed. If executable pages are accessed more frequently than > others, reference can be found more for them at LRU cycle. No need for this > special check. > > However, file pages includes syscall-ed pages and mapped pages, and, > reference tracking models for mapped page has a disadvantage to > one for syscall-ed page. Several references for mapped page would be > considered as one at LRU cycle. I think that this check is to mitigate > this disadvantage, at least, for executable file mapped page. Hm, I don't quite understand this reasoning. Yes, there are two models for unmapped and mapped file pages. But both types of pages get activated with two or more references: for unmapped it's tracked through mark_page_accessed(), and for mapped it's the two LRU cycles with the referenced bit set (unmapped pages don't get that extra trip around the LRU with one reference). With that alone, mapped pages and unmapped pages should have equal chances, no? > > IMO this applies to executable file and anon equally. > > anon LRU consist of all mapped pages, so, IMHO, there is no need for > special handling for executable pages on anon LRU. Although reference > is just checked at LRU cycle, it would correctly approximate reference > frequency. > > Moreover, there is one comment in shrink_active_list() that explains one > reason about omission of this check for anon pages. > > "Anon pages are not likely to be evicted by use-once streaming IO, plus JVM > can create lots of anon VM_EXEC pages, so we ignore them here." > > Lastly, as I said before, at least, it is done separately with appropriate > investigation. You do have a point here, though. The VM_EXEC protection is a heuristic that I think was added for one specific case. Instead of adopting it straight-away for anon pages, it may be good to wait until a usecase materializes. If it never does, all the better - one less heuristic to carry around. > Now, I plan to make a next version applied all your comments except > VM_EXEC case. As I said above, fundamental difference between > file mapped page and anon mapped page is that file LRU where file mapped > pages are managed uses two reference tracking model but anon LRU uses > just one. File LRU needs some heuristic to adjust the difference of two models, > but, anon LRU doesn't need at all. And, I think VM_EXEC check is for this case. > > Please let me know your opinion about VM_EXEC case. I will start to rework > if you agree with my thought. That sounds like a good plan. I'm looking forward to the next version! Johannes