Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp211146ybg; Wed, 18 Mar 2020 21:03:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvrFzgUhpLF1HiMNhxRtAkktRh60l+1vQivZ7IR1WD2kggAb27HfOdTXICICi1BdIRONf7V X-Received: by 2002:aca:c4c5:: with SMTP id u188mr895564oif.139.1584590609339; Wed, 18 Mar 2020 21:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584590609; cv=none; d=google.com; s=arc-20160816; b=LaB9J9rdeMYAAtoLAOtyhdVcP3xjlswZxrIluewIgJPNL0mrJsKaZZZqxX4bgJ53nW Tsjg1Q/IdjyFIF4uBwxUlaHlMQKjMUiFFg4zTwwEdXCBcEXm8rx6O+ouKhw7PmJvkU/N Aktbi6nWyb6nSQuECGK03ZGxdo4aJPI9m8Eivw0FFxhS93ULpyS2DlJrEjMEEbi4akX/ 7/ptl/p4xS6z81Jsg98goadU4FZzodU+QVjtYb8wmFBsToFKkUZG16/PNpy2BL1XdHFL 0CEg3ynK/5o7tWmvA8AWNTAWLkNToNHjvIkzGI9a+mdn/K8UICOgfZXlKzWS7lTAoYuQ CEVA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=olaDQ7NlhWJr6NAH6yj+Y1cZnBeT1uBNBs+/2Gulbqg=; b=nL8GEsnns/sQNZbri0W89t6Gq1rjy5oRA/GgppO8WjPczqmdjvpJI3yPPy1yUIzXdD bEX+ukCW/UALpIALbuqZcoTgcXhkv6XGXWBGChF0BiwLtfBPKrQovBcbAV7CLBM59q5V XrPnJPc9hwMPxqxYYgcCZFJiBDc3MxiW1jFYu9cZrk4t4SQvPY3knlm8tm8D3X6u9iR2 7NmAFO1our/1TOCBXcDItRKUetv0hNtwIWKNyjYl7u1qwTXjOimuEz9EJbXx5DYLDLmd 3X+o35FXRuC0WNwGQ8amXYBaFOxAmCm5gezJrKTwT9b+2vop87Y0PJ4xRTUqyZBjkP1i GJ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ESQp9csY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si434590oih.95.2020.03.18.21.03.16; Wed, 18 Mar 2020 21:03:29 -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=@gmail.com header.s=20161025 header.b=ESQp9csY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgCSEBi (ORCPT + 99 others); Thu, 19 Mar 2020 00:01:38 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:46859 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbgCSEBi (ORCPT ); Thu, 19 Mar 2020 00:01:38 -0400 Received: by mail-qk1-f194.google.com with SMTP id f28so1091924qkk.13 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=VebMwHEJ/03L8Ff5rqteXe6/FMWksEM+jw8N8iKLV6ebPhzYVYU60LpUaN1emEVCYP 1QmNYnLV+B8syUWh8+09P1qUm1GxZ81AEdJ7chkiNUSmA2q+O3EwNKbzCU6CV/n10rzw Zj/UjoarvBkRDqGNPZkW4JGRBDSrRcwQESiO6R2dAYfhVj1tYKrODnLoC9HfOLbIUmtu x1M2lKUyNKLaYUFBkfvsu9MFR/RcDl+orYQO0CnBlxpIrBFW2nhh0wOmmHjlQqViSo3U M7+3s1YtWmTYJkZ415r21VvFXqCOZ+oOKNqK3ihxExOldzGAYYQ1GBc+NGks1jn+yDH/ AijA== X-Gm-Message-State: ANhLgQ1RFSKSsdLaaMgt1sHwujVGwU0hmGKcOnK62UTxjpKxrtcTVb1a ++YqvGxuB9tpUXVYoCCtFnC3/bWKgNdQpSm3n08= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.