Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp884855ybh; Wed, 18 Mar 2020 10:54:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuci1eRvnqQJ9UdSr/LTzIhiZKApCm+MXlnORBX6eKIhKSKimD37bcSl6n+bziy+cLhbpux X-Received: by 2002:a9d:c61:: with SMTP id 88mr5085149otr.144.1584554057067; Wed, 18 Mar 2020 10:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584554057; cv=none; d=google.com; s=arc-20160816; b=eGzDGQ5lcKJcfKHvlHW67QiR/afYWv138wjjlQW/zNySOy3935UYqM3QbzJrq/frba nlKAjfWYtFEyzBTDKTM+68/hSe0MY7M15D5ybKpie2lm7shVS2d7m6cCzPmxjgB51F9l o0L51K/PgI4pp54+V6fUJhUMPtT2Gj2TutzVSs1XcG95nLUnDlSVYfocj+sx73X5JpkM jnQaTSGqMZ3JwMdJbgL53VW5EJp2iJ1vUz/WIBQe0tzkwA+KpF4qWWKgdp+TK1cbriYT lu2JHdjkcSxlyYcxq8D8kBezGtykakSCHNG+gRHgQ6a/ZRFEGWwaTm1CsfxOfce08OLt 0s9A== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=W0JooyDRbeGuBMVupYbPukHqUszgISMZep91jqIkGUg=; b=lWBu12tTCCAYo8FpPTSN+IJXxUyow+BK2YzAU1++msngqYq3SJLv3cwlRaTVThMdpu HMxqtH2t4pcUIkKKIJqJN15U/gGrc7JQWmh2sqGyQMcHxTRXCxS06aDAfObnCcZPIDe5 nIGzX5ZdnX95PXyTPmiVpe9JUQJ75mc88jWx19nLereLwAY5BJjn4oce+ij4ZrlpbwMR cq0CUe/hc1gPJXiaHUkeL5gn6IVKCBXVpM+jonQJCW1NyPBmMtJsmqYiaZm7CKSpT4Ub UZfwbIFlI3gk4k/BauWJFO5FMXKNnIV4mgPFbY6SAXZiGhpNJscOkk7gIpvEx+I143KQ AzHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=RiLItl+H; 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 o14si3817298otl.122.2020.03.18.10.54.04; Wed, 18 Mar 2020 10:54:17 -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=RiLItl+H; 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 S1726680AbgCRRv7 (ORCPT + 99 others); Wed, 18 Mar 2020 13:51:59 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:46251 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgCRRv7 (ORCPT ); Wed, 18 Mar 2020 13:51:59 -0400 Received: by mail-qk1-f193.google.com with SMTP id f28so40238347qkk.13 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=hVSn61y8jACK8TJt7ARRakqFDN9TN7f5BXKDr2PhHEx7bhIYm+7yg6GOqRIfUhDn5U +VjIDmVSQkHKJTv5Cm9Qfx0jcNV7QjK/PJxjYyn+dfi4jcm5f54qzjtBmzHTzrFqvwQ2 l+yTKip+Sk+Cdm170BQACl7T8M/8OT/dGr87UX+81h7IOYPsPiztXNXGjaja7MxZkLgX FhpdPA5v80w/Y823Gg89Q0Mu1QuFrVJgrJC1+ZF2ve5LzZXU5KystVLXn0ke0j0rsqOT uhFTDTwkGVU9YN15O6bYffrW0Xp3CoyLT8N/+UqBp1EuFEedXzNJ1dW7ptQ+asQbOpTt zU5w== X-Gm-Message-State: ANhLgQ2fdPQxIBhMWMURoOzCqWkzitDLl9Hml0i2893QYJzgHBtbFKe6 wd4YdrCeUxUsET2UxBy3c4yBIg== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.