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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0703EC433F5 for ; Fri, 18 Mar 2022 14:11:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8661D8D0002; Fri, 18 Mar 2022 10:11:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8149A8D0001; Fri, 18 Mar 2022 10:11:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7040E8D0002; Fri, 18 Mar 2022 10:11:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 609378D0001 for ; Fri, 18 Mar 2022 10:11:06 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1E8B923C97 for ; Fri, 18 Mar 2022 14:11:06 +0000 (UTC) X-FDA: 79257693732.08.7352ACD Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf14.hostedemail.com (Postfix) with ESMTP id 3C3CA100003 for ; Fri, 18 Mar 2022 14:11:03 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0V7WdvNv_1647612657; Received: from 30.0.159.17(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0V7WdvNv_1647612657) by smtp.aliyun-inc.com(127.0.0.1); Fri, 18 Mar 2022 22:10:58 +0800 Message-ID: Date: Fri, 18 Mar 2022 22:12:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] mm/damon: Make the sampling more accurate To: sj@kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220318121543.26861-1-sj@kernel.org> From: Baolin Wang In-Reply-To: <20220318121543.26861-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3C3CA100003 X-Stat-Signature: 5758rg896yhu63h4p6jpiq4qn6fffgnq Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-HE-Tag: 1647612663-903365 X-Bogosity: Ham, tests=bogofilter, spamicity=0.008879, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/18/2022 8:15 PM, sj@kernel.org wrote: > On Fri, 18 Mar 2022 19:58:07 +0800 Baolin Wang wrote: > >> >> >> On 3/18/2022 6:49 PM, sj@kernel.org wrote: >>> On Fri, 18 Mar 2022 18:01:19 +0800 Baolin Wang wrote: >>> >>>> >>>> On 3/18/2022 5:40 PM, sj@kernel.org wrote: >>>>> Hi Baolin, >>>>> >>>>> On Fri, 18 Mar 2022 17:23:13 +0800 Baolin Wang wrote: >>>>> >>>>>> When I try to sample the physical address with DAMON to migrate pages >>>>>> on tiered memory system, I found it will demote some cold regions mistakenly. >>>>>> Now we will choose an physical address in the region randomly, but if >>>>>> its corresponding page is not an online LRU page, we will ignore the >>>>>> accessing status in this cycle of sampling, and actually will be treated >>>>>> as a non-accessed region. Suppose a region including some non-LRU pages, >>>>>> it will be treated as a cold region with a high probability, and may be >>>>>> merged with adjacent cold regions, but there are some pages may be >>>>>> accessed we missed. >>>>>> >>>>>> So instead of ignoring the access status of this region if we did not find >>>>>> a valid page according to current sampling address, we can use last valid >>>>>> sampling address to help to make the sampling more accurate, then we can do >>>>>> a better decision. >>>>> >>>>> Well... Offlined pages are also a valid part of the memory region, so treating >>>>> those as not accessed and making the memory region containing the offlined >>>>> pages looks colder seems legal to me. IOW, this approach could make memory >>>>> regions containing many non-online-LRU pages as hot. >>>> >>>> IMO I don't think this is a problem, since if this region containing >>>> many non-online-LRU pages is treated as hot, which means threre are aome >>>> pages are hot, right? We can find them and promote them to fast memory >>>> (or do other schemes). Meanwhile, for non-online-LRU pages, we can >>>> filter them and do nothing for them, since we can not get a valid page >>>> struct for them. >>> >>> For some of DAMOS actions that you mentioned, that could make sense. However, >>> that wouldn't make much sense for some other cases, especially for manual >>> DAMON-based access pattern profiling. >> >> I am not sure about this case, could you elaborate on how this can worse >> the case you mentioned? > > For an example, let's suppose a user using DAMON to know the working set size > of the system. And further suppose there is a region that containing many > offlined pages and one online hot page. With this patch, once DAMON sampled > the one hot page, the entire region will be reported as hot, though the other > offlined pages has not accessed. As a result, the user will think the working > set size is bigger than real. OK, sounds reasonable. Seems I need add a flag to indicate if we should ignore offline or non-lru pages when monitoring for some schemes, which can help to do a good decision.