Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp169376rdb; Thu, 30 Nov 2023 01:14:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmau2lFoesH67/unolslqZ2WmobHg6bBIUg8WhDKEfl2j/AQvPwnZqxmfLcAITCkOUav7l X-Received: by 2002:a17:902:d346:b0:1cf:b1d2:a9f5 with SMTP id l6-20020a170902d34600b001cfb1d2a9f5mr16065805plk.56.1701335690523; Thu, 30 Nov 2023 01:14:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701335690; cv=none; d=google.com; s=arc-20160816; b=xgalG6VsaVMJWk47qkuorykbQjSuVeLChQX+hXDBCTKNSzERmT94wZ308sodt7RNPG PMXDFWlrC9w7Utr/KCYAmW6DEzjSbvnruiE+mJoIYskHtf4SxIREgsvidHC8dc78Z5AW A6hNquQZJhHYOuUA+084fhhRvT1g7MUz2KgX29znHoWRINdn5SI4vFlPMJjd4pD8qHIO 9TrP9cYBpiPrMpf0jnIgV5cUDYO5/TAcdVtdo8iNIjuTGsk14WnCa0+FbzRQq2qAMoz1 v+JzPRVbhPH19Z5V8ZBEXqytimEBfb5WHvnGvf41i89EXxZgwKk+pOTNsPsPSbZOE2PS 2tIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kkZm04lfRlD3mzOUGiHtFxV8qZ1vw4L1VTf3erF9dac=; fh=5xrNAZ3G9anYsY2FUSiKgj0Ap6H/8EJb4xW1COhFbkw=; b=tsGEDI91Y07ySd3GA+3+FLAeIha+ZJipMrGcQFWaNLRikxBniG2oJ/1src9Nb5otZk hjTYOJ885l3gl2Tb0wRAWCL4ShmRiQTOC7FWXxb3UFudh/vqTNow2GW4yYQAcIB19PQZ sa0Pjm528qDSc4gQB5Nm7O96V4wbQ6PPCvXkxkXMW9Wen1rGjC87WJhgxl+xarBYPB11 WdpYKgSZa77l2PxfhXcTwV3S0bgst2xRZ1CA+8B5eDw0c5viu9m5C328rOIhFhlSylab +tBooVtD1n0cheHK36uC8oS5dZAxU1swQhGftaAD6S/8SUhTRBXtCnmSl7B8dwwmvd2S XSeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XARN8ftd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bd10-20020a170902830a00b001cc5f995bccsi755715plb.182.2023.11.30.01.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 01:14:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XARN8ftd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B4F158041180; Thu, 30 Nov 2023 01:14:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235009AbjK3JO1 (ORCPT + 99 others); Thu, 30 Nov 2023 04:14:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbjK3JO0 (ORCPT ); Thu, 30 Nov 2023 04:14:26 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03BC1A8 for ; Thu, 30 Nov 2023 01:14:32 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cfc2bcffc7so6663685ad.1 for ; Thu, 30 Nov 2023 01:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701335672; x=1701940472; darn=vger.kernel.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=kkZm04lfRlD3mzOUGiHtFxV8qZ1vw4L1VTf3erF9dac=; b=XARN8ftdHu7RvmsxQnJP9OUtda79Rz3Ua6qMKRIxomYTCteBpdApQFQqTkYKOeXIlz nOX23kFGIFtM3QuCVMB++l1l8KXfixGGY0mKziOLMrlKv40AMb+IKNek3GKdNGJkNhWY 6obnKsExtMKO1TepvPUwX+kNsNLfwxXzf1QwQAPECkt/XeE3ePYG6VLEt2iJB0z2a1ks sen8PeonG58XkV9ijH3caZcjM8Q8savj3oJZO5rYr98DWRtl9jamlzob21xWY4RtkFiA cJBAbEXCXN6gZB9maq6r8mIxKnjq7j4qwJJKqzb0kXnHO8uWIkaVSTn6INvs7/egygVg A5QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701335672; x=1701940472; 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=kkZm04lfRlD3mzOUGiHtFxV8qZ1vw4L1VTf3erF9dac=; b=cJIyxFI23Q8Q8IJe53I7T2/5VfkHGiw5jUXheDQkHPR3GwKNa8FGnT59SkAgU6JAqC LyrFJhagAJ5gIskooHj6mZJWJfrQGcfnZVP4NgegniwNTgZdJLjvEBqOFEDfzdS27kEf Yey+WOZnQ/dODYSC1Q2NXrKgXiuxmrov3vA3FrJHc5JGkcDoThE4kxC/ir0KQ2N91Awn SFtokVET4DcVLu4wRHvhfE5h2uQkGmJGmQf/Z9x4gitsuGIC8m/sS+N6cjHOR64Ef8s8 TqPXD3u1Vdb0D0RBaiINAzczAN2xKjZRB5EEbhwvvHnjdGQNn+qtqND6ru6JHtBZwyx8 tm8Q== X-Gm-Message-State: AOJu0YwoUQ1UxuRhmqhf6Zk9ds4S/+z3uN1wt8UvJ8YYono3TPKV9lcm 5Tbiup0boDK1fe9jNFt8Yew= X-Received: by 2002:a17:902:db09:b0:1cf:cc0d:b269 with SMTP id m9-20020a170902db0900b001cfcc0db269mr15176117plx.40.1701335672265; Thu, 30 Nov 2023 01:14:32 -0800 (PST) Received: from cuiyangpei ([43.224.245.227]) by smtp.gmail.com with ESMTPSA id y4-20020a170902700400b001cfc46baa40sm835498plk.158.2023.11.30.01.14.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Nov 2023 01:14:31 -0800 (PST) Date: Thu, 30 Nov 2023 17:14:26 +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@xiaomi.com Subject: Re: [PATCH 1/2] mm/damon/sysfs: Implement recording feature Message-ID: <20231130091426.GA13946@cuiyangpei> References: <20231129131315.GB12957@cuiyangpei> <20231129171058.50270-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231129171058.50270-1-sj@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 01:14:47 -0800 (PST) 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. Thanks. On Wed, Nov 29, 2023 at 05:10:58PM +0000, SeongJae Park wrote: > Hi Cuiyangpei, > > On Wed, 29 Nov 2023 21:13:15 +0800 cuiyangpei wrote: > > > Hi SeongJae, > > > > We are using damon on the Android operating system. It starts monitoring > > when app comes to the foreground, stops monitoring and save the > > monitoring results when app goes to the background. > > Thank you so much for sharing this detailed use case. This will be very > helpful for us at understanding real usage of DAMON and making it better for > that together. > > > > > The two methods that you mentioned, > > > > 1.tracepoint events > > This method requires opening the tracepoint event and using the > > 'perf-record' tool to generate the perf.data file. Then parsing the > > perf.data file. However, the user's phone is not enabled tracepoint > > events. Additionally, the generated file is quite complex, and we only > > need memory addresses and access frequency informations. > > That's fair points, thank you for kindly explaining this. > > > > > 2. damos > > There is no direct Python runtime environment on android phones. > > > > Both of these methods provide results that are not very intuitive and > > require complex parsing. We save the results in the format of starting > > address, region size, and access frequency. When the available memory > > reaches a threshold, the user space reclaim memory with low access > > frequency by calling 'process_madvise' function. > > Again, very fair points. So, if I understood correctly, you want to reclaim > cold pages proactively when the available memory reaches a threshold, right? > DAMON could do that directly instead of you[1]. Using that, you don't need to > save the access pattern and parse but just ask DAMON to find memory regions of > specific access frequency range and reclaim. Have you also considered using > that but found some problems? > > I understand the feature may not perfectly fit for your use case, and I want to > learn from you how it could be better. > > [1] https://docs.kernel.org/mm/damon/design.html#operation-schemes > > > Thanks, > SJ > > > > > Thanks. > > > [...]