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 8A54DC47258 for ; Sun, 28 Jan 2024 09:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B68786B0072; Sun, 28 Jan 2024 04:13:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B18576B0074; Sun, 28 Jan 2024 04:13:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B8F06B0078; Sun, 28 Jan 2024 04:13:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 893306B0072 for ; Sun, 28 Jan 2024 04:13:09 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1AEB81601C5 for ; Sun, 28 Jan 2024 09:13:09 +0000 (UTC) X-FDA: 81728155698.20.70AB31A Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf12.hostedemail.com (Postfix) with ESMTP id 723994000F for ; Sun, 28 Jan 2024 09:13:07 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JaqCI0fG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of cuiyangpei@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=cuiyangpei@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706433187; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=acLZOEynjKiK7s/lexC5VGK4yZ4FEotAitBzQjrV9U4=; b=bFBNEH1TpjD7/JAdOQXHq2IQnCadX/q8hfDU0da0aPO7lzCTBbC9f01EAN5+wUNLuIolVs Deq8x1u5/MFfS5ZXH314y66BRjVwi8JOsTgptSE346K1vyJRc+EFfMQbTUlSFNWfeZs14d rOQEgKxXwDiTsjbI/r8uSuMpuq17HXw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JaqCI0fG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of cuiyangpei@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=cuiyangpei@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706433187; a=rsa-sha256; cv=none; b=4hj6/x2/ReNzxJMuUxc5utAzDBP/ZvS9oLSXqjW9H+G8KfJHrFFdaD/mh61oQ6oY7F7T0w 3WtNSwURJdUS8CRe7U6mN1xVoNWue2017UHZYZ5e+hMzELJOHgzRC0FpLG4ltxwIaadigU qJr8AviCR1pOqBr4XFJHnZiNRB1Vg9o= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ddfb0dac4dso1449835b3a.1 for ; Sun, 28 Jan 2024 01:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706433186; x=1707037986; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=acLZOEynjKiK7s/lexC5VGK4yZ4FEotAitBzQjrV9U4=; b=JaqCI0fGh/ht6EjD+c33V1TTQrnOT+0qwGohkcKKdrgdfKrup9CKYM69ZSUkNv+e30 Jk12BNr8UYQORu8eNBAduux/fJ4VRZmMcj7wA8kvxqpfckF3AKvgPJkcEKENRDtzxEvD E8VYL4CBhPycCrQE5OZE80szu5fdaqk7c8Oj7zlLaf8mO1Y4Q9FeWUjaMFxPy1gXrMmM Zx7D1eU0dm622l5CiViFSzSX8OnA/SxWMYmj9Nx6uoL6uSC6voGRSZVDiAX5hExTg3Ey mL9skkLkFbYTmwF+XheqFq5Jop0yTm7h7p3ZynAE0wKXWiLn2DjPHyxfqoLjOjtjGh8L NaaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706433186; x=1707037986; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=acLZOEynjKiK7s/lexC5VGK4yZ4FEotAitBzQjrV9U4=; b=lYN64zDcfYqt0zSML4IFUJaoFqQG3FqDcEljeLlw2JB3aj1JmlS36h+moVuwRtMXZo qkuUM4q5thVGCT8ztVrRWANfSgscvIzMZ4CPwRJIAcAVXzszPxrTO+TsMmmXjlp9ZVEW eOxS4hxI/GPwQimlZT3YUOEifKjxDwKt2uCNcHjFQF2Kqg5GP8JFqeRqoBAiAnMeG0wt 9rRnJQb4oxj3TLkZk6j+FJW6tdQZUz/7lErlIGXKbjh2QCApQLvK6umMikiuUCvMSz/2 U8IHixP+MrGGwWK4PsHuJy6Ftc/tI2u3PM8OMZHLuDUKUYoxjkN0djnPZsBg2MpjXQ2J Z5ng== X-Gm-Message-State: AOJu0YzhL5SVjp0wfsvu76KsQ28mZVbqglL1Wgvxhw8OV+HRQBnU9jry 3sLYo61WXsEkcxpHOxbqMNnq5DK03GBdfLp3EFrAD2XQWolISymt X-Google-Smtp-Source: AGHT+IGVSXMwhvAVXiaEic9M2v+ZLMqMnlBUCWXEZ/jyvI1kYhN2vFmSFunS2p0WsjEPHkQi2jI5yg== X-Received: by 2002:a05:6a20:6d4:b0:19c:9d4d:7d7 with SMTP id f20-20020a056a2006d400b0019c9d4d07d7mr1724532pzf.41.1706433186004; Sun, 28 Jan 2024 01:13:06 -0800 (PST) Received: from cyp-ubuntu ([43.224.245.229]) by smtp.gmail.com with ESMTPSA id f14-20020a056a00228e00b006dde27853afsm3800852pfe.113.2024.01.28.01.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 01:13:05 -0800 (PST) Date: Sun, 28 Jan 2024 17:13:00 +0800 From: cuiyangpei To: SeongJae Park , sj@kernel.org, akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: xiongping1@xiaomi.com Subject: Re: [PATCH 1/2] mm/damon/sysfs: Implement recording feature Message-ID: References: <20240126065706.GA16652@cuiyangpei> <20240126080454.15649-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240126080454.15649-1-sj@kernel.org> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 723994000F X-Stat-Signature: fy4jptq9ixn36msq9kju3n3e3pd4ha8m X-Rspam-User: X-HE-Tag: 1706433187-336115 X-HE-Meta: U2FsdGVkX1+SRN5QXdvnM4FWnXBEf4KweNIoCW60iP0y7m+3LDUCDGk1p4i0FgKwZ6zYFgukzEgl4+l5NsEPwDX6aumD8iUz9I6JTgb9caUezdw/HtNIuJpqaPe7SROiIHyzNA/R3dFxJDgvU1VBil7V5VuGlCY2O3QukYpZ8jtbzhthmBjATL5azZ5evhClz7QRrSXGa68bGpcbALGjQhCKucDVgkOUMz+06qe9fHIrISewkO4KUZ4gK1DK3m+Uvl5LzbfK9iOXUJW7Cj/cTAnZYQjiVuYMWGprNv1T7/Rg9OH/ZdJf+kGaiTiDK8FjhxYUp89DfjonYNr3J3fYBdLD+n9aghQea5OmdFvKDSmevOlYG2A5tCjYbgwVhO64vqtP6wdF51X78FfCqjuK4n3BZIuB6IOIQLx1FTq/0+sF+jG45VGnVyxkYgAf//Vm7xaEhtjGxqYMdNLMhkgZIr+yvD20OaOBUvO57udhcUdEzg1nxXaCJGX8AVgyoFKfim2T8VAXcRrScqdVEYs5FrbW2TaMJs3RLs+xTToZzRCFHPuvjl3ZYhRudKRoBtRZVWmWIBHUrwPYGTas+GU6xFicummx372bsH5ZkS8yAq1XgzAV3nIbRXKoDlEYXmf/DP88q1GInuLjmckdueOcMnv/78n+kcZhZ6Rt3CwVZHknchmQ2xPW9IT/ZHV4jKUihDRkRKmCUoyl+FrILA8d2DlSl4yOjkfl8md5EB0tCUd40RSoJsurWF+gtkwJUgee2GKdZMQpJxIZBftJat9qb8l8OWRUErmjMQ6z754FqoZrhUrLRErp2urCb6lX7YN6Y11lhe6i7oHlevk5/rEiKXuCwEN3rKdDgHl8gVkIxNCp85uvzkwctROjKVACltIjhqBI+Odgt04K4zGPe0Y4lunVxaQJFXcKOduvsZgw4UwY+cq+mf8SmaQrHFK3qVrNNO2YqBf76m+thBvJl9f t5kQDjSG V1bNPoHO15IGdmxttJBdichwm2ar9Om4UNxJYChFIcVe20PiYyIacoS2UZK0tNORR+HkdHutGbPe1Tgv3iNqV9lgSkEmqDLnllByqo6ikwLhj5LnWgvVmadDLfABxhALSN+DLLcjFj1qAQ1o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.015358, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jan 26, 2024 at 12:04:54AM -0800, SeongJae Park wrote: > On Fri, 26 Jan 2024 14:57:06 +0800 cuiyangpei wrote: > > > On Mon, Jan 22, 2024 at 09:56:11AM -0800, SeongJae Park wrote: > > > Hi cuiyangpei, > > > > > > On Mon, 22 Jan 2024 13:46:31 +0800 cuiyangpei wrote: > > > > > > > On Sun, Dec 03, 2023 at 07:37:45PM +0000, SeongJae Park wrote: > > > > > On 2023-12-03T13:43:13+08:00 cuiyangpei wrote: > > > > > > > > > > > On Fri, Dec 01, 2023 at 05:31:12PM +0000, SeongJae Park wrote: > > > > > > > Hi Cuiyangpei, > > > > > > > > > > > > > > On Fri, 1 Dec 2023 20:25:07 +0800 cuiyangpei wrote: > > > > > > > > > > > > > > > On Thu, Nov 30, 2023 at 07:44:20PM +0000, SeongJae Park wrote: > > > > > > > > > Hi Cuiyangpei, > > > > > > > > > > > > > > > > > > On Thu, 30 Nov 2023 17:14:26 +0800 cuiyangpei wrote: > [...] > > > > Is there any way to catch sampling result immediately after setting the > > > > "update_schemes_tried_regions" state? > > > > > > There is no way for exactly doing this. You would need to proactively collect > > > snapshots while the app is foreground, and use the latest one that collected > > > before the app goes background, like recording-based approach would do. > > > > > > I think recent DAMON changes might make an alternative approach available, > > > though. From v6.7, DAMON provides pseudo-moving-average monitoring result in > > > sampling interval granualrity, since patchset "mm/damon: provide pseudo-moving > > > sum based access rate". And a followup patchset, namely "mm/damon: implement > > > DAMOS apply intervals", has made DAMOS works in the sampling interval > > > granualrity. Both patchsets are merged into v6.7-rc1. > > > > > > Hence, I think you could use 'update_schemes_tried_regions' after you noticed > > > the app's state transition, with DAMOS apply interval of one sampling interval. > > > Then you will get the monitoring results after one sampling interval. Of > > > course, the snapshot may contain some of background access pattern, but > > > wouldn't made it changed significantly, unless you set aggregation interval too > > > short. > > > > All other actions will apply at one sampling interval except for the > > `stat` action. > > > > We use 'update_schemes_tried_regions' after switch to the background. The > > before_damos_apply callback function will only be set when the next aggregation > > interval arrives. The `tried_regions` will only be updated after setting the > > callback function. > > > > DAMON is still sampling during setting 'update_schemes_tried_regions' to the next > > aggregation time, which is not what we expected. The pseudo-moving-average > > monitoring result can reduce nr_accesees inaccuracy, but age is still being modified > > during this time, so it can't improve this issue. > > > > Please let me know if my understanding is incorrect. Thank you. > > So, 'update_schemes_tried_regions' command is firstly handled by > 'damon_sysfs_cmd_request_callback()', which is registered as > after_wmarks_check() and after_aggregation() callback. Hence > 'update_schemes_tried_regions' command is still effectively working in > aggregation interval granularity. I think this is what you found, right? > Yes. > If I'm not wrongly understanding your point, I think the concern is valid. I > think we should make it works in sampling interval granularity. I will try to > make so. Would that work for your use case? > It's much better than working in aggregation interval. I have a question. Why does the 'update_schemes_tried_regions' command need to work in the sampling time or aggregation time? 'update_schemes_tried_regions' is a relatively special state that updates the regions that corresponding operation scheme. Can it be separated from other states and controlled by sysfs node to respond immediately after being written? > > > > > > > Alternatively, can it return the "last_nr_accesses" and "last_age" values in > > > > tried_regions/ directory? > > > > > > This could also be a good alternative in my think. Nice idea. But, because > > > the previously mentioned alternative is already available while this require a > > > bit small but additional changes, could we check if the previously one make > > > sense and works first? We could revisit this idea if it turns out the previous > > > alternative is not suffice in my opinion. > > > > > Can you consider adding "last_nr_accesses" and "last_age" two files in > > 'tried_regions/' directory? > > Actually we don't have 'last_age' field, right? And in case of > 'last_nr_accesses', it is a hidden private field, since it is intended to be > accessed by only DAMON core code. Making it exposed to user means exposing > implementation details, and the mechanism that coupled with an exposed > interface is hard to be changed, so be unflexible. Hence I'd prefer making > 'update_schemes_tried_regions' works in sampling interval granularity, more > than exposing the two information if it works for your use case. > Ok, I get it. > Thanks, > SJ > > [...]