From patchwork Tue Jun 8 11:52:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12306581 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 C671FC4743F for ; Tue, 8 Jun 2021 11:53:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6457F61351 for ; Tue, 8 Jun 2021 11:53:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6457F61351 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 09B576B0071; Tue, 8 Jun 2021 07:53:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 074646B0072; Tue, 8 Jun 2021 07:53:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2E646B0073; Tue, 8 Jun 2021 07:53:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id B3B596B0071 for ; Tue, 8 Jun 2021 07:53:19 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 43AD498B2 for ; Tue, 8 Jun 2021 11:53:19 +0000 (UTC) X-FDA: 78230396118.16.FC986EA Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf16.hostedemail.com (Postfix) with ESMTP id 33C05801936A for ; Tue, 8 Jun 2021 11:53:16 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id c138so6939408qkg.5 for ; Tue, 08 Jun 2021 04:53:18 -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; bh=1v3jF6xE2cadC0A5okidQotQQ/sADUe8F+zXLAj+QLM=; b=mDHQ2YMh1wx+gC9L9QO0GSL2MxjH0qEDBREBkT9xZfRPHTih2jw4S6xa1bbGfaOZrs CwcL3xX1gTSfuPCDIYBAJ66P1bZam83EPUrmm6/K0avsxZZU+kHgpf/6wf0J9FLkqWEP htvwgvuyJrf4saioMmd1RvXq0nVd1ZLxa/yZ+FKnH4GYUj7jJxm7KOZnW9MM+rZziU/r tzzFszZw0W1TZaqN8Pnlv7Ouo4k/mFznd8bXE86+0y3+kO3eGD3P4467F8iR97Md891y UYYGgQdVJbo0MKn67nGnjtbW0Kf7dwPRIkrbRqtZWF7TkacXxoZGHMED7KZLxPZ5v8B2 XZpw== 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; bh=1v3jF6xE2cadC0A5okidQotQQ/sADUe8F+zXLAj+QLM=; b=AbRPIn//fKgvMZ1GFY2IKEckYDWf0thJhPrU52f4C/FLWqEC07K1sM/JbFDhliav9r /KShfywYl93ZmUigXz3xMwESVdBKhxPd7619ezHgEQd+z+3yoGH8CxBypT/AA34cV042 bMeQvL5qPrPKAqWadqdWUuFbUAx6tvlUcNgq7hNFQkWHJ3gfpnrjFLCUaOGpl3obko1u VlMchLWOuK5guTop6f3q60Q145h98W40si47Ou5pIE09MghLlisQ1/9Obl0O22pMxB3V izTMDg2qkoW4cfbwcZqfzgfuB6/y7Ag3M1BzOsc+PUA0QgkYcOrfbzCzj4TCWiKTBvZu dv0g== X-Gm-Message-State: AOAM530XcadmEOTjFolXJ4rvrC6qiztWaxWDNE2+LeJsxb793HJlc1+7 m5eVgv+xEO41jZZ75gmfm/o= X-Google-Smtp-Source: ABdhPJwUvb+KltsTXZs159GKaS7Z/4amSHZTojI8glTyC1QaSMs/x/Ym94/UGCYQevE7izxWu9Lo+g== X-Received: by 2002:a37:73c7:: with SMTP id o190mr6613475qkc.314.1623153198298; Tue, 08 Jun 2021 04:53:18 -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 h4sm2133927qth.66.2021.06.08.04.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:53:17 -0700 (PDT) From: SeongJae Park To: akpm@linux-foundation.org Cc: SeongJae Park , Jonathan.Cameron@Huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendanhiggins@google.com, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, fan.du@intel.com, foersleo@amazon.de, greg@kroah.com, gthelen@google.com, guoju.fgj@alibaba-inc.com, jgowans@amazon.com, mgorman@suse.de, minchan@kernel.org, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, riel@surriel.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, shakeelb@google.com, shuah@kernel.org, sj38.park@gmail.com, snu@zelle79.org, vbabka@suse.cz, vdavydov.dev@gmail.com, zgf574564920@gmail.com, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 03/14] damon/core/schemes: Skip already charged targets and regions Date: Tue, 8 Jun 2021 11:52:43 +0000 Message-Id: <20210608115254.11930-4-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210608115254.11930-1-sj38.park@gmail.com> References: <20210608115254.11930-1-sj38.park@gmail.com> Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mDHQ2YMh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of sj38park@gmail.com designates 209.85.222.176 as permitted sender) smtp.mailfrom=sj38park@gmail.com X-Stat-Signature: kxmc8mc4j4mank34kyu3zxd6eod8y1sr X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 33C05801936A X-HE-Tag: 1623153196-215070 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: SeongJae Park If DAMOS stopped applying action to memory regions due to the speed limit, it does nothing until next charge window starts. Then, it starts the work from the beginning of the address space. If there is a huge memory region at the beginning of the address space and it fulfills the scheme target data access pattern, the action will applied to only the region. This commit mitigates the case by skipping memory regions that charged in previous charge window at the beginning of current charge window. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++++ mm/damon/core.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 35068b0ece6f..0df81dd2d560 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -104,6 +104,8 @@ struct damos_speed_limit { /* private: for limit accounting */ unsigned long charged_sz; unsigned long charged_from; + struct damon_target *charge_target_from; + unsigned long charge_addr_from; }; /** @@ -331,6 +333,9 @@ struct damon_ctx { #define damon_prev_region(r) \ (container_of(r->list.prev, struct damon_region, list)) +#define damon_last_region(t) \ + (list_last_entry(&t->regions_list, struct damon_region, list)) + #define damon_for_each_region(r, t) \ list_for_each_entry(r, &t->regions_list, list) diff --git a/mm/damon/core.c b/mm/damon/core.c index 4ac4a9aa2514..5864b63c18f9 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -107,6 +107,8 @@ struct damos *damon_new_scheme( scheme->limit.ms = limit->ms; scheme->limit.charged_sz = 0; scheme->limit.charged_from = 0; + scheme->limit.charge_target_from = NULL; + scheme->limit.charge_addr_from = 0; return scheme; } @@ -558,6 +560,21 @@ static void damon_do_apply_schemes(struct damon_ctx *c, if (limit->sz && limit->charged_sz >= limit->sz) continue; + if (limit->charge_target_from) { + if (t != limit->charge_target_from) + continue; + if (r == damon_last_region(t)) { + limit->charge_target_from = NULL; + limit->charge_addr_from = 0; + continue; + } + if (limit->charge_addr_from && + r->ar.start < limit->charge_addr_from) + continue; + limit->charge_target_from = NULL; + limit->charge_addr_from = 0; + } + sz = r->ar.end - r->ar.start; /* Check the target regions condition */ if (sz < s->min_sz_region || s->max_sz_region < sz) @@ -576,6 +593,10 @@ static void damon_do_apply_schemes(struct damon_ctx *c, } c->primitive.apply_scheme(c, t, r, s); limit->charged_sz += sz; + if (limit->sz && limit->charged_sz >= limit->sz) { + limit->charge_target_from = t; + limit->charge_addr_from = r->ar.end + 1; + } } if (s->action != DAMOS_STAT) r->age = 0;