Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp85495pxv; Thu, 24 Jun 2021 03:27:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiUI5tve3HK+AUBg30wldrt59PjYXpjkSGQf4N3pxocloG2P5dyRwfu9D1NnFK9Kw0nAOb X-Received: by 2002:a02:641:: with SMTP id 62mr3936856jav.125.1624530457551; Thu, 24 Jun 2021 03:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624530457; cv=none; d=google.com; s=arc-20160816; b=GJMUa9x0T+9+XDwb1ITnt5G/RnfySWH3rsQlyXw40/PkyghJ7a+zVG1q1I8tqcPiWZ 7/gb3A9KWkKH1rJmsjUVh+VqTTFwAj8Nf/U2YCBI2KEEg7GnfSG5D4glyUG3ipCVnGOV 1NTO/zBySGEQR/ux+KoCdVK55RHN+/6ATLdTlqUvMq3a70LAXzMkJKWwMm0ToYbwx9gE NNm9LtFfgc8DZEnwd0x1L6wx3SlIqTFFLOHmtAqQZ3KOU0cS2cMv+alUCBBgH2Q1uEX2 bF9lUHmd8eD6asfeXJZswFZ5TqaEfytjeevnlN8U7JfseVWy1HPu1X6ZaIU1ae9165mX qzcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aYxEESGYd+nGspsnDUf9V/geC8TjcsBr5faZa+wAtFE=; b=QdAPMu99nQs6uRcF75YN6KvsMDkGnyS1W+KMfymuLwUYsAzaL5lBAnf7/3vD28sxvS Cz6Gf+TNWWlmnLzLSU3VnJtVmEIyg3oXTm/yTw3g9zN6OHUXG+PWynDm/QYe/ZmqxzME S5XoAM5q6XDg7/Dyz9Rx+mXUb80fJ/S2m0gzJdBiZxYC2IOVxMgHwmjKGzS5WaAOm8FX uiVtD2DiN5PxEfEdCZjSKWrrKb3GG5BmiAE05H/JddEyufjmVwXkcVWYpxtFhyTvz9wI nouYT0Cb6ArNy0XIF6+hYR4odaUHX4iqbGsnK4jjGk4WjO6eJnNpV/npvaeoh+CNyht1 vRvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n9332Kyl; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si3324171jae.125.2021.06.24.03.27.24; Thu, 24 Jun 2021 03:27:37 -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=@gmail.com header.s=20161025 header.b=n9332Kyl; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhFXK3B (ORCPT + 99 others); Thu, 24 Jun 2021 06:29:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbhFXK27 (ORCPT ); Thu, 24 Jun 2021 06:28:59 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915BFC061574; Thu, 24 Jun 2021 03:26:39 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id f16so2997328qvs.7; Thu, 24 Jun 2021 03:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to; bh=aYxEESGYd+nGspsnDUf9V/geC8TjcsBr5faZa+wAtFE=; b=n9332Kyljg+bQ1InWHjSaOf0m9gf3rTgTFgm5k+drGmtNO3PQiPF1r9NMqgk2AXMMQ RDIgan1nerVcawH0Ckn9m3xuLFmklqx2ofXnt5daFr4KEwvkii/ockvzVEAaioWTbUQp thvR56eg5DywSPDD0ShiJ4E9Yl4aJjM/DimbPvX5H8PJJrGAd2vwbNMhTGrosnc/PcRc gxtSnCVCnjf7t5lXUY21QuGdlpjBmLQaea4Vbj+MP4PT3qc5yxoGGgw2WF2xa2hnyItZ /bbYyxXB4LQ6zwDv3C/+EAR/NO7QDTWNn/OtzUr/cF8ZJeOWFuiDpeCQKur/8oaVwfAY mZDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to; bh=aYxEESGYd+nGspsnDUf9V/geC8TjcsBr5faZa+wAtFE=; b=JPUgGCMTCG9bw0yuYYQCAVyJDjPCNcbtDoIr5YVZzisimYAcUIXoVSyIGDKv4GWRS3 zNvMwoOSeC7ffXzxq/BQ39caNP9WI6nJbYzUsXJnkGcFd5X0Oeew1zVgnJqXui3Q3w3r TozMzcawOjYwybm1ekExhVPznYk14G/0SsiM+UnoRraJIPxCnpphv9unng6Im6JGC9sH MgQj99n2J31u2oZOch+0B1v1XWa6gHWEkSQBwYYa04aAOPuNJqrzEm75Av70TV3c6Wk7 Dy7GQGzdWJL+0Td6oocnv3tpEhEz3JpFGhaKLngkr9REotj2p1ysLgYPlNjlBwR2VZSH QIRg== X-Gm-Message-State: AOAM532N4j3L8RZVxQnhLKJbBp0rdzA+0KrGdW6wpwG93WX6Awmvxuy4 N1dGmtzRg/p+r04DF17EtVk= X-Received: by 2002:a0c:fdc5:: with SMTP id g5mr4263859qvs.15.1624530398844; Thu, 24 Jun 2021 03:26:38 -0700 (PDT) Received: from localhost.localdomain (ec2-35-169-212-159.compute-1.amazonaws.com. [35.169.212.159]) by smtp.gmail.com with ESMTPSA id w195sm2132842qkb.127.2021.06.24.03.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 03:26:38 -0700 (PDT) From: SeongJae Park X-Google-Original-From: SeongJae Park To: Shakeel Butt Cc: SeongJae Park , 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 Subject: Re: [PATCH v31 03/13] mm/damon: Adaptively adjust regions Date: Thu, 24 Jun 2021 10:26:20 +0000 Message-Id: <20210624102623.24563-2-sjpark@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210624102623.24563-1-sjpark@amazon.de> References: <20210624102623.24563-1-sjpark@amazon.de> In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park On Tue, 22 Jun 2021 07:59:35 -0700 Shakeel Butt wrote: > 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. Ok, I will make the change in next spin. > > Other than that, it looks good to me. Thanks, SeongJae Park