From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48938C433E1 for ; Tue, 16 Jun 2020 07:42:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2375D20663 for ; Tue, 16 Jun 2020 07:42:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="N4lBkcJH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbgFPHmZ (ORCPT ); Tue, 16 Jun 2020 03:42:25 -0400 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:4292 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbgFPHmV (ORCPT ); Tue, 16 Jun 2020 03:42:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1592293340; x=1623829340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=BbAExRFRfMg+90dvctRpnkPL9WeMbxW5TouiucAxE2c=; b=N4lBkcJHYL4Fkz3iamLC2iIFDVlLZgiYEeIzXp1ZKJNHhkGxT9OsRG7p gow70ph3sqioOAUOOVmmR1YP5S8cqCzlQidY3Ciq/dvDbbWLQBsTqmhio J8QcpK6Q9iqWjGrjgKS/T0vTl9t6x1AFuRO9GMBGzKh/+PrWgU+leAFHo 0=; IronPort-SDR: r2JyEaD1QuXScvjNdy4c2bI77Be29uPWBV9SHiMWSVtM/TDe/tfZK/jcEf07CedA9KI7vJFTHq tzxVH/C7i+dg== X-IronPort-AV: E=Sophos;i="5.73,518,1583193600"; d="scan'208";a="36514975" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 16 Jun 2020 07:42:15 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com (Postfix) with ESMTPS id 06CB4A18EB; Tue, 16 Jun 2020 07:42:03 +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, 16 Jun 2020 07:42:03 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.248) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Jun 2020 07:41:35 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v12 5/8] mm/damon/schemes: Implement statistics feature Date: Tue, 16 Jun 2020 09:38:25 +0200 Message-ID: <20200616073828.16509-6-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616073828.16509-1-sjpark@amazon.com> References: <20200616073828.16509-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.248] X-ClientProxiedBy: EX13D22UWC004.ant.amazon.com (10.43.162.198) 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 928cda0ed509..076852bab7aa 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -73,6 +73,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 { @@ -81,6 +82,7 @@ enum damos_action { DAMOS_PAGEOUT, DAMOS_HUGEPAGE, DAMOS_NOHUGEPAGE, + DAMOS_STAT, /* Do nothing but only record the stat */ DAMOS_ACTION_LEN, }; @@ -93,6 +95,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 @@ -107,6 +111,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 f3805e2a7534..5862b60cdea9 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -211,6 +211,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; @@ -918,6 +920,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; @@ -945,8 +949,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; } } @@ -1499,11 +1506,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