Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp283824ybg; Mon, 8 Jun 2020 23:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5ryBxL15XlrokAD/grA4bYH1brQH19hoAvtq6Ja7PB6ht1Dx0Ri8TVTFE1dPl625VQQQE X-Received: by 2002:a50:d7d1:: with SMTP id m17mr26217082edj.126.1591685946613; Mon, 08 Jun 2020 23:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591685946; cv=none; d=google.com; s=arc-20160816; b=ABYeKIIFR8ogrzzKdcS/+giIoH5x2K44uoFO0rNYB6pt6aTICQSIddegJkPi19Tnnw LuVWbBU78DufwzSyRzjRDj3pvCPE2Di8s2WJRzVTPXoekFVrX/wKB8m6R/6LUqeffT5e ELMuAzIvdFzJQ/4WyluUfSmUGgibGifkDf2W8l5KMEpr69+VMAhh8wALvzHcb4/ZvITC /MZscQ30ZGOjPrGtD0MLhtCu9x9Clr8CCsVU9wjSCUy/A0AV7YSc84jpe31A+S0kYUcM 5ewxAhUZwd/bLCHqURERYZ5R0YvI5FWvdJ11ZoGr0D5HjN1kwwCt4lZ9U+FAfpYZXV6f oaQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=Y3TApI5hCDymjWLvwYp9oxbri4e06E85N4q9qWFSw0w=; b=JARxcWaWsx+REpbiSJwdhR/Pgz2LjNGr11b2HascTQ1b75N2qIMNEEFZQTLtnvYMcl iFJg8HcilwEmuuaFs4+M+hCliLL984UOXyFE2chBxWGJO4cExpctnwC6AqfQsWvBrg+r 6mE+GoYmzVoy7Qp99OlfZTCsi8PKK15ErGlALf+3DeFWd2v3c3zxSVUUBHVX7kfHfoIB H0je5FoBYb6Fn7zpIB5LxXCL36NonKDfvQAPpaCsKwSdQgMomKc+xe3aXM+NHe69kRXk RB43lJDBiT70MaH1//k/VOTor24bctdRyahsSZHOt6JgwSnmyG2nXadSWwJvU8Z+rrD5 IdXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=nsuVsvsx; 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 b2si11008787edy.582.2020.06.08.23.58.43; Mon, 08 Jun 2020 23:59:06 -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=nsuVsvsx; 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 S1728047AbgFIG4N (ORCPT + 99 others); Tue, 9 Jun 2020 02:56:13 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:18749 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbgFIG4M (ORCPT ); Tue, 9 Jun 2020 02:56:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1591685772; x=1623221772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Y3TApI5hCDymjWLvwYp9oxbri4e06E85N4q9qWFSw0w=; b=nsuVsvsxHwJW9B18SYx17h8btl8f8n5ObwKU4sZR4dG0D59V71KpSY0d WO4CQpwKruY+B15BrlLQ9Y2kjfIIjd5la8gxQ1VEXFmTmH+mLiSxcQxmf pguc7qlZ+k8d/NIydlABjCVP1gxWo/AS1ysm7FnrTzbyQYmbra69Ui+gN o=; IronPort-SDR: adQ+B6Lg1TtoHu1LX+SgrJcSef0Do9ODVHGybEjAQ7UnUguhkmQANcGv5+plQe0N30UCFvsa5X o7lmHU3XAcXQ== X-IronPort-AV: E=Sophos;i="5.73,490,1583193600"; d="scan'208";a="50834101" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 09 Jun 2020 06:56:07 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-a70de69e.us-east-1.amazon.com (Postfix) with ESMTPS id CF93AA21F2; Tue, 9 Jun 2020 06:55:55 +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; Tue, 9 Jun 2020 06:55:55 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.53) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 9 Jun 2020 06:55:38 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v11 5/8] mm/damon/schemes: Implement statistics feature Date: Tue, 9 Jun 2020 08:53:17 +0200 Message-ID: <20200609065320.12941-6-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609065320.12941-1-sjpark@amazon.com> References: <20200609065320.12941-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.53] X-ClientProxiedBy: EX13D31UWA004.ant.amazon.com (10.43.160.217) 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 From: SeongJae Park To tune the DAMON-based operation schemes, knowing how many and how large regions are affected by each of the schemes will be helful. Those stats could be used for not only the tuning, but also monitoring of the working set size and the number of regions, if the scheme does not change the program behavior too much. For the reason, this commit implements the statistics for the schemes. The total number and size of the regions that each scheme is applied are exported to users via '->stat_count' and '->stat_sz' of 'struct damos'. Admins can also check the number by reading 'schemes' debugfs file. The last two integers now represents the stats. To allow collecting the stats without changing the program behavior, this commit also adds new scheme action, 'DAMOS_STAT'. Note that 'DAMOS_STAT' is not only making no memory operation actions, but also does not reset the age of regions. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++++ mm/damon.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 842a01e80c6e..e77256cf30dd 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -64,6 +64,7 @@ struct damon_task { * @DAMOS_PAGEOUT: Call ``madvise()`` for the region with MADV_PAGEOUT. * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE. * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE. + * @DAMOS_STAT: Do nothing but count the stat. * @DAMOS_ACTION_LEN: Number of supported actions. */ enum damos_action { @@ -72,6 +73,7 @@ enum damos_action { DAMOS_PAGEOUT, DAMOS_HUGEPAGE, DAMOS_NOHUGEPAGE, + DAMOS_STAT, /* Do nothing but only record the stat */ DAMOS_ACTION_LEN, }; @@ -84,6 +86,8 @@ enum damos_action { * @min_age_region: Minimum age of target regions. * @max_age_region: Maximum age of target regions. * @action: &damo_action to be applied to the target regions. + * @stat_count: Total number of regions that this scheme is applied. + * @stat_sz: Total size of regions that this scheme is applied. * @list: List head for siblings. * * For each aggregation interval, DAMON applies @action to monitoring target @@ -98,6 +102,8 @@ struct damos { unsigned int min_age_region; unsigned int max_age_region; enum damos_action action; + unsigned long stat_count; + unsigned long stat_sz; struct list_head list; }; diff --git a/mm/damon.c b/mm/damon.c index 0d12a74aba58..98fd32ace6f7 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -206,6 +206,8 @@ static struct damos *damon_new_scheme( scheme->min_age_region = min_age_region; scheme->max_age_region = max_age_region; scheme->action = action; + scheme->stat_count = 0; + scheme->stat_sz = 0; INIT_LIST_HEAD(&scheme->list); return scheme; @@ -882,6 +884,8 @@ static int damos_do_action(struct damon_task *task, struct damon_region *r, case DAMOS_NOHUGEPAGE: madv_action = MADV_NOHUGEPAGE; break; + case DAMOS_STAT: + return 0; default: pr_warn("Wrong action %d\n", action); return -EINVAL; @@ -909,8 +913,11 @@ static void damon_do_apply_schemes(struct damon_ctx *c, struct damon_task *t, (s->max_age_region && s->max_age_region < r->age)) continue; + s->stat_count++; + s->stat_sz += sz; damos_do_action(t, r, s->action); - r->age = 0; + if (s->action != DAMOS_STAT) + r->age = 0; } } @@ -1418,11 +1425,11 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len) damon_for_each_scheme(s, c) { rc = snprintf(&buf[written], len - written, - "%u %u %u %u %u %u %d\n", + "%u %u %u %u %u %u %d %lu %lu\n", s->min_sz_region, s->max_sz_region, s->min_nr_accesses, s->max_nr_accesses, s->min_age_region, s->max_age_region, - s->action); + s->action, s->stat_count, s->stat_sz); if (!rc) return -ENOMEM; -- 2.17.1