From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D886D2CE0D for ; Tue, 22 Oct 2024 17:54:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4656B008C; Tue, 22 Oct 2024 13:54:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4DBE6B0092; Tue, 22 Oct 2024 13:54:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EF126B0095; Tue, 22 Oct 2024 13:54:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 704DC6B008C for ; Tue, 22 Oct 2024 13:54:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F256DA0386 for ; Tue, 22 Oct 2024 17:54:27 +0000 (UTC) X-FDA: 82701988782.11.E8C6F7B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 123384001E for ; Tue, 22 Oct 2024 17:54:48 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eBBvj0ZR; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729619544; 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=uSTrgr87M1RZTKt1i5MSTbPBpA7Kg/AUI7P/4+BLw9E=; b=bFBI6h0mLSWmGD5iUbmHPmEddzdFRpWnA4i7UY0iv6lyyQ834ty2xID5kkQGgZYCO1fevH uxl/zEMDtIVgK3Bp6VI+d+EERKPLd8qRYAjeZIjK5T2wY6R8Bw9m8osHEmHYCSNZjYS0el NjRk4PotyEHQ+BZrTeP1NDBvsjHcoUI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729619544; a=rsa-sha256; cv=none; b=RjPQeI+CS3r4tngIotI7obePUEuFvIcpPuceFaWqU6AXBx5ul+O5it29FXrQiczG0iTcJg XXZGNxSw6xXwNMhlr3WUpQbR4O1xay/2IknNGpdtz3U0KyBCIXMd0kpD6QW1PPTwapMebP XIKH2NDPJx8vyy/P4n346DqPx9tCFbI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eBBvj0ZR; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F13925C10BE; Tue, 22 Oct 2024 17:54:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12066C4CEC7; Tue, 22 Oct 2024 17:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729619695; bh=nLbAoVMUYyE5cMe1vr0m+KdrW988ArZe2IMHu2HfY4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBBvj0ZRu88+FxwCUlLk0ymo8kxA7pnODwhMCbSiMn/RXqO/E5LkmhwmWMdXcVhyU hKjWyQjVBRDZo4CzLQ3XhHltQ824RXzAEOIZvEugma2XUardhkk5nOt2Gb27QD+oPd Gh0LPV2pBBeZYyf8DU7ytk5cwzZ9rjR+/FIdYNp7W5n6YnOla8QpvtH8hrd2+mEpAI e0E/LuHz8S1j5eYUOaZHicBk67KI5MjY3e+cQACo901R3pvScl/WwxgCUaM+O5fPWy EDBAFuaJSmr3TSlBGd+MDf/GSEq0jjKaWccGMRg4lwICQl3nGrm2lTMe6Ku6R29MQO Zs9S4DLrlNGLg== From: SeongJae Park To: Zheng Yejian Cc: SeongJae Park , 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, brendanhiggins@google.com, davidgow@google.com, rmoar@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Subject: Re: [PATCH v2 1/2] mm/damon/vaddr: Fix issue in damon_va_evenly_split_region() Date: Tue, 22 Oct 2024 10:54:52 -0700 Message-Id: <20241022175452.42218-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022083927.3592237-2-zhengyejian@huaweicloud.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: u7m9jojaqjxozachkte381txwweug1zx X-Rspamd-Queue-Id: 123384001E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729619688-883005 X-HE-Meta: U2FsdGVkX1+TvkbRmfaaxSjpsxx1bUmB0hin+eueKyFQ4iLR32C4RtNfFSeyrGDIR/8CO7ekAYDvksoN5igNoJ0ESL8xfZwl+eBS/uCHzLS0ONVJ6GntLnNkjTZ1BifTMrxk8RJssNqf5achVWrEAe0xCiVwzUF8M+ynIHJHfnkHQkeVGb750lA+OfHQ57m7o6M99dBMRwD4OqybySXuw6WcFJqD98Nek6WxggUT7245z6mhrqI8K7PlnNP1z2htG1MBwIcr3LUgU8zGQ6tiJVim60zlzO9gvMojuLbJGQMP73DhwI9eavqgVQJ4evdSseOupC8HfxCNvBDX9TbhPmtuzZlsUiWej4Qf6/csqIVRLwNrOZjIsohaM5w5HuNGcd+aWNl7qFyBaB75W0LwLk1tI7Qg7LdlHxnuS2PqG9RCwmNE8eE3HqLPIZHGSDazs7/xk+9lmIMus+ihgA4ARwoCiJ5S6JMQf6tJh7FBQKbT6bdQl6XflwHtkz1YSxwjX8+nBXJ5RQw++oErutCMZNmzvgpihT9m5KQlHRlEnF/dENVclZojVfbOj5DInxpwsq6lh0hQe5DUpsZyom7ly4x9T0dv/F+ZVuy1ib6AM8d3B+hIBBlLphIZiW4T42mCoZG4mb/xwQg4nDKUCeUbNU/01BqhlhrqQEpobNL7n6SmVIbLXrCMQ2QPS4NJPnB0lLizdYPp3iWfxTrD9K7vLHwuqdzzuhl4VwHErqbCCmW5tLmT1OUi0Zlkr/Rg8rCujjxw2fCWWPn0P/N/DfE6tAyCKdtDEcRUraw8DQ4jFlzkLMAhzqYY3zcxbmbVTUunpukd/Wz2FinR9YhAeScJUyXAVv05T9/wZp6T2vzHYluLPouzSphvlCra0btb2bQHo0FJ0gPcVbqgpCvGRYjm6kRo0loZimOD3s9F8nDa1GILoBvPNvwnWyO6p3OfWMjjcXUYpbvMQj+abIGvs0B c++1Q9T7 xDsVhSuB5o/wNfY5LsazGSSjCW4BoJSOuefk/NS0TPRBFAKOCqOba0rVbUmC++pNQ+Y5PbtPiovWkasP50gCj0afbkPrvJARHwCNz/KcctkH7QX42UCjYqZjwbiIxzZxccFvmPAE9c0x6HrvK+7O7RNzgYSH1udxLESWe9PvGOSBmS5vnvUwhWNVkZLcaVwl6f+vNZ9pMC4vWAAsYNxkxC72NI9EUYZL7VDO39U/fAAzUIbraQEnsw2pRMaek7KyaQOUweBVLdclNiKfZ3uyOpkALPfSaUSbL3A0JUukdsW5phtG4224UCiJyJw== 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: Hi Zheng, We Cc kunit folks for any DAMON kunit test changes, so I Cc-ed them. On Tue, 22 Oct 2024 16:39:26 +0800 Zheng Yejian wrote: > 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(). > > After this patch, damon-operations test passed: Just for a clarification. damon-operations test doesn't fail without this patch. This patch introduces two changes. A new kunit test, and a bug fix. Without the bug fix, the new kunit test fails. I usually prefer separating test changes from fixes (introduc a fix first, and then the test for it, to avoid unnecessary test failures). But, given the small size and the simplicity of the kunit change for this patch, I think introducing it together with the fix is ok. > > # ./tools/testing/kunit/kunit.py run damon-operations > [...] > ============== damon-operations (6 subtests) =============== > [PASSED] damon_test_three_regions_in_vmas > [PASSED] damon_test_apply_three_regions1 > [PASSED] damon_test_apply_three_regions2 > [PASSED] damon_test_apply_three_regions3 > [PASSED] damon_test_apply_three_regions4 > [PASSED] damon_test_split_evenly > ================ [PASSED] damon-operations ================= > > Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces") > Signed-off-by: Zheng Yejian Reviewed-by: SeongJae Park Thanks, SJ [...]