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.9 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 2A274C433DF for ; Fri, 3 Jul 2020 00:48:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0DEC207D4 for ; Fri, 3 Jul 2020 00:48:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tiv0Wo8V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0DEC207D4 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 72E5C8D000B; Thu, 2 Jul 2020 20:48:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DF288D0002; Thu, 2 Jul 2020 20:48:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F51E8D000B; Thu, 2 Jul 2020 20:48:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 4ACE38D0002 for ; Thu, 2 Jul 2020 20:48:00 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C6D0E1EFF for ; Fri, 3 Jul 2020 00:47:59 +0000 (UTC) X-FDA: 76994927478.27.spot81_470733126e8d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id A6F783D663 for ; Fri, 3 Jul 2020 00:47:59 +0000 (UTC) X-HE-Tag: spot81_470733126e8d X-Filterd-Recvd-Size: 7629 Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Jul 2020 00:47:59 +0000 (UTC) Received: by mail-qv1-f67.google.com with SMTP id di5so8660267qvb.11 for ; Thu, 02 Jul 2020 17:47:59 -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=QubtygT6CHPqxIkPsZey+WL7TuPuIYxqs13CLNXIeHw=; b=Tiv0Wo8V7BGJ98NUyieGZaCTDAHig6wZyVeaeiVFIhMeO7PL64VLLJBKgiGnmMAWOb lIqVjjiMrLzx6Bq8hBzWRDDQN07NPH6sC6vkNbqGv4Q3vLWGezl/uVoGQqE3hiApBORw BByd9gH5KUFCjtxCAGSwM1yN8t+O+LK3sJqVf/84Sg11eSAdQJ3/R+iapUrOTzX1SmrK Jgegw6uQzJNoHzVgfPNpl+730XkD8fClhCTriVjZG5k2alnF5LFTDfaLx/rMMpNcTj1i ic8IQ+h9FAVX8PG81NiOqwqSgN/NG0iGI2Nx6ugBbSxoCFaqCYDazWouLUL3fZM7YTly 35IQ== 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=QubtygT6CHPqxIkPsZey+WL7TuPuIYxqs13CLNXIeHw=; b=JUmJmao3hiYLKhNIYU+gaCJW7oXxhUPqNMcDL6j3rXunLT+q9CS+5UbKn47BAkZqqB ttM18dlYgDWo6cj1IBMWyZrr4Kl5gZTpytWHKWHIR5Qgo5+qnwUm/ZBC/CVXaFIuyJrJ kGryx6cPos8GxF2D9UQpjI1esfv2pyj6aSa2dw2ayyKZE9nUvzoyaSdbz0SWRBm+bXSI lHwkGr/V/AeRIpF8WQCu8Oc/nx/k/DSsW1lv2cXrjU51ZbgHRsd5Mm5Pc04DbjhoM95N czpyfroDNrKrivsCAXoHT15VjJzPNYmhfsDDC0mWQVcVuOpAZb6HPojuRiijgD7Q8XzK oy3Q== X-Gm-Message-State: AOAM531EOnpX9CsFm+mM87hL+fw1uBzBxKysrmvsdC/03nyaNnUbK3jG 4XnCGc1NXON/Nmx3mRWC2qObdO3rXqG7lsluocY= X-Google-Smtp-Source: ABdhPJz809WyueVeEH9q/ZinGqq/wkDF6ZSpVhBPgriKUE1wN1KSOm4Ffh2VFu7uGvVVyrWeg1m0pqs1z6kQw7zzoNs= X-Received: by 2002:a0c:99c5:: with SMTP id y5mr9684766qve.66.1593737278471; Thu, 02 Jul 2020 17:47:58 -0700 (PDT) MIME-Version: 1.0 References: <1592371583-30672-1-git-send-email-iamjoonsoo.kim@lge.com> <1592371583-30672-3-git-send-email-iamjoonsoo.kim@lge.com> <4591b38d-fdd0-e2e6-bf11-6e5669575736@suse.cz> In-Reply-To: <4591b38d-fdd0-e2e6-bf11-6e5669575736@suse.cz> From: Joonsoo Kim Date: Fri, 3 Jul 2020 09:47:47 +0900 Message-ID: Subject: Re: [PATCH v6 2/6] mm/vmscan: protect the workingset on anonymous LRU To: Vlastimil Babka Cc: Andrew Morton , Linux Memory Management List , LKML , Johannes Weiner , Michal Hocko , Hugh Dickins , Minchan Kim , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: A6F783D663 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: 2020=EB=85=84 7=EC=9B=94 2=EC=9D=BC (=EB=AA=A9) =EC=98=A4=EC=A0=84 3:02, Vl= astimil Babka =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On 6/17/20 7:26 AM, js1304@gmail.com wrote: > > From: Joonsoo Kim > > Hi, how about a more descriptive subject, such as Hello, > mm/vmscan: add new anonymous pages to inactive LRU list This patch does two things to implement workingset protection. - add new anonymous pages to inactive LRU list - check two reference to activate So, I think that the current subject is more descriptive for this patch. > > 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. > > detection similar to the one that's already applied to file LRU. Will change! > > v6: Before this patch, all anon pages (inactive + active) are considere= d > > as workingset. However, with this patch, only active pages are consider= ed > > as workingset. So, file refault formula which uses the number of all > > anon pages is changed to use only the number of active anon pages. > > a "v6" note is more suitable for a diffstat area than commit log, but it'= s good > to mention this so drop the 'v6:'? Okay. > > Acked-by: Johannes Weiner > > Signed-off-by: Joonsoo Kim > > Acked-by: Vlastimil Babka Thanks! > One more nit below. > > > --- a/mm/swap.c > > +++ b/mm/swap.c > > @@ -476,23 +476,24 @@ void lru_cache_add(struct page *page) > > EXPORT_SYMBOL(lru_cache_add); > > > > /** > > - * lru_cache_add_active_or_unevictable > > + * lru_cache_add_inactive_or_unevictable > > * @page: the page to be added to LRU > > * @vma: vma in which page is mapped for determining reclaimability > > * > > - * Place @page on the active or unevictable LRU list, depending on its > > + * Place @page on the inactive or unevictable LRU list, depending on i= ts > > * evictability. Note that if the page is not evictable, it goes > > * directly back onto it's zone's unevictable list, it does NOT use a > > * per cpu pagevec. > > */ > > -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 unevictable; > > + > > 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)) { > > + unevictable =3D (vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) =3D=3D= VM_LOCKED; > > + if (unevictable && !TestSetPageMlocked(page)) { > > I guess this could be "if (unlikely(unevictable) && ..." to match the pre= vious > if (likely(evictable)) else ... I will fix it, too. Thanks.