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 C9CABC47422 for ; Fri, 26 Jan 2024 06:57:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0684F6B0080; Fri, 26 Jan 2024 01:57:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F35426B0087; Fri, 26 Jan 2024 01:57:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAE856B008A; Fri, 26 Jan 2024 01:57:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C13866B0080 for ; Fri, 26 Jan 2024 01:57:16 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3B91B80EBF for ; Fri, 26 Jan 2024 06:57:16 +0000 (UTC) X-FDA: 81720555672.19.9E26D60 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf25.hostedemail.com (Postfix) with ESMTP id 61611A000B for ; Fri, 26 Jan 2024 06:57:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=K164TcA5; spf=pass (imf25.hostedemail.com: domain of cuiyangpei@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=cuiyangpei@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706252234; 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=obmNILo/IhMsOn7tNaJgOnb5hD2rgV9SrDPKtcBkAB0=; b=gx2UX+7IPNPC0Hb4IpG47DIJ0wE3Yoy4q6O8D+aUa3bRUqw1q7xCCidp4AhGHlxHkSfl1h L5lREpq1POnRyV2P5QqZ0B/LJMVLzsYBd9PStQE+Zl3yZ369uthyJsq50rT4bcAh9zvreq kmC+EYmsx7M9YW3A9BjHJVHGtf/wLBo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706252234; a=rsa-sha256; cv=none; b=KIhToZl8xaMP/P2zTuqpGGwk15FccZDCkuSVh7Jnx47mKhdrhjvYg9xoWTGtp7MVq3bMA5 YTI9x+pF6JFhMlv/hukAjsLZDA9LlFVc+2wOWdn6Ng7pG85c/labzAuYltyCKFc3smlNvG YNAuw8buROzswU6hCpCFGlRJNHw2VfA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=K164TcA5; spf=pass (imf25.hostedemail.com: domain of cuiyangpei@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=cuiyangpei@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6ddc2a78829so7854b3a.3 for ; Thu, 25 Jan 2024 22:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706252233; x=1706857033; darn=kvack.org; h=user-agent: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=obmNILo/IhMsOn7tNaJgOnb5hD2rgV9SrDPKtcBkAB0=; b=K164TcA5PLkC7ElJ7f00YxOao5he+ZiC80B1OF0AldieePf1AohqJviVTSNcdgC6/i pJVWxz4Le7rwOW5H8xaUvq/5aoCBM9DLNd77II6EZHcPYaF0dZyPOst2Fn7EvtqzhWAq YxHzD84pMnW6ZKUvk3s5WtFBdwFtOoAdbT7nVhPMNOoRtQ+8LxFCSX0yQHAc60+Mkwfs ZNHzzqzV0XSF9QHeJ/f5A5xoJRIUzzi/VjwAVH8+mKH0N+w3HHwGnZfL1fKgFOWd+ylI NboQKgQ4Y0xY/hELZzE9t0Zfv3jcyupF0kQCHwy+A5a917b4TD2QIT28oiXPgOv1gVU2 tiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706252233; x=1706857033; h=user-agent: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=obmNILo/IhMsOn7tNaJgOnb5hD2rgV9SrDPKtcBkAB0=; b=FlpHGebY0dfMMEVNqVu6pxyKoryEHbtwgO0RfenwJH7PQjT0QKYxSRt30T61/lxt6P kf9PpnYQrRMDofsxFCE8iIBdl1g6F2V6phJpPerof5qGx1ihUSaw0ypWlQfG24Fdtu4p ugyQOV6sqSPu2RY/aHppwRvr7fdLzARjlgR3i9LKkx+Cl7SGYF1B0evrHdcBFWwDfbZ8 Y/d8tQZAPY3OiaZ62sTQXaQr1CXmQmNJ6hIUNMtda7YoaNWXXtfB0nDMvX9M8juCZ69/ E3hQUT2EUC+2A2kx+Sy0QPPmYyk8XKGjIIERyC4D7fJ0+iYWxxf8MJpwlPKvo7+7rLK3 xcsw== X-Gm-Message-State: AOJu0YxrNyvPu/aJ9+LFa/BlwKewOkSPcPbMDPNHpkiM6MNuiZBtqtRT oclIKN14kGKc1DMZ/2RtD8qeH3q3uQFAaAiw7XWuxu0Kph3qAUjd X-Google-Smtp-Source: AGHT+IG7PKlIuVbF4dQed4/SZvmdfB0JA0BdDNlbOuweQSdzYs2QW8PJVNxyumqtKvz2V3xPIQE9Gw== X-Received: by 2002:aa7:86d7:0:b0:6da:8572:ecab with SMTP id h23-20020aa786d7000000b006da8572ecabmr587227pfo.64.1706252233040; Thu, 25 Jan 2024 22:57:13 -0800 (PST) Received: from cuiyangpei ([43.224.245.227]) by smtp.gmail.com with ESMTPSA id lp17-20020a056a003d5100b006ddd182bf1csm533350pfb.46.2024.01.25.22.57.10 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jan 2024 22:57:12 -0800 (PST) Date: Fri, 26 Jan 2024 14:57:06 +0800 From: cuiyangpei To: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: xiongping1@xiaom.com Subject: Re: [PATCH 1/2] mm/damon/sysfs: Implement recording feature Message-ID: <20240126065706.GA16652@cuiyangpei> References: <20240122054631.GA7880@cuiyangpei> <20240122175611.46371-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240122175611.46371-1-sj@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 61611A000B X-Rspam-User: X-Stat-Signature: 4ggkibo6tt4dsr597g3r7rqk8oj4x53c X-Rspamd-Server: rspam03 X-HE-Tag: 1706252234-623582 X-HE-Meta: U2FsdGVkX1+K81zphA6G69FKwC8Kp/9tO+pzGlCqG8UcAuLALwhVuBz5Jr9iAa3KBDimKsQzmAOeS8/dAM6eQVkw7OWlMnHnmV0V4mqZ/pDdXKwP3fOXyChnlVoyE6796ccpOfzjxBziVsGSWeniA4PVo2roCXejFje2hGyNKbN2wwQsRaPXoLzyOgbKu5R34d2w05QEGv0ke8GRrhFo9mArfK7j44d3v+TBV4AIdP155RrgCpfUEFCNymLDUBkdYB6cDDSKgK+T7mzao4gujtRY2hB9GhhX1YNq0gXau46aDn/jh39STyFMU2Y27rN7xU/2HHP2Oe1G8qJaSW28NwAZnBOh/zhwQqlr96C3Knfv1p582bHtd66fh8KKg35lTm1s6bv8f9rRZwiyDb0JpJgm1aKgJO15+h2cuo8UCO1rBS7BxdaZ820RWHgzhu3HnXEt5a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294459, 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 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: > [...] > > > > 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. 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. > > > 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? Thanks. > > > > 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.