From patchwork Tue Oct 22 08:39:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Yejian X-Patchwork-Id: 13845299 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 7B4E4D1CDBD for ; Tue, 22 Oct 2024 08:39:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFB956B0083; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A36C36B008A; 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 71DE96B0085; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4BB4C6B0082 for ; Tue, 22 Oct 2024 04:39:36 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0F0480FC3 for ; Tue, 22 Oct 2024 08:39:21 +0000 (UTC) X-FDA: 82700588754.07.CA2BF92 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 1704918000C for ; Tue, 22 Oct 2024 08:39:29 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of zhengyejian@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=zhengyejian@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729586263; a=rsa-sha256; cv=none; b=A0u1VgzSi+Z1w6LM2BVQPkv8bv9Dpw46iRkZY9KMKoCDqgqWcW4vWaxPaqUWaOExyxUfqd SEeHdQQsYJGnNILucoHOUyW29cc89gpMlPPJ342rYFNHcR+R3d10p+i7Vf1bTiJnO+4+pW P+cxoxgE+HH/qihzL0kQiw4QrBEKn4E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of zhengyejian@huaweicloud.com designates 45.249.212.51 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=1729586263; 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=vuzkLtZS6MTmzjC+KqTLGnl4aLwvf/puQQc7VEGvLRE=; b=gnIenzz0Tcuf7PVgrn/powfbpzXhkUIDlen0l0u15KgO5ug40OpalPrw1HhhTXZT6Bo+L4 PDu6355sgMTcV44LyjdYt7bnts4+ypB7kPduKrfC/mu6J1MQ1oK8oiSVBTSXzGIs9N1aeA A42zbnCjvKJqr8xxydw6g88rjz7odME= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XXlw22sX5z4f3k6M for ; Tue, 22 Oct 2024 16:39:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id AA79B1A07BA for ; Tue, 22 Oct 2024 16:39:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP3 (Coremail) with SMTP id _Ch0CgCnRoO3ZBdndQiQEg--.6910S4; Tue, 22 Oct 2024 16:39:26 +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 2/2] mm/damon/vaddr: Add 'nr_piece == 1' check in damon_va_evenly_split_region() Date: Tue, 22 Oct 2024 16:39:27 +0800 Message-Id: <20241022083927.3592237-3-zhengyejian@huaweicloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241022083927.3592237-1-zhengyejian@huaweicloud.com> References: <20241021163316.12443-1-sj@kernel.org> <20241022083927.3592237-1-zhengyejian@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnRoO3ZBdndQiQEg--.6910S4 X-Coremail-Antispam: 1UD129KBjvJXoW7tF1rGr4UCF4xWr18ZrWkZwb_yoW8XFWfp3 s3Ww4UKrykKFZ29w15XFn0van2yrWjgF1UGFyxJFn09r1vgas0kF15trW3Jr1rAFWfZ3yf ua1xZrWfWFZrCFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVj vjDU0xZFpf9x0JUczV8UUUUU= X-CM-SenderInfo: x2kh0w51hmxt3q6k3tpzhluzxrxghudrp/ X-Rspamd-Queue-Id: 1704918000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: sz3hdoktwdzfnrdcqutn5fodgikmxiow X-HE-Tag: 1729586369-117346 X-HE-Meta: U2FsdGVkX18FYg7UFym+UIbZ0Oa4OaLLGUTbZvwAp9tPh/85HK0sN4Tar9TCdPSQhKpYV/fRJQkzp8fRc6Abe5eG7WMVAJeEDKHs7w8AmwxVyyt46mgCsFgRvuStedAaVGRkF1LMTRR6sxYdRz0mUVodJS1wcktGLD8vmf0c5vhHwhQpfRXyQ3mF+NKBQ8nHsJS0W1pZKdOCTM6yuToCpahGk9eSqFCVChPA46zLcBWuwhZKDWENV2BXgc1YMDU0ztmvu5aEw7LD3/vpebOD+n9m0RIK/76bPFdEeNST6rzU3FYg4PDdpYGeDNvgCN/LFjTHeVSpfyJETqxgUKpSYn15g9rHxb7QTZksg8p24ttmPUjz6jndvjERNFbMySyOg7S/+DNbk+i5VDtakMtFEsGPKD32bYsI2uvzqx/M0rupWy4wWARQwiLrgrE9cq+nWKVRhuCVUg+fvffjxYZzzgH3XfHCP11vSz76XDdCsRHWzyewKDpBcdWO6+KR8RhXdd44ejNpu1jFOa0JMVZ7v+6OlvMRtm7DIXVz7rq26x8t4oUNuJdf2oycuWRPECQa8yg1mg3r9hEAtUKcVux0caSex9ySx9S2w1/oxJ4r3U0xzj9ORIvikZRXw53XZ9Wz4R8pnoD4tbEW6qVVQ/XRhtJ/IMJ8rBZp0ZwO+4CsY5iaTODAErPmsmRBa4Y4oTQh34UKGkpPF85BNHQM+9QW2kkDdKonEHDQlArJi2sf8Zg/JQHXwzYltVS0cRd0go0aIQVDNXn2Qjb1MJhqrHzWT77rUsLPCRRtIUk8/4Nh0oP+5tQ2LdV8reCo/sZAZsiNoL10TpCSIL2qwCoOPOOyCS+13Lje0QK8KXhEucGTpd9xd5kXcLxp2P5A/lIdrEh49mOMeaqbIBS1QUfkd2GgPxVBE2AzieZgZ68yVZrzwoXPSsJ+7tj+3+RzK+P9ThCT2o81OyyL0VrSMGuS64r kF28ck5l r8bYeBxSScUGEwEGmwTmUTZbLSp3zrihb9QZcEFqE00/97+sfL/1BzRkeiMTJNhCX7J71ZiVeUEFqiTp4ktTdJUORPvCUbF5VpOeYAWnxXtGqA7dkfzSR5YbONFjJ5RH+FhKv1/Exo8iysWO0oY3OcNdOrWtTvxFVZxGoPMTUkr32/sJRBx5xv8HHQ5gYmrh2iJkBFo384BVixxs= 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: As discussed in [1], damon_va_evenly_split_region() is called to size-evenly split a region into 'nr_pieces' small regions, when nr_pieces == 1, no actual split is required. Check that case for better code readability and add a simple kunit testcase. [1] https://lore.kernel.org/all/20241021163316.12443-1-sj@kernel.org/ Signed-off-by: Zheng Yejian Reviewed-by: SeongJae Park --- mm/damon/tests/vaddr-kunit.h | 1 + mm/damon/vaddr.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index a149e354bb26..b9a03e4e29e5 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -300,6 +300,7 @@ static void damon_test_split_evenly(struct kunit *test) damon_test_split_evenly_fail(test, 0, 100, 0); damon_test_split_evenly_succ(test, 0, 100, 10); damon_test_split_evenly_succ(test, 5, 59, 5); + damon_test_split_evenly_succ(test, 4, 6, 1); damon_test_split_evenly_succ(test, 0, 3, 2); damon_test_split_evenly_fail(test, 5, 6, 2); } diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index dba3b2f4d758..25db0a582c27 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -72,6 +72,9 @@ static int damon_va_evenly_split_region(struct damon_target *t, if (!r || !nr_pieces) return -EINVAL; + if (nr_pieces == 1) + return 0; + orig_end = r->ar.end; sz_orig = damon_sz_region(r); sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION);