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 917EEC10F04 for ; Fri, 1 Dec 2023 17:31:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D151C8D0027; Fri, 1 Dec 2023 12:31:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC57A8D0001; Fri, 1 Dec 2023 12:31:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB3F28D0027; Fri, 1 Dec 2023 12:31:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A99098D0001 for ; Fri, 1 Dec 2023 12:31:21 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6927DA02D4 for ; Fri, 1 Dec 2023 17:31:21 +0000 (UTC) X-FDA: 81518940762.19.8282D09 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id D81B61C0017 for ; Fri, 1 Dec 2023 17:31:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FaBiOJUw; spf=pass (imf20.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701451879; a=rsa-sha256; cv=none; b=Ho1lS1w4gVQPrsrUZlrbxO2xO5eLU2dDF2uHW6N3CUtF+GS+uwUuQmFzgqBqG07OXl9xoV YN0/14v/tYWAtjpgbnhVj6eHHUav41Q9EQtUReSLrs3Qjlvfark0MEUyJctkLuDyH/8vAN GdkltwsauKf+Q5Yn//wp4r9Fz6iUuHw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FaBiOJUw; spf=pass (imf20.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=1701451879; 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=TBUJgnFzuVOkk++7YW2/rIMyqJt4rE9hlsuUvLl4M+c=; b=n4VIHZuOo7Rdv5bGrBdLcTqe4HXIO8svCuhX/Gq5ZwDf6zCnjlQvg7cQ+iZ3CrZGFLgxqP wTa1wc8UzgfJToBdp/hfJyJ/xF/n6t4iT0DdELRIT/dBieM8+MB8bmxUAgcvVM40kZ9+dW /AtthrP1u41/BghU039AIIIuN2js8PQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id F3AABCE23EC; Fri, 1 Dec 2023 17:31:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A662BC433C8; Fri, 1 Dec 2023 17:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701451874; bh=wA+Ueq448VkzLDqFZSym3+gEJt7y1F440M6KTvullms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FaBiOJUwzapgllxu6aBcQv9MtKgB3w5QJQp3VFfeXWbuu7MxKNe7y713pMHoSGe/3 3u94ST2R/3bQjGwrRzl/NY659HngxTVBfOKQhuhkW+bzHIYayQtbnd7xmqlPCSGhpv xSLkpe2yNqvSBoTd1hXtMClbyDKV6jy7hYxIhhe3HIQyqpogDPfbCEjVfnFazgnsV7 9LqsJU24u9FimiiUjMLeCyQlb/6dmMIfcdPoNK1rlfU5+6RSjSn8qqRjvdfutLvaVt 47+qclvmKRrfMS8gLsY5h4ro3KE5tFk0Bv/bVj32hfhfgzApyxbqtYQkV37Yyfw4Fc gu/Uxz5UifSNA== 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: Fri, 1 Dec 2023 17:31:12 +0000 Message-Id: <20231201173112.64300-1-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201122507.GA15806@cuiyangpei> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D81B61C0017 X-Stat-Signature: jrho4p97wimqfzq34msbn6y36iizskh7 X-Rspam-User: X-HE-Tag: 1701451878-335097 X-HE-Meta: U2FsdGVkX18/UnvbPPvSHDmROMhyHRk5cjTpXJTliSVLDi+bnLyQe6k5/LOYU528JqV24y94n8lUGE+rptDKf6LULeJvtMdIF5ilHW5JuG4nNN6iJMrLOK3A1MOmli76QAWciKSqw0m552i8Dwduo6JESIrCvXyyQUrwJZH8+mRt8F01vIKRvU+zf8aEmkQMEGnbvMrrmRsHK79yh18yc9qwzUG5OD7U8Ez9bexpHvgTDkV4oe5NiR+DVWKGY9o32rxadklmdfSHC3YQIU6Qv5nCJTWXeJ761vgfKzn4Uih3hNYr0BAdBUVOUS5wKIZZInqY90dEK1n4RUBSOiQzw6oiDx0UuQvnZksS9d7OV16ua9n2tFJTQMRO35IdXF/pTy2QDf44NaHy0MHMFGUG9LlJ8KA3llEM0Pp7LgWAQZMkTMFb0l0jLVBXTABSa4n/qkKr5KfU1r5zYeUAmc9MBHeJcpai2mNVsF+Z3Hpi05ZL7BGYf/ndhSYsI8NBiQ2ZnEeogNmvaA2IZF0BkXnjUJYmqVsH9Iy/Dqxtqmq7n15banO9hsdVRIawCWxPA3fjACV1vmwPQl36/Rrd8lUXLFicHq9F8wgaUSTRDPlDmXvoK2X94Z4QxeialfUZGfwsYf+YpF606Y/ueec3IHda/Vp8TFh8PoDzJf+AZTiINQYoAbPb0VaviCVqbRGgBcZ8idBGyRckgoHRp/ZbYJ+231zqYQCqmGxj/F9DrjK3NVo6gA1VtTIt2ZMkufipD75Y0ey31r4gIzGYr/rsBR8wDFQ9mvNmx7vfVDQbo4mJYNsmNMzBif5kJexW74mtr9XbTBnuWYr+yrHILFbizL/02PuTjrkLLZMXe4brXrcJ8ZohJNzSDDr/NBxNY7HqrUxTX21DR4e8V33qF6tTUAlRrcbV3LReBC5uUKGqPtbVbUosS/ruDHeza3KmSIj6z/17FdkDhhF8BojvuyX7WhD eCmop9uX rmsJeUYam3QXk3hfxfoMrjY2aUgJfVngzAZsmVwh2GxWGfuXSidQlhU91EuQtoqutNmArsDWWJOK5z/Wdat5GtNI/Sz6pv4/Bg18gmOs/1VrkUJ4QGzcioYzYjF4LNPfn4MkvKmZSo5FsIYtnMnvk7niouq3/YBDseLkc8NVf0mtLttNeh6+DDs3wPQ3C1mkNrYStd0/iIaBAvpUUgsEonMAKtk0UR6fptbbTPA3qfy3K5yDcd78Fb/v8RdNCPO1cyuXJKtGya125vpkSOSsaCHu37YXsgV2jjf1HK6I1C3mDUYk7/Tj26EvKKg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 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 also investigated the operation schemes you mentioned, but we don't > > > think it can fit our needs. > > > > > > On android, user will open many apps and switch between these apps as > > > needs. We hope to monitor apps' memory access only when they are on > > > foreground and record the memory access pattern when they are switched > > > to the background. > > > > > > When avaliable memory reaches a threshold, we will use these access > > > patterns with some strategies to recognize those memory that will have > > > little impact on user experience and to reclaim them proactively. > > > > > > I'm not sure I have clarified it clearly, if you still have questions > > > on this, please let us know. > > > > So, to my understanding, you expect applications may keep similar access > > pattern when they are in foreground, but have a different, less aggressive > > access pattern in background, and therefore reclaim memory based on the > > foreground-access pattern, right? > > > > Different apps may have different access pattern. On android, the apps will > join in freeze cgroup and be frozen after switch to the background. So we > monitor apps' memory access only when they are in foreground. Thank you for this enlightening me :) > > Very interesting idea, thank you for sharing! > > > > Then, yes, I agree current DAMOS might not that helpful for the situation, and > > this record feature could be useful for your case. > > > > That said, do you really need full recording of the monitoring results? If > > not, DAMOS provides DAMOS tried regions feature[1], which allows users get the > > monitoring results snapshot that include both frequency and recency of all > > regions in an efficient way. If single snapshot is not having enough > > information for you, you could collect multiple snapshots. > > > > You mentioned absence of Python on Android as a blocker of DAMOS use on the > > previous reply[2], but DAMOS tried regions feature is not depend on tracepoints > > or Python. > > > > Of course, I think you might already surveyed it but found some problems. > > Could you please share that in detail if so? > > > DAMOS tried regions feature you mentioned is not fully applicable. It needs to > apply schemes on regions. There is no available scheme we can use for our use > case. What we need is to return regions with access frequency and recency to > userspace for later use. Thank you for the answer, I understand your concern. One of the available DAMOS action is 'stat'[1], which does nothing but just count the statistic. Using DAMOS scheme for any access pattern with 'stat' action, you can extract the access pattern via DAMOS tried regions feature of DAMON sysfs interface, without making any unnecessary impact to the workload. Quote from [2]: The expected usage of this directory is investigations of schemes' behaviors, and query-like efficient data access monitoring results retrievals. For the latter use case, in particular, users can set the action as stat and set the access pattern as their interested pattern that they want to query. For example, you could # cd /sys/kernel/mm/damon/admin # # # populate directories # echo 1 > kdamonds/nr_kdamonds; echo 1 > kdamonds/0/contexts/nr_contexts; # echo 1 > kdamonds/0/contexts/0/schemes/nr_schemes # cd kdamonds/0/contexts/0/schemes/0 # # # set the access pattern for any case (max as 2**64 - 1), and action as stat # echo 0 > access_pattern/sz/min # echo 18446744073709551615 > access_pattern/sz/max # echo 0 > access_pattern/nr_accesses/min # echo 18446744073709551615 > access_pattern/nr_accesses/max # echo 0 > access_pattern/age/min # echo 18446744073709551615 > access_pattern/age/max # echo stat > action And this is how DAMON user-space tool is getting the snapshot with 'damo show' command[3]. Could this be used for your case? Please ask any question if you have :) [1] https://docs.kernel.org/admin-guide/mm/damon/usage.html#schemes-n [2] https://docs.kernel.org/admin-guide/mm/damon/usage.html#schemes-n-tried-regions, [3] https://github.com/awslabs/damo/blob/next/USAGE.md#damo-show Thanks, SJ > > [1] https://docs.kernel.org/admin-guide/mm/damon/usage.html#schemes-n-tried-regions > > [2] https://lore.kernel.org/damon/20231129131315.GB12957@cuiyangpei/ > > > > > > Thanks, > > SJ > > > > > > > > Thanks.