From patchwork Fri Dec 6 18:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13897544 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 3A6A6E77179 for ; Fri, 6 Dec 2024 18:16:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F28C6B0202; Fri, 6 Dec 2024 13:16:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 77C126B0200; Fri, 6 Dec 2024 13:16:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F6156B01F4; Fri, 6 Dec 2024 13:16:43 -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 34D626B01A8 for ; Fri, 6 Dec 2024 13:16:43 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DB5F0A1650 for ; Fri, 6 Dec 2024 18:16:42 +0000 (UTC) X-FDA: 82865338836.09.EAADFB9 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf01.hostedemail.com (Postfix) with ESMTP id 44EC740012 for ; Fri, 6 Dec 2024 18:16:28 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=i+hQjPCJ; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1733508989; 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=TEIoEeFSNBZzBiel4A8kwVBDr+dCyb2gt/UrbBRiPEs=; b=lMkC97p2SBFSb/IgnH0HCQmFQjzRc1Q6jfsr3+jCMr1ZStIfj4jenJjq6l+wYxJpU1zF0k p1wZef53yMTRMHNayI6Md4DFhuwu3+TpWLro1nsMaNubPEh5tf7p+AZhY1xhMGYoq0fKE5 Y24sq9uY3RTVHOofzVYUx+Ezc+54sM0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=i+hQjPCJ; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733508989; a=rsa-sha256; cv=none; b=UmaLwmVnZ5GSsDWUqN2opTHy7ay469/jqlIeh2G724rPsOi2n54XG7NTmoDjSuGrVJsl5Z JNQMaMwLYxK49baU0ceuDSKKRtfc3qHSgzuj3nRgVlmxt6GWdyz5GxXVK67PNJiODFgOuP 99RRQsX/T6wMaGLMfseC2LbxBIMH+AM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B98D6A41D57; Fri, 6 Dec 2024 18:14:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BE47C4CED1; Fri, 6 Dec 2024 18:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733509000; bh=5pUCOmO26Nd3bpuwEx9+UO+/wAuFr0DwltCsV9SFGcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+hQjPCJwTLMGDNySEgbFPriLF74/Q25ftZO6x9pTNMs6Ox/Sx4VcbFjkDT/7Tlyc UCfD1IUXUuPP2/Znd3BeClZn26SHD/8v5VnN4cnZSZcF4TvFdYksuNKSwcJjeUfYUd 4MjrNH6hO6eHIDWRnUcjIDgoiJsYa9aRttWLTLqq13nQ1EqYtFhejv/adni0i35F8O 8RKeikTmCZ9aU85RjQzXusscGadatipw1kjlrxJy7wFC4Jgd4YnEWrwH4+U8eqObQI 6QT9n2t4rkqPTtshrMcCTr1SvTqFQhF7Wi7gHUMTXckE41zRWCy3urmQwJ6+wRjEkq OYwVhQaIAFfsw== From: SeongJae Park To: stable@vger.kernel.org Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, kernel test robot , Brendan Higgins , Shuah Khan , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15.y 1/2] mm/damon/vaddr-test: split a test function having >1024 bytes frame size Date: Fri, 6 Dec 2024 10:16:19 -0800 Message-Id: <20241206181620.91603-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206181620.91603-1-sj@kernel.org> References: <2024120625-recycling-till-0cca@gregkh> <20241206181620.91603-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: cfs6aengr3njfksuacji59gnbuzrpnqm X-Rspamd-Queue-Id: 44EC740012 X-Rspam-User: X-HE-Tag: 1733508988-852153 X-HE-Meta: U2FsdGVkX19FgWlQp/NKkr6vL1SN/OHl0eSDRXP0i0pRpQHXPtNZVMkGJudwKUZV+0DpruFr7c8vfUBkbwmGT3xGM1iTdagoiEg2me9Fo9ym94qqdmjLQjHdNlnB/z+LhtiexdmWVO/zIkxWPp8gMitJVNfuIFdbx69ktYNec6hG/HQXZQXFgy7JWgBBxgODTnxYxEB46Q8+BOBXwN97wkYqfgQyrPHAA5kWLDSomQaWUMOs7fl0L9HRA9mIn8Lvs7+k6LJw4SjZx4jqwzC6xscuY/B15NhXNdnr6N7QvsoVyd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4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On some configuration[1], 'damon_test_split_evenly()' kunit test function has >1024 bytes frame size, so below build warning is triggered: CC mm/damon/vaddr.o In file included from mm/damon/vaddr.c:672: mm/damon/vaddr-test.h: In function 'damon_test_split_evenly': mm/damon/vaddr-test.h:309:1: warning: the frame size of 1064 bytes is larger than 1024 bytes [-Wframe-larger-than=] 309 | } | ^ This commit fixes the warning by separating the common logic in the function. [1] https://lore.kernel.org/linux-mm/202111182146.OV3C4uGr-lkp@intel.com/ Link: https://lkml.kernel.org/r/20211201150440.1088-6-sj@kernel.org Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Signed-off-by: SeongJae Park Reported-by: kernel test robot Cc: Brendan Higgins Cc: Shuah Khan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 044cd9750fe010170f5dc812e4824d98f5ea928c) --- mm/damon/vaddr-test.h | 77 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/mm/damon/vaddr-test.h b/mm/damon/vaddr-test.h index 1f5c13257dba..95ec362cdc37 100644 --- a/mm/damon/vaddr-test.h +++ b/mm/damon/vaddr-test.h @@ -252,59 +252,62 @@ static void damon_test_apply_three_regions4(struct kunit *test) new_three_regions, expected, ARRAY_SIZE(expected)); } -static void damon_test_split_evenly(struct kunit *test) +static void damon_test_split_evenly_fail(struct kunit *test, + unsigned long start, unsigned long end, unsigned int nr_pieces) { - struct damon_ctx *c = damon_new_ctx(); - struct damon_target *t; - struct damon_region *r; - unsigned long i; - - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5), - -EINVAL); - - t = damon_new_target(42); - r = damon_new_region(0, 100); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 0), -EINVAL); + struct damon_target *t = damon_new_target(42); + struct damon_region *r = damon_new_region(start, end); damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 10), 0); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 10u); + KUNIT_EXPECT_EQ(test, + damon_va_evenly_split_region(t, r, nr_pieces), -EINVAL); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1u); - i = 0; damon_for_each_region(r, t) { - KUNIT_EXPECT_EQ(test, r->ar.start, i++ * 10); - KUNIT_EXPECT_EQ(test, r->ar.end, i * 10); + KUNIT_EXPECT_EQ(test, r->ar.start, start); + KUNIT_EXPECT_EQ(test, r->ar.end, end); } + damon_free_target(t); +} + +static void damon_test_split_evenly_succ(struct kunit *test, + unsigned long start, unsigned long end, unsigned int nr_pieces) +{ + struct damon_target *t = damon_new_target(42); + struct damon_region *r = damon_new_region(start, end); + unsigned long expected_width = (end - start) / nr_pieces; + unsigned long i = 0; - t = damon_new_target(42); - r = damon_new_region(5, 59); damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 5), 0); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 5u); + KUNIT_EXPECT_EQ(test, + damon_va_evenly_split_region(t, r, nr_pieces), 0); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), nr_pieces); - i = 0; damon_for_each_region(r, t) { - if (i == 4) + if (i == nr_pieces - 1) break; - KUNIT_EXPECT_EQ(test, r->ar.start, 5 + 10 * i++); - KUNIT_EXPECT_EQ(test, r->ar.end, 5 + 10 * i); + KUNIT_EXPECT_EQ(test, + r->ar.start, start + i++ * expected_width); + KUNIT_EXPECT_EQ(test, r->ar.end, start + i * expected_width); } - KUNIT_EXPECT_EQ(test, r->ar.start, 5 + 10 * i); - KUNIT_EXPECT_EQ(test, r->ar.end, 59ul); + KUNIT_EXPECT_EQ(test, r->ar.start, start + i * expected_width); + KUNIT_EXPECT_EQ(test, r->ar.end, end); damon_free_target(t); +} - t = damon_new_target(42); - r = damon_new_region(5, 6); - damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 2), -EINVAL); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1u); +static void damon_test_split_evenly(struct kunit *test) +{ + struct damon_ctx *c = damon_new_ctx(); + + KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5), + -EINVAL); + + 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_fail(test, 5, 6, 2); - damon_for_each_region(r, t) { - KUNIT_EXPECT_EQ(test, r->ar.start, 5ul); - KUNIT_EXPECT_EQ(test, r->ar.end, 6ul); - } - damon_free_target(t); damon_destroy_ctx(c); }