Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4786318pxj; Tue, 22 Jun 2021 08:02:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpc+5rAHDkWh+ELcn6fGwBxYvItScANHu5XFfLtCBpryLtvonYNwvertYHMdF0eMmMukr8 X-Received: by 2002:a02:380c:: with SMTP id b12mr4337711jaa.98.1624374158133; Tue, 22 Jun 2021 08:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624374158; cv=none; d=google.com; s=arc-20160816; b=m+n2i4kbdi54OxBHMSk87t1fYXtI9m7nvlLYT7ZVwUwS+YTUAztL0+MkAsV3oyOi1z GqkkptqO6RLfAEnq96P6c3BTbin7u1oIwsaM4nlJ1hMv/qXxku2NcZXauGja1B5Ad5XP PFhTLKqHxGrOMiK8hJ2QkqfXgW6JzM2D+Z2mo+od0UymovGl6sEIr0LvMLtAEXHKZ279 LN8NcDMqhk15iaaFCgRoql6PBRvz1SWhVJoCUHK0BXNNfzqpGUYBywmD+aYFim67qlEw oX2SKLBX4LLj5Kd1MBefOFjvO2Io3alkG4giOfRHzmR4Ib4kt/MXNQ1NwediwoOULk3L zLRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=ABmBYcu+4/n1dOlRPVKWB0dreKwbq6pnswqP3dJxTt5ma7hrdaUBnnyvjqwsGoo3OK 8jyjB/TY5KTEjoJ4g9xveSW/YUr1c/5rPsubvJN1Z603q1F2HwQJAHBH548x1PnS4Bt/ U6NT0DM/+ZY2xZCgzKnlLYyMBGdgQbcF8B+rMld/V9atyDzyp1D9f93MCOaMDWVT1bqn 4QiQXtQXXu/JsqblD0+Lvli2ojxZ9QfiR+j3tbjkRXtFNP04ORhgT7OcsFrirTycnzTV AQ4XaDE1CIWVtYhRlEpmhhdV8C8GdxEUr3Ft8JHCb42LWupJ4Y7+jeHDR8Zi/9GhOVaO xBgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EUy5hSQv; 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 8si27183902jao.112.2021.06.22.08.02.24; Tue, 22 Jun 2021 08:02:38 -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=EUy5hSQv; 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 S232100AbhFVPCH (ORCPT + 99 others); Tue, 22 Jun 2021 11:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232107AbhFVPCF (ORCPT ); Tue, 22 Jun 2021 11:02:05 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F75CC061756 for ; Tue, 22 Jun 2021 07:59:48 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id f13so3435111ljp.10 for ; Tue, 22 Jun 2021 07:59:48 -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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=EUy5hSQvlr8ahlU4CaiCb2eNOofiUSD+vYfRdctNN157O9jl4+Qq6tJH0mQqexJocZ dFdPNn1PjMVEHq0IZrzaliNGMXUSDFSr0EdImVqstiim9tRoM3nKofzeXq7b/mU/6fty anECsJMjFdAuTnUKKVJ11E+l4p0WdjrMpeySt/wlkJTwGd7SsFHtEeXIXcNuTjGHMvif 9h2PLYOQfdmOMXX7EfR8VWZPsOkylWcIVTdCA+Bj5Me7VVI2kDE2ii9bRPqlXimNXQvk oD5k6m6h/LW9X2W11+sf10Dr+i9o0gQYG4rsiI9twScaF761lflMTuA++iJv/mB9b7z6 PwFg== 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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=cmgRXYLKyHyDgGAAXcOKg3YsuQpxqE9ArM++C/nu1RgOPmZHk8KhMqOcNP2dCtMb4I 800Lbv1ZiYMlWvj7qE09npCuQNi1DkG5LPxwPDgaLAW2yy4pXKxtgD8foDBnfe1jve5h /KcjV5oVE5ctfC8KEbyt1ggh9TnFsazwa97p0bbKtlldl+DCrydyzHzukJPgh7PEpLVg QnkXTYQVMlwoDPs1U/5/nvJB3k5u73fC1M4/4ltRP3308fq9IvsXeqL/JTAhwWufwe4a 4KpaYRIZi2ZpNbQbjcFHlmOb/NfeVS8OSfJRZVO73Mqf5roIsf8DhXImKwGDsrAhVDJp D9dg== X-Gm-Message-State: AOAM531dy7IKgv6fJHHU28jtOH2NeCEhL1p9F2tj1nZbt/x4HLuqzpXx qNbNA6KhLuS8d9SqnsHzRo2tvRmS+IjubnMUAJyvLg== X-Received: by 2002:a2e:8190:: with SMTP id e16mr3684033ljg.81.1624373986663; Tue, 22 Jun 2021 07:59:46 -0700 (PDT) MIME-Version: 1.0 References: <20210621083108.17589-1-sj38.park@gmail.com> <20210621083108.17589-4-sj38.park@gmail.com> In-Reply-To: <20210621083108.17589-4-sj38.park@gmail.com> From: Shakeel Butt Date: Tue, 22 Jun 2021 07:59:35 -0700 Message-ID: Subject: Re: [PATCH v31 03/13] mm/damon: Adaptively adjust regions To: SeongJae Park Cc: Andrew Morton , SeongJae Park , Jonathan.Cameron@huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, Brendan Higgins , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, Marco Elver , "Du, Fan" , foersleo@amazon.de, greg@kroah.com, Greg Thelen , guoju.fgj@alibaba-inc.com, jgowans@amazon.com, Mel Gorman , mheyne@amazon.de, Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , Shuah Khan , sieberf@amazon.com, snu@zelle79.org, Vlastimil Babka , Vladimir Davydov , 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 Mon, Jun 21, 2021 at 1:31 AM SeongJae Park wrote: > > From: SeongJae Park > > Even somehow the initial monitoring target regions are well constructed > to fulfill the assumption (pages in same region have similar access > frequencies), the data access pattern can be dynamically changed. This > will result in low monitoring quality. To keep the assumption as much > as possible, DAMON adaptively merges and splits each region based on > their access frequency. > > For each ``aggregation interval``, it compares the access frequencies of > adjacent regions and merges those if the frequency difference is small. > Then, after it reports and clears the aggregated access frequency of > each region, it splits each region into two or three regions if the > total number of regions will not exceed the user-specified maximum > number of regions after the split. > > In this way, DAMON provides its best-effort quality and minimal overhead > while keeping the upper-bound overhead that users set. > > Signed-off-by: SeongJae Park > Reviewed-by: Leonard Foerster > Reviewed-by: Fernand Sieber [...] > > +unsigned int damon_nr_regions(struct damon_target *t) > +{ > + struct damon_region *r; > + unsigned int nr_regions = 0; > + > + damon_for_each_region(r, t) > + nr_regions++; This bugs me everytime. Please just have nr_regions field in the damon_target instead of traversing the list to count the number of regions. Other than that, it looks good to me.