Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp882612ybg; Mon, 27 Jul 2020 02:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqavuspjJ2e5HDyOTs0/OAW7bgrpuQ0Cn6ohWOnbSVkvgj6zGL/0ZqpgTbFhc+NTdPkZL7 X-Received: by 2002:a17:907:205c:: with SMTP id pg28mr18976835ejb.22.1595840676020; Mon, 27 Jul 2020 02:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595840676; cv=none; d=google.com; s=arc-20160816; b=zzs0GhlTClCpsQpZOpEbODbgpbIgqF7EswW/R1mk2KXGj7GhMDdWKqBmmca1ldDQ/H Ffn6HNe4FEWcXWifxXAdOIO20GsAzWv2931D1Q+ShF3zbivLceaT2zgRBSblF5zlA23a f+RUAy5u9aD9bu4aFvy4bEvAS1647YsbyAlfS4SRlB/vHC3lzzKw1reviZggKXZq0Oda qT7f/UkpNg33pEoAC5/PG5xHv2ksd1pZclEEtUPE8hWuzXEAcQeY+8u9BX4xi/UgmgLS U067n0QYWr6+I2S5fCEqmDHqFpEc+fJnyNKgstYzS/R58Fb6fztyANnPVbEk0brO03Gh N1YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:dkim-signature; bh=oYQUjD8dm/BApSQBrI8Gg5yalczlaUdJshqRb6pjbFc=; b=nQ5LTB/2P/zN59VKtJP7az+09puNdA5y5u8fxZmUyobvKybtOrBJqczWkTtnouT9lz NAImv2OhuHIA7Z/R9o/k6YHAm92p/d/9rJAh3zsH+1Z2QbMw8mnNWbRzAcVMmC4/j8Zp ilHcaZCh5ST/eql/ajN40I2Ilsfe1cWaArycdN9WNgpaVU4CbzxmBS6AqhgFj3fWGaLl Ft1KXiQEZWQZZ2mzLoXVK1J1MxplAdzZ99Cy9l0VuO07M3BvE4359+OatAgS2qUQXIyF YyzOWt6qpyJdSg+wQQ9on4Zhx3vRnUu2AfEqCUlnkA/AHAZmvBPML4gEpnwa30i/BRtP Hmvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=YvSZb7Y2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si5006205edl.300.2020.07.27.02.04.14; Mon, 27 Jul 2020 02:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=YvSZb7Y2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbgG0JDg (ORCPT + 99 others); Mon, 27 Jul 2020 05:03:36 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:23452 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgG0JDf (ORCPT ); Mon, 27 Jul 2020 05:03:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1595840616; x=1627376616; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=oYQUjD8dm/BApSQBrI8Gg5yalczlaUdJshqRb6pjbFc=; b=YvSZb7Y2b+yrwvLX5yBmaw36yNlVZEVU9HhkmXeMyFiytCSldgQwZELN rLsqKiLNxfuvotkN8yeP7/yQ8F+cL7f8HQobVqo9wqv9kmgoXcC8VOUmz krqwKIJMMSfmx0zuQaS8DQzABQPRe6sJoZiiG6Ih3YJAms0qbCJJHXwCR c=; IronPort-SDR: SeUBRoAaOOHBYkmwX+kFFfS0f8E2TXF9TxG1RPvIcCdkvjKgx+opOY2SaqTBlDb9GuvV29duQw S/y4+38llViw== X-IronPort-AV: E=Sophos;i="5.75,402,1589241600"; d="scan'208";a="63149857" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 27 Jul 2020 09:03:33 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com (Postfix) with ESMTPS id AD0E1A1E1E; Mon, 27 Jul 2020 09:03:30 +0000 (UTC) Received: from EX13D31EUA001.ant.amazon.com (10.43.165.15) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 27 Jul 2020 09:03:29 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.160.48) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 27 Jul 2020 09:03:13 +0000 From: SeongJae Park To: Greg Thelen CC: SeongJae Park , , "SeongJae Park" , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: Re: [PATCH v18 06/14] mm/damon: Implement callbacks for the virtual memory address spaces Date: Mon, 27 Jul 2020 11:02:55 +0200 Message-ID: <20200727090255.24114-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.48] X-ClientProxiedBy: EX13D47UWC003.ant.amazon.com (10.43.162.70) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Jul 2020 00:34:54 -0700 Greg Thelen wrote: > SeongJae Park wrote: > > > From: SeongJae Park > > > > This commit introduces a reference implementation of the address space > > specific low level primitives for the virtual address space, so that > > users of DAMON can easily monitor the data accesses on virtual address > > spaces of specific processes by simply configuring the implementation to > > be used by DAMON. [...] > > diff --git a/mm/damon.c b/mm/damon.c > > index b844924b9fdb..386780739007 100644 > > --- a/mm/damon.c > > +++ b/mm/damon.c > > @@ -9,6 +9,9 @@ [...] > > +/* > > + * Functions for the access checking of the regions > > + */ > > + > > +static void damon_mkold(struct mm_struct *mm, unsigned long addr) > > +{ > > + pte_t *pte = NULL; > > + pmd_t *pmd = NULL; > > + spinlock_t *ptl; > > + > > + if (follow_pte_pmd(mm, addr, NULL, &pte, &pmd, &ptl)) > > + return; > > + > > + if (pte) { > > + if (pte_young(*pte)) { > > + clear_page_idle(pte_page(*pte)); > > + set_page_young(pte_page(*pte)); > > While this compiles without support for PG_young and PG_idle, I assume > it won't work well because it'd clear pte.young without setting > PG_young. And this would mess with vmscan. You're right, thanks for catching this up! This definitely need to be fixed in the next spin. > > So this code appears to depend on PG_young and PG_idle, which are > currently only available via CONFIG_IDLE_PAGE_TRACKING. DAMON could > depend on CONFIG_IDLE_PAGE_TRACKING via Kconfig. But I assume that > CONFIG_IDLE_PAGE_TRACKING and CONFIG_DAMON cannot be concurrently used > because they'll stomp on each other's use of pte.young, PG_young, > PG_idle. > So I suspect we want: > 1. CONFIG_DAMON to depend on !CONFIG_IDLE_PAGE_TRACKING and vise-versa. > 2. PG_young,PG_idle and related helpers to depend on > CONFIG_DAMON||CONFIG_IDLE_PAGE_TRACKING. Awesome insights and suggestions, thanks! I would like to note that DAMON could be interfered by IDLE_PAGE_TRACKING and vmscan, but not vice versa, as DAMON respects PG_idle and PG_young. This design came from the weak goal of DAMON. DAMON aims to provide not perfect monitoring but only best effort accuracy that would be sufficient for performance-centric DRAM level memory management. So, at that time, I thought being interfered by IDLE_PAGE_TRACKING and the reclaim logic would not be a real problem but letting IDLE_PAGE_TRACKING coexist is somehow beneficial. That said, I couldn't find a real benefit of the coexistance yet, and the problem of being interference now seems bigger as we will support more cases including the page granularity. Maybe we could make IDLE_PAGE_TRACKING and DAMON coexist but mutual exclusive in runtime, if the beneficial of coexistance turns out big. However, I would like to make it simple first and optimize the case later if real requirement found. So, I will implement your suggestions in the next spin. If you have different opinions, please feel free to comment. Thanks, SeongJae Park > > > + } > > + *pte = pte_mkold(*pte); > > + pte_unmap_unlock(pte, ptl); > > + return; > > + } > > + > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > + if (pmd_young(*pmd)) { > > + clear_page_idle(pmd_page(*pmd)); > > + set_page_young(pmd_page(*pmd)); > > + } > > + *pmd = pmd_mkold(*pmd); > > + spin_unlock(ptl); > > +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > +} > > + [...]