Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp19741rdb; Mon, 22 Jan 2024 10:30:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxaRoVCP45xd04+lOFLLsaRXLiQ+HIWPHGc9QjYAS5oz27Cogk2PwGT3ssNnNZmRDvDmPh X-Received: by 2002:a2e:8611:0:b0:2cc:8923:9e65 with SMTP id a17-20020a2e8611000000b002cc89239e65mr1916994lji.22.1705948232592; Mon, 22 Jan 2024 10:30:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705948232; cv=pass; d=google.com; s=arc-20160816; b=RKAgWPC+myrA7I32DHhqlFegtG464KRJtEFyUEnsoa/NiQLK6r9FjzPUPlTt39hIN5 APyOgvWFM5+D/HAPsPDe9ADpb/+nQC2KI6S2+98b4H/kc7UiOZO0k9+2obS9/abxRcm6 z3giaBLU3d7RU89OgN9Gqm9e9eLg3VRMkI/mn3z96OzHh7ZW/RIW8xDTezjr0us8Ufn3 7hPXhgPso/+98IYL8Fd59pT/tBEGaVvQfvANhM0deu8J73d0EamDXbJ32G6tQUqg073W MJMQj7IKSldRE9OSRzBAmQDtM4B5pY+gayFJYkBdWrZsn7/jJ76D3Hgs9dWP5QCgkDCK 5wMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1uv1tMQqW0Arv04x+lB8QhvPZh2KlOB5Rs8pLzmMb7A=; fh=UfQOkad9c7itxlc2aN206qkrnbaxAD6j72EGLuO7fjo=; b=yFrjeDob6X2nuZMVXscE2w5J4UoeExjoYU2j8X5nDUnRMUJlni4cAax1S26Vy3yfXT Sq7DZzIRcedmiMm+iCIcI9Bj3dQoSCJPrslXDnfPc0s89pCi56wzeZoQ4vTf6Fu/w/ub a2skqVu/AshaEUyNsl3tgLxK2bigF6XT0wYnxt2dSBeCxle09YRIY+Lh0RfXtFuiWUIn TvGGXoIKo3cWa/qFTl1/uK6xBVCsBiJdA7mIrIEdFF8aUwD0CKLMNo/aVg0oCLZjCz1V a0MRUkrtD6KEFn45icjxdP2hzQwEyMnFp1cBCiM4kB+CobYE55zWgleuHxCED/+LWDp9 TnlA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C99ZHiti; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u19-20020a50c053000000b0055a059380a6si4813647edd.621.2024.01.22.10.30.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:30:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C99ZHiti; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 88D5A1F25AAC for ; Mon, 22 Jan 2024 18:26:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF3735B5B1; Mon, 22 Jan 2024 17:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C99ZHiti" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9F1450243; Mon, 22 Jan 2024 17:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705946175; cv=none; b=Rzq8BZCvebcfjKtY5EQbtGNUAwMnWA1XdOG5veTV3Aw1w5yBKtJwvUBvo8p4f6oxKxxEksbg3hB2vVvNEJ8dhOQMm9ihSUVXBt1Q2rqnr/rtYgQy55AUT6H5QhMrtbpO2QKKVhk9ylcDEtL9+KC1c+RBuSaSm09Spm4FELAPGn0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705946175; c=relaxed/simple; bh=TV6kmzHej1eOV5PjQSphBRoan0WDagVe/CDQQutnVms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g5GItIKu4dEmhL7cbTOhxKrA/cesNX3HnVGZ3PhNrSnSIEc4AUcFa5wYvr3lB1xhMn0ChVG2fim/AdHnUCDGBJ9Np18pY07YD/An96BKF36r09pVFH9D0JCi6xfro1FIjDpUl6R09EGVeVSU0GimtyU9eJDhV/6Jf1PYS7EvkVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C99ZHiti; arc=none smtp.client-ip=10.30.226.201 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.