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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 EABE5C433E6 for ; Wed, 23 Dec 2020 22:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DD6022288 for ; Wed, 23 Dec 2020 22:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbgLWWy4 (ORCPT ); Wed, 23 Dec 2020 17:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbgLWWyz (ORCPT ); Wed, 23 Dec 2020 17:54:55 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BFCFC061794 for ; Wed, 23 Dec 2020 14:54:15 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id o17so982757lfg.4 for ; Wed, 23 Dec 2020 14:54:14 -0800 (PST) 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=G6K+frm4usiDNsy54nqovFvsVKgDfwnlcqwizLUB2sMkLMPHlYnxgfuXUHsOojVXFw /xt2oZRbXSu5CI8DX5+rRvzw4S9LW+Xj/Nc7JSgAoW8ivJkV45cWCKrLTf7PxLxxx+Cx zI9Wm8nTWe1MMOuXTFlce9/yjl8z85vEMsRETL370DlXbffiE1ivHgPADKgCqZwgtqDg 0LcU6uoZKF6W6BUO1wtPdKNyDZLyWe38U3Svmx06IfXYwGPUreI5Omz+Bg1G+IrGOhLF lMfckB64+SM8Xa8ny/ivZLlqJpHPuzr94Aqf+oMcRLV8kMeb5FdyS2AmK/NtXoAU3WCf ocBg== 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=sBn74D4jfb6CMag/SfHf2vwGPklM09B/D+451Lit7Z0+UOEbPzG5vaaB9aP++DLK7e ugeKUoe8mvhkthgnzJ7mEsExAlaD0LrrJpAK3O3VCpq9YmpPJg0eb2+3xtaWPRlt5Uf8 5t18NBBNervNH/zHW1s/VZjpc+mn+tSTHqeqjqPnFOnUEnt/0cvR/p01EeA0go89KnbD dbxWPRJdU9YZGqfsWmH9+OCtaIBfH81k1TkSY52najbajMipvG9ONm+0rylT/w36dIKV 6M+NmMRxUIib4GI2Cg68biF2xH9sf/VFRRJUYyB7/wPC463FSQW/20exbvmLE9nPZt1K bzyA== X-Gm-Message-State: AOAM533lnempVlBN7BMAgV+fTL4M4309i7qIDS+UwTwezOScyPsztKsg xHnkNKjJAuPMYqEAGqjueooMXeL+S6NQfJ76AcoWcQ== X-Google-Smtp-Source: ABdhPJy/Kuiq5nYL/CE16WSk/6X+m/pQAohwMoamwxyWTJjm6Ssj0NyAucKyNP7cAy7nAgBmnP0B7IFJsfjl51hpq9c= X-Received: by 2002:ac2:46d4:: with SMTP id p20mr11066331lfo.299.1608764053186; Wed, 23 Dec 2020 14:54:13 -0800 (PST) MIME-Version: 1.0 References: <20201223164700.29723-1-sjpark@amazon.com> In-Reply-To: <20201223164700.29723-1-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 23 Dec 2020 14:54:02 -0800 Message-ID: Subject: Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: 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, Marco Elver , "Du, Fan" , foersleo@amazon.de, Greg Thelen , Ian Rogers , jolsa@redhat.com, "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , sblbir@amazon.com, Shuah Khan , 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 23, 2020 at 8:47 AM SeongJae Park wrote: > [snip] > > [snip] > > > + > > > +static bool damon_va_young(struct mm_struct *mm, unsigned long addr, > > > + unsigned long *page_sz) > > > +{ > > > + pte_t *pte = NULL; > > > + pmd_t *pmd = NULL; > > > + spinlock_t *ptl; > > > + bool young = false; > > > + > > > + if (follow_pte_pmd(mm, addr, NULL, &pte, &pmd, &ptl)) > > > + return false; > > > + > > > + *page_sz = PAGE_SIZE; > > > + if (pte) { > > > + young = pte_young(*pte); > > > + if (!young) > > > + young = !page_is_idle(pte_page(*pte)); > > > + pte_unmap_unlock(pte, ptl); > > > + return young; > > > + } > > > + > > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > > + young = pmd_young(*pmd); > > > + if (!young) > > > + young = !page_is_idle(pmd_page(*pmd)); > > > + spin_unlock(ptl); > > > + *page_sz = ((1UL) << HPAGE_PMD_SHIFT); > > > +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > > + > > > + return young; > > > > You need mmu_notifier_test_young() here. Hmm I remember mentioning > > this in some previous version as well. > > Your question and my answer was as below: > > > Don't you need mmu_notifier_clear_young() here? > > I think we don't need it here because we only read the Accessed bit and PG_Idle > if Accessed bit was not set. > > I should notice that you mean 'test_young()' but didn't, sorry. I will add it > in the next version. > I should have said mmu_notifier_test_young() instead of mmu_notifier_clear_young(). > > > > BTW have you tested this on a VM? > > Yes. Indeed, I'm testing this on a QEMU/KVM environment. You can get more > detail at: https://damonitor.github.io/doc/html/latest/vm/damon/eval.html#setup > Hmm without mmu_notifier_test_young() you should be missing the kvm mmu access updates. Can you please recheck if your eval is correctly seeing the memory accesses from the VM? 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 7D838C433DB for ; Wed, 23 Dec 2020 22:54:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA99722273 for ; Wed, 23 Dec 2020 22:54:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA99722273 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 081FF8D0058; Wed, 23 Dec 2020 17:54:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 058D18D0026; Wed, 23 Dec 2020 17:54:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E62978D0058; Wed, 23 Dec 2020 17:54:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id D12648D0026 for ; Wed, 23 Dec 2020 17:54:15 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 90C491F1B for ; Wed, 23 Dec 2020 22:54:15 +0000 (UTC) X-FDA: 77626052070.16.tin72_23039512746c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 6D4BB100E6903 for ; Wed, 23 Dec 2020 22:54:15 +0000 (UTC) X-HE-Tag: tin72_23039512746c X-Filterd-Recvd-Size: 6178 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Dec 2020 22:54:14 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id b26so929975lff.9 for ; Wed, 23 Dec 2020 14:54:14 -0800 (PST) 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=G6K+frm4usiDNsy54nqovFvsVKgDfwnlcqwizLUB2sMkLMPHlYnxgfuXUHsOojVXFw /xt2oZRbXSu5CI8DX5+rRvzw4S9LW+Xj/Nc7JSgAoW8ivJkV45cWCKrLTf7PxLxxx+Cx zI9Wm8nTWe1MMOuXTFlce9/yjl8z85vEMsRETL370DlXbffiE1ivHgPADKgCqZwgtqDg 0LcU6uoZKF6W6BUO1wtPdKNyDZLyWe38U3Svmx06IfXYwGPUreI5Omz+Bg1G+IrGOhLF lMfckB64+SM8Xa8ny/ivZLlqJpHPuzr94Aqf+oMcRLV8kMeb5FdyS2AmK/NtXoAU3WCf ocBg== 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=EmbKDsU6JZ5/6f4Ky7wAgz/yejLM2GGx4qNSjWmhMxhJqfgFZALzrahbX8IfuS9z4g NcpNbJ3WRtK0NBtz+HPFAoAVlzr3LCUI8t96tz+7nJJr85W9UzTcj0NLHWUOabQYLTnT DENFqhW0THTRs0Qw/G0cYdIyfObAwk0NCYg2Sl5SXtkWQo0wgZOZJCtFNvGov6BIXpUX 7oWIn/607i7UHmePgbmTbtSbs9mbD0dB4Knb1fGfITMNZHKrG1J2mi46+IEQN0VY1K1X dMOq5RwdqZjGcO45E8vw75eMLitL+Ie2bpP2Rm6jAJrEjGLLBzD9bpBuyERRkxCr4VNC ZzGQ== X-Gm-Message-State: AOAM531LIIxEmrvjKzHTRGrDK7dHqjDVSxAeFA10oCveLC89OUDQrzVJ 9mfLdmpSyQKZjczEmdZmx1XJeSrlo8jPBqCIszjadQ== X-Google-Smtp-Source: ABdhPJy/Kuiq5nYL/CE16WSk/6X+m/pQAohwMoamwxyWTJjm6Ssj0NyAucKyNP7cAy7nAgBmnP0B7IFJsfjl51hpq9c= X-Received: by 2002:ac2:46d4:: with SMTP id p20mr11066331lfo.299.1608764053186; Wed, 23 Dec 2020 14:54:13 -0800 (PST) MIME-Version: 1.0 References: <20201223164700.29723-1-sjpark@amazon.com> In-Reply-To: <20201223164700.29723-1-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 23 Dec 2020 14:54:02 -0800 Message-ID: Subject: Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: 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, Marco Elver , "Du, Fan" , foersleo@amazon.de, Greg Thelen , Ian Rogers , jolsa@redhat.com, "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , sblbir@amazon.com, Shuah Khan , 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-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 Wed, Dec 23, 2020 at 8:47 AM SeongJae Park wrote: > [snip] > > [snip] > > > + > > > +static bool damon_va_young(struct mm_struct *mm, unsigned long addr, > > > + unsigned long *page_sz) > > > +{ > > > + pte_t *pte = NULL; > > > + pmd_t *pmd = NULL; > > > + spinlock_t *ptl; > > > + bool young = false; > > > + > > > + if (follow_pte_pmd(mm, addr, NULL, &pte, &pmd, &ptl)) > > > + return false; > > > + > > > + *page_sz = PAGE_SIZE; > > > + if (pte) { > > > + young = pte_young(*pte); > > > + if (!young) > > > + young = !page_is_idle(pte_page(*pte)); > > > + pte_unmap_unlock(pte, ptl); > > > + return young; > > > + } > > > + > > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > > + young = pmd_young(*pmd); > > > + if (!young) > > > + young = !page_is_idle(pmd_page(*pmd)); > > > + spin_unlock(ptl); > > > + *page_sz = ((1UL) << HPAGE_PMD_SHIFT); > > > +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > > + > > > + return young; > > > > You need mmu_notifier_test_young() here. Hmm I remember mentioning > > this in some previous version as well. > > Your question and my answer was as below: > > > Don't you need mmu_notifier_clear_young() here? > > I think we don't need it here because we only read the Accessed bit and PG_Idle > if Accessed bit was not set. > > I should notice that you mean 'test_young()' but didn't, sorry. I will add it > in the next version. > I should have said mmu_notifier_test_young() instead of mmu_notifier_clear_young(). > > > > BTW have you tested this on a VM? > > Yes. Indeed, I'm testing this on a QEMU/KVM environment. You can get more > detail at: https://damonitor.github.io/doc/html/latest/vm/damon/eval.html#setup > Hmm without mmu_notifier_test_young() you should be missing the kvm mmu access updates. Can you please recheck if your eval is correctly seeing the memory accesses from the VM?