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 DF3F9C47DD3 for ; Mon, 22 Jan 2024 17:56:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7771D6B0095; Mon, 22 Jan 2024 12:56:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 726E86B009A; Mon, 22 Jan 2024 12:56:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EED16B009B; Mon, 22 Jan 2024 12:56:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4C5826B0095 for ; Mon, 22 Jan 2024 12:56:22 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 19E7480B2A for ; Mon, 22 Jan 2024 17:56:22 +0000 (UTC) X-FDA: 81707701404.14.EF5D442 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id BE50720009 for ; Mon, 22 Jan 2024 17:56:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=C99ZHiti; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705946180; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1uv1tMQqW0Arv04x+lB8QhvPZh2KlOB5Rs8pLzmMb7A=; b=RPa4QDhQfnH5iE54OiOdzWiyZTPUVf9K+cddhH/ui4uKziZGkahUN2wFNeThzBw994NSOc RZYaupUcGb6uhL2812clCdkqmskrysVG1dWEiB0fEpHGejTQhHAQ6MgEVSL9pQtK8V/nEb RCNvbGAThBmqXGL0b7D6ecr995L+o2E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705946180; a=rsa-sha256; cv=none; b=TRKaMy5k9xQlp60c70dAQElf6Owxm0/sMZtsZlwKB8iKVH4TYlo8ztiteQSh5As0RP2DJu peja0tSXmqk9mVUZj1UpK/4VC0R66LR3vr2jxG1ikpgM6oXab7ybBAyrJ07zCYda9nge5k EV479fD/18jl1QobUMq9DRqaGE8hVXA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=C99ZHiti; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 21130CE1D71; Mon, 22 Jan 2024 17:56:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAA75C43394; Mon, 22 Jan 2024 17:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705946174; bh=TV6kmzHej1eOV5PjQSphBRoan0WDagVe/CDQQutnVms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C99ZHitiFHDxHhxnoMTF5gAzLE7++CpQpMeXRlUQsFxHsUB8CvFe+EmaQnDkm1LxZ xTl8o7x6lP4TVp7f0WkAAmI+YG0zgsWuX8zny8qcmgY+I08A5Fkkbdu04b4nKgKRJG ASFLI8sp8Ske/N5O6nArJFNZP/pkaccnQR5XXDv5fCxOtZjk4hC6UE/i3ytTP05HXn DkSNQjk1tLz9gennB6lKei8WX947rjoz1FG1geXSR9xsLI6agR45ErxBZiTKYd/vo4 agzQTg0fSaMXdekwuD3zWHOT5xRKRhboUT4Ht1j9+IHayslRyyJzjdECJ4QEpDfyKB fknoz4UgvnHAQ== From: SeongJae Park To: cuiyangpei Cc: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xiongping1@xiaomi.com Subject: Re: [PATCH 1/2] mm/damon/sysfs: Implement recording feature Date: Mon, 22 Jan 2024 09:56:11 -0800 Message-Id: <20240122175611.46371-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122054631.GA7880@cuiyangpei> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: wdn9yd5b9d1hcnzii9kmbibdc75xbidt X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BE50720009 X-Rspam-User: X-HE-Tag: 1705946179-800413 X-HE-Meta: U2FsdGVkX18SFOgkWTiNnjRPzskgICQ9z/Nup3eFoLpm0SLs/dkK/THSbCmEv7t2ApkbVjRpi7s0+FdUUzTKoxncLMuZns/OClWR259LNSS8V/cYxlzRNjvd6u2YV+wULQ/Madnephe4YdtROjYTC+nK/m/0ETHsMqsVNm8UDe2AE+akHS1O1+OCzB01ptPj0CpXRmWev9Hcyn8bqov/qIYsxkIOSqo6IyeVy2diF5Gho4V264tRK4ulhsb18U/Mlzdtu6+mTVCS/5lx5PuVDoUb09vYpg/1gh2JnKzhwtU931iK32Ry/m1WoVxeSJCuYnP5oEBE0yJ/lyTFYMr1SoYzL9KcVxhADKZmznHwcwVKfVz8X6LTewzp6MIluf8ciBNlhKSic9CZHgzFkGoW2Fy8AvqTSsWWfbtocXYaTdIexCDAZhSzkHYz0+jUovLdB2HrxiqKdLU9sCl2YQGwJNi1mKnlmxOWcYhh+QQlCbNHeAcHC0cTwzoJ4Fxlspvf073BUA7qFnh1t56oHtTmD6cvBbGTHm3Qyja8YAw4kWmSfiHQwDCJ/LkUJ/+8Pg/5hNFZDe6pt6oSHQqlfHgyz/6KTxG63O++FqstktxrA1yJxzg8xZS/fvIB6Q0ZCMFdn1O/dBELwNL+0x7KKKL8oWddRm0LBFngYWi+pHees4MmmwTrbzF2InKrYqXCFhV9CgNXXKvBUNn78pkZyju1k+GYPiQJBbjrE7vdVIajyojK/VK5ei0m7ah4Tohzmm6SjlGn8vCc6gTlXldvjzAbtYpUBHT4NiZOuQx48jOh7+IDHCDiAEGRlGitzr8ULFrQAaXzmR3bn5L14WvDMkryiTncF6lWs2zAajPiAzARPRkMuEbs2F3PAPVEPGS2kChw551nDvdGUrviJaTU6Wq+PEP/VMOyGZPKdSkXPAMFZo0npm54t26IIa4XVkh7f1H3HJ02Di5j7CB0wx5lXv7 zCT6yAmh Ak0KQ2YeQYzMf2NoEsvUFFZEpUpMgZsodUulpIV467EXQiU4M+O73RFmNzeCC1oUho/p9qHsXTyKlipQeBmTRKTV9I4LxFACLMXwA6ff30W4RRbY5766PdRKQKfV8XjNENtxyfroV26Dj5vPVvWMDoAFi5DNIs9W7GvUO5wr2yWCMWZEasKcMusEZITk2pZW1tCyGMni4g2x+4Hq189fBZ2YVqVz9LZ7SUJMy1bwIY45qnGM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: [...] > > Hi SeongJae, > > We set 'access_pattern' and 'stat' action in schemes when apps are on > foreground, record apps' memory access pattern when they are switched > to the background with 'update_schemes_tried_regions' state. But it > catch the snapshot after next aggregation interval. DAMON is still > sampling during the app switches to the background and the next > aggregation time, which can cause the value of "age" to change. The > sampling results during this period cannot accurately reflect the app's > foreground access pattern. > > 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. > 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. > > Do you have any other suggestions? As I mentioned above, I'd suggest the DAMOS apply interval of single sampling interval for now. Thanks, SJ > > Thanks.