From patchwork Tue Oct 22 08:39:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Yejian X-Patchwork-Id: 13845300 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 BBCD9D1CDB7 for ; Tue, 22 Oct 2024 08:39:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8506B0085; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D37F76B0088; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB1BF6B0089; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 819556B0088 for ; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 73DDBC1074 for ; Tue, 22 Oct 2024 08:39:18 +0000 (UTC) X-FDA: 82700589090.12.ED6876A Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf06.hostedemail.com (Postfix) with ESMTP id 0703718000C for ; Tue, 22 Oct 2024 08:39:20 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf06.hostedemail.com: domain of zhengyejian@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=zhengyejian@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729586224; 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; bh=3PFWLXjIvYpm7jZ0TwEGIO3TJV667IC8YB5CXMph6Ew=; b=YRKFav5NmBbo1dit1Q6oRtGhMhSmXUewJUwlcP0/7vL9XW6k1dNDldEULAAokxJGNSseb0 FLQ2xX9iJMoUfK2QMLhJuc+pOfVm7tXeqBOIC0YHhWfiTyRhfSTqarYZ+Fri1EXXmvrNVT y/fBMlZu6g0JQ1CFLmC7lGRdpnK8Mys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729586224; a=rsa-sha256; cv=none; b=7sTxi3W6Zqo2PMWHTsJYXF802UoHOc38H7WZu5S1/TslYy6TP3ymz8rIqblDa8meu8OV8P kjrL0O25HfUb9dOU9YTNFH9QWEjZR3EF9wkSmNPZV7WoUa9VN06sbJetxq1T6HYlKdQi6B LGtQimYNQc9Xaj945VK29l7A67KD0rY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf06.hostedemail.com: domain of zhengyejian@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=zhengyejian@huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XXlvv56vBz4f3jsV for ; Tue, 22 Oct 2024 16:39:07 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 1D6201A0194 for ; Tue, 22 Oct 2024 16:39:25 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP3 (Coremail) with SMTP id _Ch0CgCnRoO3ZBdndQiQEg--.6910S2; Tue, 22 Oct 2024 16:39:24 +0800 (CST) From: Zheng Yejian To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, foersleo@amazon.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, shakeel.butt@linux.dev, sieberf@amazon.com, yeweihua4@huawei.com, zhengyejian@huaweicloud.com Subject: [PATCH v2 0/2] mm/damon/vaddr: Fix issue in damon_va_evenly_split_region() Date: Tue, 22 Oct 2024 16:39:25 +0800 Message-Id: <20241022083927.3592237-1-zhengyejian@huaweicloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021163316.12443-1-sj@kernel.org> References: <20241021163316.12443-1-sj@kernel.org> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnRoO3ZBdndQiQEg--.6910S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZryUKr4kKF4rWF4fCF45ZFb_yoW8Jw43p3 WfWr45GF4vkryav3Z3u3WYvwn0yrW8Jr1DGry3JF1Yka4vga4YyFy7tr90yFyUCFWfJ34S 93W8XrW3CF93uaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x 0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2 zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF 4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWU CwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCT nIWIevJa73UjIFyTuYvjfUonmRUUUUU X-CM-SenderInfo: x2kh0w51hmxt3q6k3tpzhluzxrxghudrp/ X-Rspamd-Queue-Id: 0703718000C X-Stat-Signature: rk5y6zfjozr93zbi66hs7q3xakwcz47b X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729586360-846362 X-HE-Meta: U2FsdGVkX18hYjySr1CA6EtZ8VPJ2Cg0J9gMwTgZk+vIMeXc38d75f/qC3yfxOWWe/3+WUqg42bo9MsNJ93voUNrT39F5IQx9iiCPXR3Xy4wE67Jy8QEXVHs6KDwrAxt8L9h1C3JR0IHBB/n8IH2b0k8pTYo2zirRM+TlDVc41mLbMcLgmXB623mGVvT6zJMZVZQpF2b6UI/yWfi3GzrwSiWROlUI9WxnVEvg62jBoROfAbsBxuqYCCLHQC13o9IsadY4FAt9jQU9Afd4HD/7K597liUh9ShaIVgirTp1l/YCExdiQIXL6918TllXjayIYh+vhZ2WCIxzZTde22cPknxHZxjtrHec2gK7GU6T5CFYn4zzzkfQkGW+P9xt9UJIGyXug0pE499m0vpXEgREQwUj6xWtcDGS7K9beh1adpjplA7rOnUqJJUmTSECNzDiq6uhMHTiMJ3Eo0+rmXV5kPfLHlaqMEezyHPfJJ4/EaZ3MYfefeWWDfqkZ3Hl4Aap+N+skM56oHJCQvh+aeVzTdMBe+AhwIyiFCs9H4QCsGzdxWp+Syxf2GT8kjv/sDsbU3cMz8q6ViJo6yKhaK0Zt1YXlqMRtWf1UPZ3ii5BjipUJ/r6woe8ar1NDTdQ1lLGaUWIMeaHm1lEwIkOnIjN6CJoRGXrHO4ngFHPVjF8LyWjV1Nfp1MhWzzIJlufIs4yI3JEDftlTd4iS09YX14Z+igiWPeuf6tY5CJytScpjiJjaMkU9Ufl6QxS27lLYLPxxppndxozqRp3JTnklDBRLKDCZ2GHFUZ34OA+DOzxWtaXmdGG/PFZNgA/3pb0zOSbr26iZHKW/RQroGBg0qwDmbBAFTKR5Cx+h6aV/jAf28wc3L8cp4CaRHJgUuLjbQhYuIIDT59LAV8jm5blXHMZAOjFEqi7BBc2jJvA7JG/uLIL2PkLkPTT+Wo0hHMBqICwJ+V7yvdV5JaD6f5T9x rHBlglJA 5u1WvSlTJfK0FrTFV34i0KKjwaW+CQ9ozVTZrXPZv+EMoY1HNr5BwJnW+nOQY2YYT1+xcyxzv+L5v31rb1d2SXKgoxtx1gA/Y6N8Z2reDY3KJdbLTURa/JX4Z/NZkygfiIH7PFroBV0LagpvlnEV3d5Y5Rg== 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: According to the logic of damon_va_evenly_split_region(), currently following split case would not meet the expectation: Suppose DAMON_MIN_REGION=0x1000, Case: Split [0x0, 0x3000) into 2 pieces, then the result would be acutually 3 regions: [0x0, 0x1000), [0x1000, 0x2000), [0x2000, 0x3000) but NOT the expected 2 regions: [0x0, 0x1000), [0x1000, 0x3000) !!! The root cause is that when calculating size of each split piece in damon_va_evenly_split_region(): `sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION);` both the dividing and the ALIGN_DOWN may cause loss of precision, then each time split one piece of size 'sz_piece' from origin 'start' to 'end' would cause more pieces are split out than expected!!! To fix it, count for each piece split and make sure no more than 'nr_pieces'. In addition, add above case into damon_test_split_evenly(). And add 'nr_piece == 1' check in damon_va_evenly_split_region() for better code readability and add a corresponding kunit testcase. Zheng Yejian (2): mm/damon/vaddr: Fix issue in damon_va_evenly_split_region() mm/damon/vaddr: Check 'nr_piece == 1' case in damon_va_evenly_split_region() mm/damon/tests/vaddr-kunit.h | 2 ++ mm/damon/vaddr.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-)