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, 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 D9E20C5ACD6 for ; Wed, 18 Mar 2020 17:52:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73FA82076E for ; Wed, 18 Mar 2020 17:52:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="RiLItl+H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73FA82076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0E0EF6B0010; Wed, 18 Mar 2020 13:52:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06AD96B006E; Wed, 18 Mar 2020 13:52:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E747B6B0070; Wed, 18 Mar 2020 13:51:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id CB8E46B0010 for ; Wed, 18 Mar 2020 13:51:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7F9718245571 for ; Wed, 18 Mar 2020 17:51:59 +0000 (UTC) X-FDA: 76609226358.23.scale10_85bc879f15b4c X-HE-Tag: scale10_85bc879f15b4c X-Filterd-Recvd-Size: 5770 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Mar 2020 17:51:58 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id t17so18509927qkm.6 for ; Wed, 18 Mar 2020 10:51:58 -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:in-reply-to; bh=W0JooyDRbeGuBMVupYbPukHqUszgISMZep91jqIkGUg=; b=RiLItl+HDnetbMERCcyRE4Cf16LHcogEpuj7cCaKCEJMbom3dVu9e4Gr3gvq/AKAFP LpT6ZDCJcOxBhjgTo+vwbryV9IyK2BrwA7iOSVlxZgj3uJaZ65OizOG8kV6ZPAFyq5X+ 0MrF+eR81QFiDC3UoVrdjeXZy52CQVhbYmaK0KBbMYtGroUNVZFjw12fQFr65YO2FUt4 tMeF8JdMt6Hna8ZxGesj+2et+M3jmmbIUOrhkbZaKz1pazB0x10KJ7kN69meyMzKaO1B ku+yTYyPYMBFbbToOb6Dy7Ld0u0eZLdJ0qICLpayJU0ZvW37f1eusCWefuOzlFu7A3A9 G38w== 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:in-reply-to; bh=W0JooyDRbeGuBMVupYbPukHqUszgISMZep91jqIkGUg=; b=TxnGyU5oTwu4SKettCN7XEoIg5FEbSiu49xE+3sK4HYxT4qfEO5yEKauUdt16MFWcM uhEoKemKfyrGDN2xlFYpf3x2XoHJzU50Mva/sAQt1NqORpe3+zUe+8cBvDmxTWo6gUSU 2fS/2heHUsLIr0UHjkjEdp2+HFK92TFOgqooh+A+BCgQjdkFIGg6SM2LI3fJsjUgXrsQ YZJA/iiwuFq7jGnF4vt9UVUJrrPTpSNqofOc6S2evYfGNqYzzuTO9gdPsckLZ9p9go3a 9mhZrPkBrDqRYx9Lt2CKw5XIngPWSkwZsycXwSpUwBGJM2Eo1Nw6au9N6OJfBX6PuH2H iwvQ== X-Gm-Message-State: ANhLgQ3JBMK9mKvLLFbe1MsMECic8eSLPs40seGd8JtD/BVrJon262/S wyJF5NKjCrbNA7DnGjT/FhhKGw== X-Google-Smtp-Source: ADFU+vuaYpWrKiiQHqsdsWhN2g1kXkYNMhE/rdbZb3HSZq9R1i8+WtDZrQ8gVJFOvNNKhoNRm8hHfQ== X-Received: by 2002:a05:620a:146f:: with SMTP id j15mr5073420qkl.443.1584553918172; Wed, 18 Mar 2020 10:51:58 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:a9a9]) by smtp.gmail.com with ESMTPSA id c12sm5317604qtb.49.2020.03.18.10.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 10:51:57 -0700 (PDT) Date: Wed, 18 Mar 2020 13:51:55 -0400 From: Johannes Weiner To: js1304@gmail.com Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Hugh Dickins , Minchan Kim , Vlastimil Babka , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Subject: Re: [PATCH v3 2/9] mm/vmscan: protect the workingset on anonymous LRU Message-ID: <20200318175155.GB154135@cmpxchg.org> References: <1584423717-3440-1-git-send-email-iamjoonsoo.kim@lge.com> <1584423717-3440-3-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1584423717-3440-3-git-send-email-iamjoonsoo.kim@lge.com> 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: 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 inactive > 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 than > the size of inactive list but less than the size of total(active+inactive). > 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)) != VM_LOCKED)) > - SetPageActive(page); > - else if (!TestSetPageMlocked(page)) { > + evictable = (vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != 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.