Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp567720ybg; Tue, 28 Jul 2020 13:01:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0bHUBkqeC0RB25AVHKmH4W9YgEkFHwLefem5a2+WXfw6n0NrkQwfLvXq+i0e064yiRMgj X-Received: by 2002:a17:906:1baa:: with SMTP id r10mr964280ejg.389.1595966510497; Tue, 28 Jul 2020 13:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595966510; cv=none; d=google.com; s=arc-20160816; b=BFrdJ/jinpZD75P+y7ExoBn3njXK0fjS8oO7+1uA4cJml+Xc6NHACEapnhZyZ2XJM0 UC2xP70zhy/cnU99f7YDQ05XEqYpzRDA4wli1N0BKuUqZkoJ3lvvmOWD9WHzg5I565wh ulcasGsjWg7p3pU0YbpVWGW8L/hUtYHEcSHHSqbw0bUtcYnUvumyXwaeM6MQx0LTL707 mSai2F8VSqVUKD3PiMq+km/zBSxuarMOmQF7TIsY3R6HXfR920s4jb5LfFGfSnOfdsws lv59wC2iQ2Bc5L6AeRxB2jW/yb/Ss6vXFDrdI5QJErhoIU6pE3Y2age7cMpb6JpvjUDm T0Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=f+tfDSCx6joFpVNbWriwZ+nE5IIT2DzkqrVvcYVEnWw=; b=q3z4HZPHCiPpX0mriTAXVYHI/YJNcbaa8URKfV2hEMQvDmJ2DVxZk6EfgWRKHU8td6 6lhxN2QmJTsCnBlZG24JR+mpbm5CkiuDtYuf9GwV0e+1PEPY+ynmGHatlbVcurEiUvTr shceEQZeaWtm8XMqzgUIHc5nWzHkLZlVhmVAwud8bf9RMqUG1bRWeA4QhV8Hq8DtqmoD bj5ANtpza7Du4jSKvPvwBrtO6yyoVpKDDY0JaDOU18dgtTrAsdJpgTb94NrYFCsoCCER gnxFTlPpkFwVYTg0O8HG5F6j4jRk2UpK44OmwWCPd9e9CskvhdLib2Xd5rO7ZKdMysy2 HIQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BMICasEX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si8524853ejy.594.2020.07.28.13.01.27; Tue, 28 Jul 2020 13:01:50 -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=@google.com header.s=20161025 header.b=BMICasEX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732024AbgG1Rm0 (ORCPT + 99 others); Tue, 28 Jul 2020 13:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731918AbgG1RmZ (ORCPT ); Tue, 28 Jul 2020 13:42:25 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFC9C061794 for ; Tue, 28 Jul 2020 10:42:25 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id q4so22107243lji.2 for ; Tue, 28 Jul 2020 10:42:25 -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=f+tfDSCx6joFpVNbWriwZ+nE5IIT2DzkqrVvcYVEnWw=; b=BMICasEXZwxvtksCsFf+27H958vekOxWwnaVUI2eOzdFoa1J6Fxax4D0LTGeodE6Fj Ar2QKrOLwTIyuBpVy5fVJzZBqoDe2g4n5fSEHduv7TswquLoEf59GEQVOjHZ9nwa46oz b+OjwAQO57Edln/dFSs4H1RaOJrcZxq1bjSALwWTsQFGNJ1aYxcL85NGd1H65D2UA9dz vK/8PKDGGipeMdG8T8S/ORyHnvjIoDwTQqnNpYMU9wtxboW6Duhd28cDyZgQjMrQ7+zL Ue/yl4nXhK3Q2tAYAmnkFp+g9Dyr+vmuytpjp53nOZrMAaOprvnbqLMSP5xJmtvU8B5v cYTQ== 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=f+tfDSCx6joFpVNbWriwZ+nE5IIT2DzkqrVvcYVEnWw=; b=YvQVIcpEhvZ4DQv8u2KTd8+f9hSlJKFX3oV0wOZP8RyJTsUvbOv39CdUXUN+6L+Hfy raX6lwaWgKuokIuY8KrIShL9VBc6AhOmPwiDBdRmaDskDs8o329veJ5xea2UWYOVIPUe ythf87IdYjK6XRqBngkdhp3lS6q3XPympFtQXLUpmAsLQGi2PXjCTdOUYikUni5SkndR us8SWktECxP0tLghcrMzF+fqQI8wSIDKhMPyVOKmXsUPdlqtQEm8onSlAWjq8H/30tdD m9n+wN08KIuKWJWFPOmhLFZrkeHgxf7vwPrIKGqss595oiS0B/qFls/fKw1NF+WEzPVf b3pA== X-Gm-Message-State: AOAM531uB7DWUVIn9KYxokrQN3dTve+5aTJ4EfAYSYE7hAoUEXX6DFec 62bJEez+S5sZ1NZpXWcyBG6e/FRkh6Jx36s4y+PlHg== X-Received: by 2002:a05:651c:10f:: with SMTP id a15mr12140486ljb.192.1595958143475; Tue, 28 Jul 2020 10:42:23 -0700 (PDT) MIME-Version: 1.0 References: <20200727090255.24114-1-sjpark@amazon.com> In-Reply-To: <20200727090255.24114-1-sjpark@amazon.com> From: Shakeel Butt Date: Tue, 28 Jul 2020 10:42:11 -0700 Message-ID: Subject: Re: Re: [PATCH v18 06/14] mm/damon: Implement callbacks for the virtual memory address spaces To: SeongJae Park Cc: Greg Thelen , 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, foersleo@amazon.de, 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 , linux-damon@amazon.com, Linux MM , linux-doc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 2:03 AM SeongJae Park wrote: > > 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. If you are planning to have support for tracking at page granularity and physical memory monitoring in DAMON then I don't see any benefit of coexistence of DAMON with IDLE_PAGE_TRACKING. Though I will not push you to go that route if the code with coexistence is simple enough.