Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp992589ybh; Wed, 18 Mar 2020 12:55:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuaCzosaLSuOCXU/X0+rl0wLcMs3RXKFHzNDCNURRyL9PJlHmkFfgAOQ2G33xobll+z7Uqz X-Received: by 2002:a9d:60b:: with SMTP id 11mr5298337otn.126.1584561310475; Wed, 18 Mar 2020 12:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584561310; cv=none; d=google.com; s=arc-20160816; b=IK0VDRq7lSRvj/S8hpytf9XQyArs6NXW0RIPuDF4NsQdmzTTjqwz4SiDHHkOVWWTmv TjDKBo6A8e5WY1HgxiGxIW0UEh85qBafmrvrrM85ZvSxsk9lSpFz7eBp68PvUNItAfgM sSxkrt7bLJg8PDi/i/PkocDsrn09HoG80gN7UHM4zfL4autOm4u4533x1SE9pywDIyWj 0PZJFUS9aAmPesvPVNQ1Kg43yZcSxXPyZggGabNUTZjXQrHQC0mgR+6f0y0VxQ30cCOH pZVnzV2MzGdjrFuVEfS55ef9Fje5Vqzik8T/YT72CSAbdvbh3oXCuKlWySXgQfvG9/8j /aOw== 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=/O7ydZcGkEnjjR0DKfEZl8dzF7U8chbFAqM/QMwcPsg=; b=Oqu+Z0OIKTODNgdlLj3LiEQgRds2XGvAnlCEcjnEG8EMKeQDQP/ljweCD12ILMvps+ bYASNnNM4ieD+FuHGcBzRb2Nr7Tu3F7/Z0929UUd7Ax8DGaWDabZ5KK4GL8Fvmvxi90Q ypHaCGrH2JX1iqMWGQQugectCBlZVAGg+r8ieQD6rzhEpPcZMYsRcXaKO/NcN8IMuSaN nla9//ixgpsGjO/sh/6moYzaQkmyw9P5LHATjx5ExwAXa1J8xVz/LakWBWb0nDRbZrJu 8jAX7TffUuo4f7cuLDx73LaJCGaCGdeVAWfOZecq/VZ4VCu7Fs1ymT7bpwQChK+XCH6Z DQOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bzGHtNA2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a190si3753488oib.146.2020.03.18.12.54.58; Wed, 18 Mar 2020 12:55:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bzGHtNA2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726795AbgCRTxB (ORCPT + 99 others); Wed, 18 Mar 2020 15:53:01 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:42821 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbgCRTxB (ORCPT ); Wed, 18 Mar 2020 15:53:01 -0400 Received: by mail-oi1-f196.google.com with SMTP id 13so86268oiy.9 for ; Wed, 18 Mar 2020 12:53:01 -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=/O7ydZcGkEnjjR0DKfEZl8dzF7U8chbFAqM/QMwcPsg=; b=bzGHtNA2tGO9KKY0VBVcKXGej5Hl6Fvi3iAb97Ei+QJuQs5DgXJIGoSSh33cEvrT89 jDfI2j9hBYEP2DFVT2bu8Ma/xTvnr1TvkkmDWuNjWz0QQcQcYcDGPxKgATGCybrDKkcO yeLO/j/P4tnAVMAVXZ8z35Ifth6PtGFOQtt8eqLen2JxNtuVI0Q1V4YAATUGlsKML0xC beVvRLkOWokeQiA0NWCyzDue30siSFbMShz0g1EgEG/+rBUh/GenyejbbQzUxIh+H6T0 SLOdsi/iKplRCqLTp48HO8JJ4hedHC91oIKM3XpsH5FHgGoj/+62KkhKLTZeCOM1HlOq pKhQ== 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=/O7ydZcGkEnjjR0DKfEZl8dzF7U8chbFAqM/QMwcPsg=; b=gN1WyOo3P2AuptBFFUtfxHpxI7cQs9maL7asRzA3gunxt7hbGMRQJTuEI584OzUYgD fkIJlWT32eRp+VfZMbVD/ZFSP2XTDo4LkrkzsngHLcCngBoyPdcdO5Jw3FD/LzUsbe3K HrxqBlEURSVWc9DyDXD0kiaP1I6rPfR9CinQEtTZMfdEDU8Pk39hDrsKFVc6/vFMIlne WLZEMRg9WJrnZPDrpY40Nw3JMHVg4iPuCVpaXN2Db6DXHx35BkmYQODUXJ75W1GnmH/b olOrLHqWHH/PqmYsJSNSb3yr23jW5EyGhWEECrcAV1XQpAA/NQ+FACVgoEs6S9JQaVSA IV4A== X-Gm-Message-State: ANhLgQ0AMtH2Vtv+aW7gdacv927iJwETxOStXoPOoaxACS5g3MNkU5IQ KPOaknbRP594LbubODsjmey2THkuyMQPMAPkKx20gQ== X-Received: by 2002:aca:af93:: with SMTP id y141mr4368099oie.144.1584561180301; Wed, 18 Mar 2020 12:53:00 -0700 (PDT) MIME-Version: 1.0 References: <20200312100759.20502-1-sjpark@amazon.com> <20200312104345.10032-1-sjpark@amazon.com> In-Reply-To: <20200312104345.10032-1-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 18 Mar 2020 12:52:48 -0700 Message-ID: Subject: Re: Re: Re: [PATCH v6 00/14] Introduce Data Access MONitor (DAMON) To: SeongJae Park Cc: Andrew Morton , SeongJae Park , Andrea Arcangeli , Yang Shi , acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, brendan.d.gregg@gmail.com, Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , dwmw@amazon.com, jolsa@redhat.com, "Kirill A. Shutemov" , mark.rutland@arm.com, Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, peterz@infradead.org, Randy Dunlap , David Rientjes , Steven Rostedt , shuah@kernel.org, sj38.park@gmail.com, Vlastimil Babka , Vladimir Davydov , 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 Thu, Mar 12, 2020 at 3:44 AM SeongJae Park wrote: > > On Thu, 12 Mar 2020 11:07:59 +0100 SeongJae Park wrote: > > > On Tue, 10 Mar 2020 10:21:34 -0700 Shakeel Butt wrote: > > > > > On Mon, Feb 24, 2020 at 4:31 AM SeongJae Park wrote: > > > > > > > > From: SeongJae Park > > > > > > > > Introduction > > > > ============ > > > > > [...] > > > > > > I do want to question the actual motivation of the design followed by this work. > > > > > > With the already present Page Idle Tracking feature in the kernel, I > > > can envision that the region sampling and adaptive region adjustments > > > can be done in the user space. Due to sampling, the additional > > > overhead will be very small and configurable. > > > > > > Additionally the proposed mechanism has inherent assumption of the > > > presence of spatial locality (for virtual memory) in the monitored > > > processes which is very workload dependent. > > > > > > Given that the the same mechanism can be implemented in the user space > > > within tolerable overhead and is workload dependent, why it should be > > > done in the kernel? What exactly is the advantage of implementing this > > > in kernel? > > > > First of all, DAMON is not for only user space processes, but also for kernel > > space core mechanisms. Many of the core mechanisms will be able to use DAMON > > for access pattern based optimizations, with light overhead and reasonable > > accuracy. Which kernel space core mechanisms? I can see memory reclaim, do you envision some other component as well. Let's discuss how this can interact with memory reclaim and we can see if there is any benefit to do this in kernel. > > > > Implementing DAMON in user space is of course possible, but it will be > > inefficient. Using it from kernel space would make no sense, and it would > > incur unnecessarily frequent kernel-user context switches, which is very > > expensive nowadays. > > Forgot mentioning about the spatial locality. Yes, it is workload dependant, > but still pervasive in many case. Also, many core mechanisms in kernel such as > read-ahead or LRU are already using some similar assumptions. > Not sure about the LRU but yes read-ahead in several places does assume spatial locality. However most of those are configurable and the userspace can enable/disable the read-ahead based on the workload. > > If it is so problematic, you could set the maximum number of regions to the > number of pages in the system so that each region monitors each page. > How will this work in the process context? Number of regions equal to the number of mapped pages? Basically I am trying to envision the comparison of physical memory based monitoring (using idle page tracking) vs pid+VA based monitoring. Anyways I am not against your proposal. I am trying to see how to make it more general to be applicable to more use-cases and one such use-case which I am interested in is monitoring all the user pages on the system for proactive reclaim purpose. Shakeel