Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp582123yba; Fri, 5 Apr 2019 12:35:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyd4di06sIfKq/U7fwkOs9Co4QLMZxtiPRSqtFnreXEKvWX9vfh7xY7iUe4pLlXfFJL7s/9 X-Received: by 2002:a62:4e86:: with SMTP id c128mr14496586pfb.39.1554492937420; Fri, 05 Apr 2019 12:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554492937; cv=none; d=google.com; s=arc-20160816; b=HHiEvKiESLBgy0YeQfYFCsmMoaXqBT0VwTOqj1gRBR8M8EtQuKK5fUyy+TkFroY99Q 6j+eZQGu+9RFmCVpALj9F4YwuGtqWxoBdLj4h9JFQKFVU5RL7RrS4XBHi9zOGg4lA2WJ HP+u4WeCLxqDa5Sncsub222U5VCoLImNzSxRkPxVACoN5/Mk9Gs486wPstTc3tVLfP1K K8SD5IOQZl1BR/bAJQMisJQaWKnTcKCCuDa9xc7uhHeChFFFv8DRm9RZRSspv4bnTSc4 eGLVIAGzqbIFxpyDBBaMU0ocSv04bOVSmr+DTsjt/QmMeeXvFdiK1QU6owf1xED9MgOo 9Thw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1sjVKmuXhVLeJPdr6cYXHsdrlxlSdoGqHJzj+qjCJSs=; b=BHBq3m1ixj47dAl7dgvWnCMzQVyFCtALQpMugmmxZ8j4pw2CW60BqT56Id37CuXCU+ NKkF+f5FQBUbqswODKygJzuq/bNGfsfaWzGRLfzB1t8p6nZVVDfZV9Z1J8jN/dnWP46g bvErC+oadSu4Ory1w7ckEObYixdeKNMDpgF8oN7yXsxcD2Nt2HWtDUdUcgCU7ouEKIoU oPMe0oSukMeekiNwje61ZQot4bPvyr2HjTTfK5S+lgbYEK6txrNAFw5as0NHghh9s2Fm dyKlo1A5jdXiBlEwjqAWDkh6QFK/4dzKmrxjvT6lKhsW/Sb9Pq0Nkmib0SPLH3lKOzFD JnVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=HfgWPH4l; 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 l1si19330441pff.206.2019.04.05.12.35.21; Fri, 05 Apr 2019 12:35:37 -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=HfgWPH4l; 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 S1731786AbfDETej (ORCPT + 99 others); Fri, 5 Apr 2019 15:34:39 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39886 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731611AbfDETej (ORCPT ); Fri, 5 Apr 2019 15:34:39 -0400 Received: by mail-yw1-f67.google.com with SMTP id z9so2724209ywd.6 for ; Fri, 05 Apr 2019 12:34:38 -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:user-agent; bh=1sjVKmuXhVLeJPdr6cYXHsdrlxlSdoGqHJzj+qjCJSs=; b=HfgWPH4lmgDv9Qm0wYYM0YSX7p/5J223RCotchxn0ig0HNWwDhe/bfWVmalb193d+I lrSYGHixHykp4b+WeCxeycJ/svB6kvxsN+UXOJi1C5bs2uEaNAG3AOfiWt2wgqQERAr0 1SohWesg5Fv8XldsD5eXKqmrmm3KYjF11BAyd198U2aTSiRg4Lw8/OB99zOrnjTxR8G6 drwgt3ljZjnPYahC1LoK+Si0axTfGOM53Td8UQoso65gA0S3MTUWEjHiVcMxxsjE59lT sUN7s7ubUd0p3Dr/LhZyQ3obCwowCTyhqiBTubree0nTzEcUGCiD4jMql98aqVcjv+kW 2C+Q== 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:user-agent; bh=1sjVKmuXhVLeJPdr6cYXHsdrlxlSdoGqHJzj+qjCJSs=; b=cOBZPu5exX59m1wMtv+O6OeTOejiiPU8CpbxJFhlYmOJ3NesvtkPsqJ22/3S1PP5h/ 6ZX774gn5xIxu8kEfE8Ouosmj29uAIFaD/6Zd4tQu7iKIKfAEqIZLs4C1ur8D5+RgCPr DCsvDvI4GdiinjnGSChxz6BxUbA3L95LSinq2WINlAuWHmXE4m7Sh8QMO3s19yDPIE8O BtYsf55MF2v9d+Myt6bfBUqcCXfb3j0vGXsdNY/fSiLE5JHTiIRdCAx5geYRN7XDfR62 xfw6/8yLbGWaVDkcAKPXWHRcHDBDgfnGbbtwAuVID4oJzqkVxz0xR87NNrazPvQcpCO0 v69w== X-Gm-Message-State: APjAAAW+eQSBi4ltwkArjho8JhSqFL3tsPr0ndgW0RAi99MPWhOVyZB4 QL6GcV3ulAXD1aIR7yDjoq8fqw== X-Received: by 2002:a81:91d7:: with SMTP id i206mr12039871ywg.87.1554492877686; Fri, 05 Apr 2019 12:34:37 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::777e]) by smtp.gmail.com with ESMTPSA id 23sm7668952ywq.91.2019.04.05.12.34.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Apr 2019 12:34:36 -0700 (PDT) Date: Fri, 5 Apr 2019 15:34:35 -0400 From: Johannes Weiner To: Zhaoyang Huang Cc: Andrew Morton , Vlastimil Babka , Pavel Tatashin , Joonsoo Kim , David Rientjes , Zhaoyang Huang , Roman Gushchin , Jeff Layton , Matthew Wilcox , "open list:MEMORY MANAGEMENT" , LKML Subject: Re: [PATCH] mm:workingset use real time to judge activity of the file page Message-ID: <20190405193435.GA16947@cmpxchg.org> References: <1554348617-12897-1-git-send-email-huangzhaoyang@gmail.com> <20190404163914.GA4229@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 05, 2019 at 07:23:46AM +0800, Zhaoyang Huang wrote: > On Fri, Apr 5, 2019 at 12:39 AM Johannes Weiner wrote: > > > > On Thu, Apr 04, 2019 at 11:30:17AM +0800, Zhaoyang Huang wrote: > > > From: Zhaoyang Huang > > > > > > In previous implementation, the number of refault pages is used > > > for judging the refault period of each page, which is not precised as > > > eviction of other files will be affect a lot on current cache. > > > We introduce the timestamp into the workingset's entry and refault ratio > > > to measure the file page's activity. It helps to decrease the affection > > > of other files(average refault ratio can reflect the view of whole system > > > 's memory). > > > > I don't understand what exactly you're saying here, can you please > > elaborate? > > > > The reason it's using distances instead of absolute time is because > > the ordering of the LRU is relative and not based on absolute time. > > > > E.g. if a page is accessed every 500ms, it depends on all other pages > > to determine whether this page is at the head or the tail of the LRU. > > > > So when you refault, in order to determine the relative position of > > the refaulted page in the LRU, you have to compare it to how fast that > > LRU is moving. The absolute refault time, or the average time between > > refaults, is not comparable to what's already in memory. > How do you know how long time did these pages' dropping taken.Actruly, > a quick dropping of large mount of pages will be wrongly deemed as > slow dropping instead of the exact hard situation.That is to say, 100 > pages per million second or per second have same impaction on > calculating the refault distance, which may cause less protection on > this page cache for former scenario and introduce page thrashing. > especially when global reclaim, a round of kswapd reclaiming that > waked up by a high order allocation or large number of single page > allocations may cause such things as all pages within the node are > counted in the same lru. This commit can decreasing above things by > comparing refault time of single page with avg_refault_time = > delta_lru_reclaimed_pages/ avg_refault_retio (refault_ratio = > lru->inactive_ages / time). When something like a higher-order allocation drops a large number of file pages, it's *intentional* that the pages that were evicted before them become less valuable and less likely to be activated on refault. There is a finite amount of in-memory LRU space and the pages that have been evicted the most recently have precedence because they have the highest proven access frequency. Of course, when a large amount of the cache that was pushed out in between is not re-used again, and don't claim their space in memory, it would be great if we could then activate the older pages that *are* re-used again in their stead. But that would require us being able to look into the future. When an old page refaults, we don't know if a younger page is still going to refault with a shorter refault distance or not. If it won't, then we were right to activate it. If it will refault, then we put something on the active list whose reuse frequency is too low to be able to fit into memory, and we thrash the hottest pages in the system. As Matthew says, you are fairly randomly making refault activations more aggressive (especially with that timestamp unpacking bug), and while that expectedly boosts workload transition / startup, it comes at the cost of disrupting stable states because you can flood a very active in-ram workingset with completely cold cache pages simply because they refault uniformly wrt each other.