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: 166859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1750485vqn; Sun, 19 Nov 2023 09:16:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGU5Bcjz0O+rxof2gXBxLySDEp0B1hOuX9Gdubjrpi+LImu2EtwqXrJUnouvOY+9nTxKGDD X-Received: by 2002:a17:903:2352:b0:1ce:8ed:2378 with SMTP id c18-20020a170903235200b001ce08ed2378mr4478573plh.1.1700414160380; Sun, 19 Nov 2023 09:16:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700414160; cv=none; d=google.com; s=arc-20160816; b=vzCCO51ZYlR+VE0yDm53q5yb3wRwI/0ykn2Uv9E6am+aDbQiHwjzxkflTP59eFrl5f ygAhsS28FAdema+KFeCdQ+q97juowB/G03PPjxymzZzAeLmuWH6EWBT2WUfoW0CXS7g9 dYAOmhWEmAV6gJyRpj0BjLkvDSKT4yFqkYOlaJtWbzcFGpY6bEiIrktdVSbjRQYhgXX7 AfIRww177b3xQQFB5lO4s0ybzea53oaL7Hmo0vCZ76i6fWUvc/TSSVULUUYtA0doXp7C Xn8HgbHZBv8cVBxr0TSaKwm9gE3Ydq89j881Ya9pEcgLCDxY5Y6l7PmYQAPzRFVjWHk8 lvmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=k3qlEKrpUKlu9+VRA9cFAtNOmR60PMxaKlmk8cYBIEQ=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=0dO31zI4K226bZ4G+ALjitp2kWqk8F3YTlAdDX2Abh2cLyWBmdw/UnZIjGmA8yvt9w ABh/G2aRb7q0rkW13HcfjLFQ2H0upzMJaofy1TNnvvIKzyGWKyC2Qwu17hWz7UZaBAoD gDVJasXYKIZXAWt0BRZoO7x8xawLEq47nJRHWnDDmKDLDF5wIVI3N2IZ4MYTNrZkcZBH XzMK0G9ZLvEtN4k8KSZ8Rz8a1/3rcCzKk3RF0O5tZ4SowPUhF9XO0FzVglZ8ahrxC2lm uyZgDo9ezNs53jYaNTMP2rndX9ggyUvchE7K9JGRKBr/kwyi21eCNyLwW2Fo0jWsX1RK o6Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkfEizFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d7-20020a170902cec700b001ce67644c86si4442145plg.567.2023.11.19.09.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 09:16:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkfEizFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6A63C8083B08; Sun, 19 Nov 2023 09:15:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbjKSRPh (ORCPT + 99 others); Sun, 19 Nov 2023 12:15:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbjKSRPf (ORCPT ); Sun, 19 Nov 2023 12:15:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB4FBF2 for ; Sun, 19 Nov 2023 09:15:31 -0800 (PST) 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 09:15:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783013478613416270 X-GMAIL-MSGID: 1783013478613416270 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: 166858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1750478vqn; Sun, 19 Nov 2023 09:15:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI/dwlLT3X0Y5PUBaQX30h5Oi6MmYKDDEdJZ/cI+SXVEgS+Fpooc8mQqlTkZgNzkUY/Y+Z X-Received: by 2002:a05:6a20:2203:b0:180:ebec:da1e with SMTP id u3-20020a056a20220300b00180ebecda1emr2359349pzb.21.1700414159494; Sun, 19 Nov 2023 09:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700414159; cv=none; d=google.com; s=arc-20160816; b=HDGTqNXjcPTAUZAu1vWskY6t5gMFiTk1wX+QpTc+iS5ZmgVIQPcRZGpSSvSe5zGEco TueWb8/EES/m7f5IhaQx1rx9Fp1fiVOLczmIqCL2pf27ejyGZTY6ehhVSY3NEGGKMYAG UXCoLeNg3IHKNYk1P5zs6iAqT/IQxtcJbmswfDHtQdIpBCoeYkBZx17Dzq4gSeOPaB9g uQVRn15RFYw2pRni3zOaNjbxO6QpXHz7zCyQU33an7GGifcTKp1tyNRek0J8mm55Aqai /h7R3e7r68/aagXDHssd88wTJKX4lwqI3vpMJH0oIiN26lsktsr65UJqDg3vmBNwCl5w HCqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dz3JwZ6TItvV+BBLFmzbVlDOXHt5HH6pjq5477TbDUY=; fh=yShER6sAU1t2EUnKfsE5D0X+v9il5RZ0sMRx2SrxMeQ=; b=cDJKGoAog7ofszcDiF9GexeH1QBaUtgD965LHK0cyefEaSHc/PB37MuzXV/VmKL0EB iIPfVFySmNxj8ihGMHonMEIaVDGofAf1bZKgsczuQCQO4T8JYrTp0Z0kxwc5JKzkSsm3 O9ube0vXtZaAKbHD0fa26ALZF2/f12671e/ugtBL+p5Z+u4phloC+kwx0gkBiWCVd518 PG3a4rhaNBwYqOxtt+O7CEAcCXS5xWqwbDUco4vUGpsGZsF2hMhflFsKhR/pcL9BTM3r AxM3AMeDV9fI5gG0MW+Gs8grI1d+v4P1HJlQv16gOA9eXljZDkLQTpd1RWILWNHFadE0 EZsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LjylG+h6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e9-20020a056a0000c900b0069335e0c824si6321400pfj.204.2023.11.19.09.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 09:15:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LjylG+h6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0E6D080615C8; Sun, 19 Nov 2023 09:15:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbjKSRPj (ORCPT + 99 others); Sun, 19 Nov 2023 12:15:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbjKSRPh (ORCPT ); Sun, 19 Nov 2023 12:15:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76F77C0 for ; Sun, 19 Nov 2023 09:15:34 -0800 (PST) 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 09:15:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783013478018450782 X-GMAIL-MSGID: 1783013478018450782 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);