From patchwork Sun Nov 19 17:15:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13460633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44664C54FB9 for ; Sun, 19 Nov 2023 17:15:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAD906B00D0; Sun, 19 Nov 2023 12:15:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5D606B012D; Sun, 19 Nov 2023 12:15:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4C466B0296; Sun, 19 Nov 2023 12:15:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A5C406B00D0 for ; Sun, 19 Nov 2023 12:15:39 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 71376C04A2 for ; Sun, 19 Nov 2023 17:15:39 +0000 (UTC) X-FDA: 81475355598.10.5A82590 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 73D6A18000E for ; Sun, 19 Nov 2023 17:15:37 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XkfEizFw; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700414137; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=k3qlEKrpUKlu9+VRA9cFAtNOmR60PMxaKlmk8cYBIEQ=; b=GOUg6P3sW8XQnUNU97VCV1+8LoJc+4i+oE0k5I7CXHRRj9jDC0WluO88F/6NS3sgoW3GdP SxMwKg89zb9NBZTiidtlJbPvFBvwILbv+FFBICQr4eVfD2zCuXhhsPojS8prUeCj8znjnX ZQbPZc9EwWdgjLiRdSHtVXVkAs1xwfw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XkfEizFw; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700414137; a=rsa-sha256; cv=none; b=RCSXT16+5zmP0jBUs7APUPbla9+nPFZSjuz4U26cDFLGfgw9KXSYe3Gmyi4h0mz3JKroyn G3nB5suSR97z2e18weXOdM4kVF+AgdYVvUtrPnX3lv56Rbkdv0KorwLlyxN51Nj4UIpjpC 8BoMLbk60eyINtBFgHH6mHzR6ZrsKP0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E5F04CE0B4F; Sun, 19 Nov 2023 17:15:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06C42C433C8; Sun, 19 Nov 2023 17:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700414131; bh=wGhN7a1c1/p9kfRbyE8itY6KQu9wn5cOAaIJeGVmnnc=; h=From:To:Cc:Subject:Date:From; b=XkfEizFwjv4s2yyAh/IAdR4Ce6ANjOrHPS6OuUGobhk63MS2x68e7h7vDvp478EgL raG02fy8zS6Zg8iVPZ2/GmQeoINkjLj9ER0t634jT0bMnPTVJlIGwZEuAhRG9bRdGp LGqm7giPcvncWcu7qPOQbfn4BAZzlqiiIw4JVn4sJh9HLYuVRRcvUKgpXRLATg3bE3 Z3/oPm1KhExae4SvDwzPARf/8tZLK4fi6QW6K38QS/kF5fUs0mYxWbzOVIuNMUGEM3 Jk6MSHWzyA/E66pjT5jbU5I17CbKbEz4aou4ik1VANNJ4G2tAZhC+9o2fL+3tA+Dlu j0XgF6IfYEe/w== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/damon/core: copy nr_accesses when splitting region Date: Sun, 19 Nov 2023 17:15:28 +0000 Message-Id: <20231119171529.66863-1-sj@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 73D6A18000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sk6rszynkpzrzwoo1hiri1f9qfjnehgw X-HE-Tag: 1700414137-355216 X-HE-Meta: U2FsdGVkX1+78GvLtg7e0/DWXsMTG2RKQW7SKzi3RsCx9zg3NmSmBdYXZMETTQS2t+wPzipCg23ZQ/4UfWnS1UtRcraMzwfSzY15F+eSVKepD1nCPKTKoKkSgAZYXwied159yZ5ctJgdJOFpRhywIYbk6IBZA26/ftakOjCnhj1QhyAC1OU+FY5hT27JoYXraQV0MBI5AvU4uA4DmLR2ohXq5gaK0ci+gyoZTlkSmmLIcPW11zy2S6K/c6VEDzQLJ88aFrbG8fb1SzSWwHtEiX/FK+dm1JgrSQNogYWPFgYUtuppFCpSGj4elTSCJl0SVtZ0TKtARZDl7MFw+8zD4TmGf1w9iBhJ1qNt05f9YUmKHG3/RkaoUGHk+abBC/jWfiWzoGP93eepPjwLDb2bSQVCoaCQITPQkrc59GbAY6SVXrIQtW3rAP0+Qrh9AKlWIwDvd65yDP6bNQrrbrPZAf2Y7Fz+vufmtURXSnXndyX2N9pimNKtHuFm76nm/Jjid/Zp9GrpNeasqocn3X16vAmURjK0ukjr1+GtqA4lN2XLTAP8I77uIr2JUKbImqkbRnADBjG6VoJDAgSxAhDkgJPipQX+uTUYbtIeE2q0DJtBX2W3YCLpvAiFLC4XPCd9KsEpPTXhi0KhcFZ326TQWGho9gkHz8Td1UqGZRknikZca4tX8EY6RxH92bgBqhk2tGZaDtZtjRcHwJKZI91DEYiNa/MYmzgbWLTZe1QSWFZ5523lCBnVjRkZUndEg6eiD8he1YQCRMgzH9iZzuHdSGBemJge7NKnCFE8Fi8H5cicNw8BpER4uVcCFk9PKsvdKWS4NRZ0CmgJ3kJztYGr2d8qsn/UW1IRYIyj6MFnBfXbEVH25uJUMimLGHwGDHoGJvVN8zlS7LpMshU2hRkWXH3JJX+r3Li9juF+vKskV9AQfRqEHN4CXJ+kgPCn0biUXPVgIMHkJip/hISG2tW iTAd5uCd jclWdxDQMVOlw3WzUWWMPzcivMgcsglnW+pSjlxtwy5Agf+9HLl54qG5iJuau7Fwq+uqz6ZHraHUYz1klMqYWcXHZCqiYfS3Mvpmoh5IX6Z2STXW7jXUUEombOjZN+9+GLMah4GKFQJt9KN9NtBvp/wH6SZKpwlRewt/IDFj0U7dEEm4s6B0+f2+L/4XAVlgWTUk7MqjSYT3WMwoSzBpnf2a4uNNZP0qQ0jrYtPiHuIhuIh1NwrY8HAdXSGqCuD5hzw+pslDOtVyJGO0GjA9zV/GAnQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000071, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Regions split function ('damon_split_region_at()') is called at the beginning of an aggregation interval, and when DAMOS applying the actions and charging quota. Because 'nr_accesses' fields of all regions are reset at the beginning of each aggregation interval, and DAMOS was applying the action at the end of each aggregation interval, there was no need to copy the 'nr_accesses' field to the split-out region. However, commit 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") made DAMOS applies action on its own timing interval. Hence, 'nr_accesses' should also copied to split-out regions, but the commit didn't. Fix it by copying it. Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") Signed-off-by: SeongJae Park --- Cc-ing stable@ is not needed, since the commit that introduced the issue has merged in v6.7 merge window. mm/damon/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 6262d55904e7..ce1562783e7e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1225,6 +1225,7 @@ static void damon_split_region_at(struct damon_target *t, new->age = r->age; new->last_nr_accesses = r->last_nr_accesses; new->nr_accesses_bp = r->nr_accesses_bp; + new->nr_accesses = r->nr_accesses; damon_insert_region(new, r, damon_next_region(r), t); } From patchwork Sun Nov 19 17:15:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13460634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B125C072A2 for ; Sun, 19 Nov 2023 17:15:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8ECE6B012D; Sun, 19 Nov 2023 12:15:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C6F86B02D7; Sun, 19 Nov 2023 12:15:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B53C6B02FC; Sun, 19 Nov 2023 12:15:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7A8806B012D for ; Sun, 19 Nov 2023 12:15:40 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 43CC7140109 for ; Sun, 19 Nov 2023 17:15:40 +0000 (UTC) X-FDA: 81475355640.27.200E5C4 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 8E439180020 for ; Sun, 19 Nov 2023 17:15:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LjylG+h6; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700414137; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Dz3JwZ6TItvV+BBLFmzbVlDOXHt5HH6pjq5477TbDUY=; b=hiOOLb0tpTiO+sq58UIrRSGfmUYIf3t187jhmke0CecclgzTjrMWPVCwpg+1GlC1iBY8qc 29yx8TZa9pjoIbWvjKHmaMSlkQd34a6y99M3u85cjva1Ampb76g4ArLWTRuu3TBr3C0t7M i+mp6n80GqgT78Glfwhy0Xxh9WtXBZs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LjylG+h6; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700414137; a=rsa-sha256; cv=none; b=L5GZslxxn0UkTVgBX3QTmGXbCOiD16/KgO+HubsOyGaDLnqBEfGi6+A5DE3rWPhiNgKkc9 kRbIGO9Zknb7Y+h6y36HNY0kuAoWYQAnUjXEXC2pUo2hg4QsrfUS+UFbI+xJ9nC8LQ+ar0 SdKVwqqc+n3QE3cTvYIw7e2SeP9zFHk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 88D5CB80C0A; Sun, 19 Nov 2023 17:15:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BEBFC433C9; Sun, 19 Nov 2023 17:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700414134; bh=YDy2xpgd3SqWOCCdmUAUqNT0vwzIyx0UHeHWEu/iyRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LjylG+h6XhlGYO3Ub30LrxVW6R/8F/y1CvnVEtKokrXHOcCFNtYWT2iWfNIgY/B4K 3cS78u1fskzF0FeyFDELRMq5TGWSesXNl4/W3mWmuwYfRQzZCmNw2+gsO/6c275yI9 lnjz95ZZZsA805p85xdm8l6+tEmOblMYoWkYqyFUbkXTk+r7NIa6hTPjWBd3AZosuH LLNMn21EXI7PiMbDrpx86j1jLp87JOZAMKgeIQcRxzMvYWHk33LKX6OR/pCBN4wNAQ C0S+WwA3iwQFHhmX4KpoAXFc6YTFVbPHaWIr7m+e21K+AGomVHVN1WYJN3Qvl7KYEG MiEfdSmcOp5uw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/damon/core-test: test damon_split_region_at()'s access rate copying Date: Sun, 19 Nov 2023 17:15:29 +0000 Message-Id: <20231119171529.66863-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231119171529.66863-1-sj@kernel.org> References: <20231119171529.66863-1-sj@kernel.org> MIME-Version: 1.0 X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quhy1VimntW6p+5 BHcErGW0 0GNDcgclAjXtlDg/I8PiEVVzhQdXKih4iftOP9UhwpuDSGVfWnuS3kmY1SbrgUHSnsMHPm58vB3T7ZL/SRfWpybeHAnDi+Lf/g/NS1J9goedWCHUGdxjO3J+kS2igTCi9Q6+J0vQbtNo0CpsbJRl1E5D6QoRaB4mBp8m64Hm1GJjL63DcJOa+hDf1DJQFLDCWTIlgWcOAxdDDOHrSYcHlp9chWxzup7dDvkgig8s8BW23jUv/ghf2FWUuR2eVJhAPQMzZmeTSU8/WrfjUcDmPcw/amkRnglCLPIBC 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: List-Subscribe: List-Unsubscribe: damon_split_region_at() should set access rate related fields of the resulting regions same. It may forgotten, and actually there was the mistake before. Test it with the unit test case for the function. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 649adf91ebc5..e6a01ea2ec54 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -122,18 +122,25 @@ static void damon_test_split_at(struct kunit *test) { struct damon_ctx *c = damon_new_ctx(); struct damon_target *t; - struct damon_region *r; + struct damon_region *r, *r_new; t = damon_new_target(); r = damon_new_region(0, 100); + r->nr_accesses_bp = 420000; + r->nr_accesses = 42; + r->last_nr_accesses = 15; damon_add_region(r, t); damon_split_region_at(t, r, 25); KUNIT_EXPECT_EQ(test, r->ar.start, 0ul); KUNIT_EXPECT_EQ(test, r->ar.end, 25ul); - r = damon_next_region(r); - KUNIT_EXPECT_EQ(test, r->ar.start, 25ul); - KUNIT_EXPECT_EQ(test, r->ar.end, 100ul); + r_new = damon_next_region(r); + KUNIT_EXPECT_EQ(test, r_new->ar.start, 25ul); + KUNIT_EXPECT_EQ(test, r_new->ar.end, 100ul); + + KUNIT_EXPECT_EQ(test, r->nr_accesses_bp, r_new->nr_accesses_bp); + KUNIT_EXPECT_EQ(test, r->nr_accesses, r_new->nr_accesses); + KUNIT_EXPECT_EQ(test, r->last_nr_accesses, r_new->last_nr_accesses); damon_free_target(t); damon_destroy_ctx(c);