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 X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16806C433E1 for ; Thu, 20 Aug 2020 00:26:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CB43320885 for ; Thu, 20 Aug 2020 00:26:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gHcwkVEn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB43320885 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5480A6B008C; Wed, 19 Aug 2020 20:26:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F9516B009B; Wed, 19 Aug 2020 20:26:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40F318D0003; Wed, 19 Aug 2020 20:26:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 2B5566B008C for ; Wed, 19 Aug 2020 20:26:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DC829181AC9CC for ; Thu, 20 Aug 2020 00:26:29 +0000 (UTC) X-FDA: 77169055698.02.bears78_1d05de62702c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id BDA8910097AA0 for ; Thu, 20 Aug 2020 00:26:29 +0000 (UTC) X-HE-Tag: bears78_1d05de62702c X-Filterd-Recvd-Size: 7061 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Aug 2020 00:26:29 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id r25so83698lfe.5 for ; Wed, 19 Aug 2020 17:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mE4zqw7ry1MfZH9x184nZ2vzhA0MYzok+VpmlWA+zfk=; b=gHcwkVEnunAcNAqPlLjtg0pSC0LdqrIfnZYk/Ajg6bM6EpGoCa/IaA4IjPsMfKhIE2 DWR+LcqK6o1msWSHL7lEADWCyseNQlRdVCWfqN16VTR+v3gg5NnBEhWkUAZEm9+vcnBN kubQnJ9KgFgT16G53OTR2T+kS+H1xRWRUd/u9OZxqTCNFZYNrGprPlDtXKwcZ/9IJHGg lug2//c6ZgN2mQ5eOHUW5mGeUDmw3ZLKKJzuY8Qn0teavWO/or7bsADvVdHKt5vYi2tu ExPBGB8SM56GfFnMXpuzbGH91OapxDb+0b+lTlWPbU/5bQ3t2jRofUPbxva/5kUr4xRC fK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mE4zqw7ry1MfZH9x184nZ2vzhA0MYzok+VpmlWA+zfk=; b=ckgfo0xR0a/ibQ9G5p0l5TDFrVbDFgwAjN543hn6dNzc2J1X9Nwm9zGHVXu8zCxYo/ k9nNRNNUkF/aYa/Ak3TjXMihBq56ETMPGuv13m1ukxiFNayNzM2KzNiiqHrJSFWBR9Kz uD+OFo4o0oj0yCsKdCh1KDAIvxfNcZB0cXUExt16wMNPt5CIiuiawcvyhlKFWMtksGjr QVUaHSCMTXfCCgyyW4RZGh6V+xvHnDUpcQQT/xviEOIComHjrU4LQhSWEju5rs9eumu0 uBnRifMfGS70elqe6tavfxxasEHCQnfVni6QAKZ8yo/359pyb0fGasjckmdn9a8U+liM h8xg== X-Gm-Message-State: AOAM532WoqTesDSz/zR9fbGrUx/aPzlSClSVHf1tZ+0xhDPINurdaijA o4+QeZTQMHKiq5TIkLOQ8R77j3enCeufjYzb40lC9A== X-Google-Smtp-Source: ABdhPJzrx/IQU+mOMBkIIzva9xPTUvU8f5r9F0LCweN2I86LVvJdng0MXgFo31CaU5p30Rqf0utS7tPTJOUJidgUNIg= X-Received: by 2002:a19:c68b:: with SMTP id w133mr284468lff.189.1597883187523; Wed, 19 Aug 2020 17:26:27 -0700 (PDT) MIME-Version: 1.0 References: <20200818072501.30396-1-sjpark@amazon.com> <20200818072501.30396-7-sjpark@amazon.com> In-Reply-To: <20200818072501.30396-7-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 19 Aug 2020 17:26:15 -0700 Message-ID: Subject: Re: [RFC v7 06/10] mm/damon: Implement callbacks for physical memory monitoring To: SeongJae Park Cc: Andrew Morton , SeongJae Park , Jonathan.Cameron@huawei.com, Andrea Arcangeli , acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendan.d.gregg@gmail.com, Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, "Du, Fan" , foersleo@amazon.de, Greg Thelen , Ian Rogers , jolsa@redhat.com, "Kirill A. Shutemov" , mark.rutland@arm.com, Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , rppt@kernel.org, sblbir@amazon.com, shuah@kernel.org, sj38.park@gmail.com, snu@amazon.de, Vlastimil Babka , Vladimir Davydov , Yang Shi , Huang Ying , zgf574564920@gmail.com, linux-damon@amazon.com, Linux MM , linux-doc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: BDA8910097AA0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: On Tue, Aug 18, 2020 at 12:27 AM SeongJae Park wrote: > > From: SeongJae Park > > This commit implements the four callbacks (->init_target_regions, > ->update_target_regions, ->prepare_access_check, and ->check_accesses) > for the basic access monitoring of the physical memory address space. > By setting the callback pointers to point those, users can easily > monitor the accesses to the physical memory. > > Internally, it uses the PTE Accessed bit, as similar to that of the > virtual memory support. Also, it supports only user memory pages, as > idle page tracking also does, for the same reason. If the monitoring > target physical memory address range contains non-user memory pages, > access check of the pages will do nothing but simply treat the pages as > not accessed. > > Users who want to use other access check primitives and/or monitor the > non-user memory regions could implement and use their own callbacks. > > Signed-off-by: SeongJae Park [snip] > +static void damon_phys_mkold(unsigned long paddr) > +{ > + struct page *page = damon_phys_get_page(PHYS_PFN(paddr)); > + struct rmap_walk_control rwc = { > + .rmap_one = damon_page_mkold, > + .anon_lock = page_lock_anon_vma_read, > + }; > + bool need_lock; > + > + if (!page) > + return; > + > + if (!page_mapped(page) || !page_rmapping(page)) > + return; I don't think you want to skip the unmapped pages. The point of physical address space monitoring was to include the monitoring of unmapped pages, so, skipping them invalidates the underlying motivation. > + > + need_lock = !PageAnon(page) || PageKsm(page); > + if (need_lock && !trylock_page(page)) > + return; > + > + rmap_walk(page, &rwc); > + > + if (need_lock) > + unlock_page(page); > + put_page(page); > +} > + [snip] > + > +static bool damon_phys_young(unsigned long paddr, unsigned long *page_sz) > +{ > + struct page *page = damon_phys_get_page(PHYS_PFN(paddr)); > + struct damon_phys_access_chk_result result = { > + .page_sz = PAGE_SIZE, > + .accessed = false, > + }; > + struct rmap_walk_control rwc = { > + .arg = &result, > + .rmap_one = damon_page_accessed, > + .anon_lock = page_lock_anon_vma_read, > + }; > + bool need_lock; > + > + if (!page) > + return false; > + > + if (!page_mapped(page) || !page_rmapping(page)) > + return false; Same here. > + > + need_lock = !PageAnon(page) || PageKsm(page); > + if (need_lock && !trylock_page(page)) > + return false; > + > + rmap_walk(page, &rwc); > + > + if (need_lock) > + unlock_page(page); > + put_page(page); > + > + *page_sz = result.page_sz; > + return result.accessed; > +} > +