Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp873589ybt; Wed, 24 Jun 2020 13:28:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZSZf1afbxt3BDAaiM2Bs+Lirrdau5rSpAePjOT56KmUoj3TRtI/RFHTusx7XIDUh4vbAb X-Received: by 2002:a17:906:8607:: with SMTP id o7mr18020717ejx.142.1593030487152; Wed, 24 Jun 2020 13:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593030487; cv=none; d=google.com; s=arc-20160816; b=inoGNGgH22l4I20d2bZCzsmESzyQS8fZUxqCQ13Mc8K2toffmXbSeMCyFjumrO7WVv m0WU61lr6qxzeO3cUQsbJpDniovWH8m6mqQXuphUkYjLmcipKASgMxpKpB9x31WzyGme f7c9Wlon6NYsmZjO/wvwcpbPfBK6DTu/98bgRH3elt9cDsQvZobe+QFfktXBy1RE91CQ 2Tg1ppZQM3qQW6jEfR37X7ft6MLvGxE0qz4woTa8nGmtyZCZte2v0hzatmcnXLB72eHh zeyOAcEmLX3sYUVmNBvcVVEyARfcOuQTSu2tAD7F7uFcyRZIWe4cGykfgn1vQ6EgsNai 5PiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=xCUSxv0g2Bu/1rTm4oH3eK8BnfOA2PJ5Xt3ZipqFJ2s=; b=R9HJbYwZWbPQKl5UxpGubTGm+u3rbuTcWyHncDUNFcv59FTpFItl8lp5qpEJE2FlK0 LPGjezk8aDhSJVFNG0T+wlUdWBQ4D9YkiJcSOLYCEbOy2H93JTu8pmVasP0w4TlnxDjL VPl6PQrZRgo7DaNG+NgxijQOvwxhNFImX1EbilTxCKo5uXUFk24mxMM1gfT+rB7Hxs+d yMlH03whpLQmcwc4pBg0W4G2aixe84cVJz8hVYvJJJY0MgqHE9fT0I5VuoSDsLKbGYkN I9jWiAenC0rMY3zoSaTu51Zhgsn9hj4CYBnqUR2FkpuGeUpDMKVxxga+WtHpKLxWqz3L x2Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw26si5563315ejb.240.2020.06.24.13.27.43; Wed, 24 Jun 2020 13:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406397AbgFXUYP (ORCPT + 99 others); Wed, 24 Jun 2020 16:24:15 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:43340 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406312AbgFXUYO (ORCPT ); Wed, 24 Jun 2020 16:24:14 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U0dBJOp_1593030249; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0U0dBJOp_1593030249) by smtp.aliyun-inc.com(127.0.0.1); Thu, 25 Jun 2020 04:24:12 +0800 Subject: Re: [PATCH] mm: filemap: clear idle flag for writes To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Rik van Riel , gavin.dg@linux.alibaba.com, Linux MM , LKML References: <1593020612-13051-1-git-send-email-yang.shi@linux.alibaba.com> <20200624115317.792d8fc6369d421d2898ab2f@linux-foundation.org> From: Yang Shi Message-ID: <61fdaf3c-261f-9138-4c4e-a0a859094786@linux.alibaba.com> Date: Wed, 24 Jun 2020 13:24:08 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/24/20 12:50 PM, Shakeel Butt wrote: > On Wed, Jun 24, 2020 at 12:18 PM Yang Shi wrote: >> >> >> On 6/24/20 11:53 AM, Andrew Morton wrote: >>> On Thu, 25 Jun 2020 01:43:32 +0800 Yang Shi wrote: >>> >>>> Since commit bbddabe2e436aa7869b3ac5248df5c14ddde0cbf ("mm: filemap: >>>> only do access activations on reads"), mark_page_accessed() is called >>>> for reads only. But the idle flag is cleared by mark_page_accessed() so >>>> the idle flag won't get cleared if the page is write accessed only. >>>> >>>> Basically idle page tracking is used to estimate workingset size of >>>> workload, noticeable size of workingset might be missed if the idle flag >>>> is not maintained correctly. >>>> >>>> It seems good enough to just clear idle flag for write operations. >>>> >>>> ... >>>> >>>> --- a/mm/filemap.c >>>> +++ b/mm/filemap.c >>>> @@ -41,6 +41,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> #include "internal.h" >>>> >>>> #define CREATE_TRACE_POINTS >>>> @@ -1630,6 +1631,11 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, >>>> >>>> if (fgp_flags & FGP_ACCESSED) >>>> mark_page_accessed(page); >>>> + else if (fgp_flags & FGP_WRITE) { >>>> + /* Clear idle flag for buffer write */ >>>> + if (page_is_idle(page)) >>>> + clear_page_idle(page); >>>> + } >>>> >>>> no_page: >>>> if (!page && (fgp_flags & FGP_CREAT)) { >>> The kerneldoc comment for pagecache_get_page() could do with some >>> updating - it fails to mention FGP_WRITE, FGP_NOFS and FGP_NOWAIT. >> Yes, will propose a separate patch later on. >> >>> This change seems correct but also will have runtime effects. What are >>> they? >> Other than a couple of extra cycles when idle page tracking is enabled, >> I didn't think of other effects. It should be negligible. The idle flag >> doesn't play a role in page reclaim algorithm, so it won't have impact >> on that. >> >> > The only user visible impact will be on idle page tracking users. They > will get more accurate data. Thanks for elaborating this.