From patchwork Mon Jan 22 12:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13525355 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 B8CA6C47DAF for ; Mon, 22 Jan 2024 12:06:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 515C76B007E; Mon, 22 Jan 2024 07:06:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C61C6B0080; Mon, 22 Jan 2024 07:06:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B5486B0081; Mon, 22 Jan 2024 07:06:07 -0500 (EST) 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 2AF226B007E for ; Mon, 22 Jan 2024 07:06:07 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC6CE120946 for ; Mon, 22 Jan 2024 12:06:06 +0000 (UTC) X-FDA: 81706818732.14.DD3E605 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 49865180031 for ; Mon, 22 Jan 2024 12:06:05 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf16.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705925165; 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:references; bh=RZ3qAJ7m+YTQxL2rzQkRyIw5i2KjbHV1uNAAvJ+RIYY=; b=zn9Lg5RqkNF2TDZ5rtm7+7ooOPowEOoMIAQLGqk/Yh6awzJm2q8DCpg3Vw6v3oOkO/S9GP TeKjEniq/NgnyxNUP00ptrEOcqKEYNwbvSDkTzNUlkhVcwJZWC4KOSKSOxIZZIf2cbuC/Y lNkcB8XvZGW+cG/m9vL+Mei7FMN3tUg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf16.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705925165; a=rsa-sha256; cv=none; b=PAA7MV7vXtAI/J7XunQDozkbmMmXOTNx8Vjazi2kTZIZDlBhXVvDHh7zXzJY/CABoYDI6v 2P7yAzlwh9ezHP9Ibt00JlHoCGdHiMfPWAN5n6VeRGAS4lLSEhYHHcDmQ0bhQ0MKhsnJID /8ujvqNly87gYxDRbyDAh5VkrvL2Ou0= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 18CDB1FB; Mon, 22 Jan 2024 04:06:50 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 17A383F73F; Mon, 22 Jan 2024 04:06:02 -0800 (PST) From: Ryan Roberts To: Andrew Morton , Shuah Khan , Pedro Demarchi Gomes Cc: Ryan Roberts , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v1] selftests/mm: ksm_tests should only MADV_HUGEPAGE valid memory Date: Mon, 22 Jan 2024 12:05:54 +0000 Message-Id: <20240122120554.3108022-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 49865180031 X-Stat-Signature: 9yj3q5d71qom3hncjc4h6jmdisr7nkww X-Rspam-User: X-HE-Tag: 1705925165-254198 X-HE-Meta: U2FsdGVkX18FIChJeZ8tVJnzoGLKXeZEv3zTxijSpq3kjJPqmeE2KY3InyDbOfSn8jDLQ2JV4b6/d0KGY97YjXsvUAOR7QzvKURjdO4p9MeB/YTS/HaP1qmFwUmB5MI9pGORMtR/2R5jKvt/kf2+WhN1doYWke5novvaKV2w0ljzUiR26ffye5DnCNmHxRmOV9zOEW8VTlI4RuCMtmR0obr4RnVJyBcHLlta+OlNrR207odYSiiesOXWD5Qf7brCVBCeA6A2dti3xUAw3yARQ0s9TIVQ191F/y50JOJ5vcPzYudNCpY6/1ZgSAiSbzRauoOPq9iEEy5uTX6vBP/RmVOogic6ixQZHO1uV/WPNBo4vRqmGqSRAVfoYuEK4iSdonhUNvfo51ihnUTn2smWNcXnjn0hHEiAD8abev74iv0dNzK/86WQwPQdgqJ9vvIxLI82R59wSWYNKkhBqIzdiPd9gQgnrMYNKkTrPcAPW6HMEUA6iTrzqjx0ZgX+vuv+/tsvFsT6HGeDyjU/ouRN+uSCu2JcWkH9VCunFcBHr8NvYg9fi7pJXkPn3TebacasiysniIvKbL7ZmQhp6mk5c8ZlvV3gVBrglfjuJOQBzaO+/JdHLpOQtKHqHdUWDyptCp5IhzS1V6PIv5/7c2B7+D5Dd9MeJpvIhOl1ENM2BZLACkrvG0tZauxI+7YLOnCHZOxIVVqAXdZluK7E7xgITn7ZsbaDfgCGv9FY9dpatSWZI1ER1iNI86Aqrph5D64q4u4u1mKU4uePCG9iX43+/XZODJnXkdCS9XN1GfawbtvOJaa9t2itDar7KT0/1f/ftHKqf+kreNkq0qCyO+KjcNl5jB37mvIjvTtrmI7HNE/LHzRF+PWZ23hK5OtNL/NRnoQVgxRsetW45Fi5V2sQobapBly+gQ5+fLdAJniCp9fpEQn0UBFfYVS6m32InDhsGSg/HGFFpwNNpzxPzvG x5Mmdk1C aqbRS7jxKbGf6/U7IdO02M6XX9F6kZXvfBNc4uOE8BNMQnyO5yIK6Kwe3EfCJk6JDrO2gzx9le4Nyv31dFO0p4pxzVtU82QiEW5ApQV06Z+PniFpz/WAY0EyY/t+YGHEe2Z1LKa5vZF5OO9C7+0jvbCjqmeEHZeBy/97cwDB0vU4x8k4uUbuvTAUdRioisvlRsRtJUL9A0zUNrWIU5AAJ11O/CTH/fmn6utOJadLJJJmGNUbT0hze6i8pHRCW8ErajqjPypOzxnqmmlo= 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: ksm_tests was previously mmapping a region of memory, aligning the returned pointer to a PMD boundary, then setting MADV_HUGEPAGE, but was setting it past the end of the mmapped area due to not taking the pointer alignment into consideration. Fix this behaviour. Up until commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries"), this buggy behavior was (usually) masked because the alignment difference was always less than PMD-size. But since the mentioned commit, `ksm_tests -H -s 100` started failing. Fixes: 325254899684 ("selftests: vm: add KSM huge pages merging time test") Cc: stable@vger.kernel.org Signed-off-by: Ryan Roberts --- Applies on top of mm-unstable. Thanks, Ryan tools/testing/selftests/mm/ksm_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c index 380b691d3eb9..b748c48908d9 100644 --- a/tools/testing/selftests/mm/ksm_tests.c +++ b/tools/testing/selftests/mm/ksm_tests.c @@ -566,7 +566,7 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot, if (map_ptr_orig == MAP_FAILED) err(2, "initial mmap"); - if (madvise(map_ptr, len + HPAGE_SIZE, MADV_HUGEPAGE)) + if (madvise(map_ptr, len, MADV_HUGEPAGE)) err(2, "MADV_HUGEPAGE"); pagemap_fd = open("/proc/self/pagemap", O_RDONLY);