From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8270C4332D for ; Thu, 19 Mar 2020 04:01:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B52620724 for ; Thu, 19 Mar 2020 04:01:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ESQp9csY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B52620724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 000476B000A; Thu, 19 Mar 2020 00:01:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF3C26B0032; Thu, 19 Mar 2020 00:01:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE2616B0087; Thu, 19 Mar 2020 00:01:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id C5E276B000A for ; Thu, 19 Mar 2020 00:01:36 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 648A6181AC9CC for ; Thu, 19 Mar 2020 04:01:36 +0000 (UTC) X-FDA: 76610762592.14.way13_483134e0de854 X-HE-Tag: way13_483134e0de854 X-Filterd-Recvd-Size: 6032 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Mar 2020 04:01:35 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id z25so1167899qkj.4 for ; Wed, 18 Mar 2020 21:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=olaDQ7NlhWJr6NAH6yj+Y1cZnBeT1uBNBs+/2Gulbqg=; b=ESQp9csYDRssnztKNkHZNO+i25NosXpZkicdp+ClRgLbxlqYwJmSo+os5sjAPJQDIr AnUes+FTiL1v8o0rf+4t9PC0brh7oBwqAJtmXyXu/EKKUZBgoTbo/FOx/yTQ8bdCOEK6 /zTap4MMVXPkYCfd6aMrLxTT9+72D7c0fUMbPfP/q3IamFWwnsQl8aGQ74mMTDdMxu39 gTDre0JjMRFBPem7q05aQ+G7fXAJlyG7TGwdQBE6V//XKqda6M36JD+puBknKwnmNyyr b3R1Wo6u8SJMGuWTtBPot91oAJYXWFJIOAtZXMCL5vXQKPogoh+vBvgO+h71rlC/7uVj XA9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=olaDQ7NlhWJr6NAH6yj+Y1cZnBeT1uBNBs+/2Gulbqg=; b=QSEaotw9BLuB7pAW93kw2vExjUh12kVgaxVxd30pyPmtg8sK6JpZtHIspgMXgLmGb7 QtssU1tg+iA+w+edW0TDW7zHi7fPxwluQTD0FjEaN0nY99pK9G8goHjqpWmejEs5UM1T xzyqSu4ygERKp1OFXjB49i13qP+p8zDrTQYubKu2fpULGCbh2I6f0zHTqCvGJG26iM6J cKAj9In+Q9ersvWwqRluStNyCHVplfraZZ5WoTru8+iNCTHnPcD46U+VMxrsx9SD3m7r Z4BmplQOdo61MM1ANLbUOtjrSikiau5zdRPWBd8lAPb/r79AFW03fVoFA+3nfJTt5Y47 V/Pg== X-Gm-Message-State: ANhLgQ3bQz52SmzHepkWw1Ga3dvrdySr0WtV5tajccmmqYVVCrTxVFC5 k5n7PvToxNoh2iSqryKTim8IcbRSLtsY584iXVI= X-Google-Smtp-Source: ADFU+vthEQFRF9nzE7lIP/Q0aqp84cLBK7a6eUpv7WfAOx1zEIHx9K46N6bzONy+obrlmPh1AkpbMSjvuJWY3nGoYkI= X-Received: by 2002:a37:b4c1:: with SMTP id d184mr1190119qkf.452.1584590495495; Wed, 18 Mar 2020 21:01:35 -0700 (PDT) MIME-Version: 1.0 References: <1584423717-3440-1-git-send-email-iamjoonsoo.kim@lge.com> <1584423717-3440-3-git-send-email-iamjoonsoo.kim@lge.com> <20200318175155.GB154135@cmpxchg.org> In-Reply-To: <20200318175155.GB154135@cmpxchg.org> From: Joonsoo Kim Date: Thu, 19 Mar 2020 13:01:24 +0900 Message-ID: Subject: Re: [PATCH v3 2/9] mm/vmscan: protect the workingset on anonymous LRU To: Johannes Weiner Cc: Andrew Morton , Linux Memory Management List , LKML , Michal Hocko , Hugh Dickins , Minchan Kim , Vlastimil Babka , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 2020=EB=85=84 3=EC=9B=94 19=EC=9D=BC (=EB=AA=A9) =EC=98=A4=EC=A0=84 2:52, J= ohannes Weiner =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Tue, Mar 17, 2020 at 02:41:50PM +0900, js1304@gmail.com wrote: > > From: Joonsoo Kim > > > > In current implementation, newly created or swap-in anonymous page > > is started on active list. Growing active list results in rebalancing > > active/inactive list so old pages on active list are demoted to inactiv= e > > list. Hence, the page on active list isn't protected at all. > > > > Following is an example of this situation. > > > > Assume that 50 hot pages on active list. Numbers denote the number of > > pages on active/inactive list (active | inactive). > > > > 1. 50 hot pages on active list > > 50(h) | 0 > > > > 2. workload: 50 newly created (used-once) pages > > 50(uo) | 50(h) > > > > 3. workload: another 50 newly created (used-once) pages > > 50(uo) | 50(uo), swap-out 50(h) > > > > This patch tries to fix this issue. > > Like as file LRU, newly created or swap-in anonymous pages will be > > inserted to the inactive list. They are promoted to active list if > > enough reference happens. This simple modification changes the above > > example as following. > > > > 1. 50 hot pages on active list > > 50(h) | 0 > > > > 2. workload: 50 newly created (used-once) pages > > 50(h) | 50(uo) > > > > 3. workload: another 50 newly created (used-once) pages > > 50(h) | 50(uo), swap-out 50(uo) > > > > As you can see, hot pages on active list would be protected. > > > > Note that, this implementation has a drawback that the page cannot > > be promoted and will be swapped-out if re-access interval is greater th= an > > the size of inactive list but less than the size of total(active+inacti= ve). > > To solve this potential issue, following patch will apply workingset > > detection that is applied to file LRU some day before. > > > > Signed-off-by: Joonsoo Kim > > Acked-by: Johannes Weiner > > > -void lru_cache_add_active_or_unevictable(struct page *page, > > +void lru_cache_add_inactive_or_unevictable(struct page *page, > > struct vm_area_struct *vma) > > { > > + bool evictable; > > + > > VM_BUG_ON_PAGE(PageLRU(page), page); > > > > - if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) !=3D VM_LOC= KED)) > > - SetPageActive(page); > > - else if (!TestSetPageMlocked(page)) { > > + evictable =3D (vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) !=3D VM_= LOCKED; > > + if (!evictable && !TestSetPageMlocked(page)) { > > Minor point, but in case there is a v4: `unevictable` instead of > !evictable would be a bit easier to read, match the function name, > PageUnevictable etc. Okay. Looks like v4 is needed so I will change it as you said. Thanks.