From nobody Mon Feb 9 06:24:28 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B10D4C77B75 for ; Fri, 19 May 2023 19:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbjESTKh (ORCPT ); Fri, 19 May 2023 15:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbjESTKX (ORCPT ); Fri, 19 May 2023 15:10:23 -0400 Received: from mail-ua1-x932.google.com (mail-ua1-x932.google.com [IPv6:2607:f8b0:4864:20::932]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B0110C9 for ; Fri, 19 May 2023 12:09:50 -0700 (PDT) Received: by mail-ua1-x932.google.com with SMTP id a1e0cc1a2514c-783eb14ae3cso2242983241.2 for ; Fri, 19 May 2023 12:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1684523389; x=1687115389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8BlbglpAiZ94wJYkjhcCjsilb7jfKjCG904F6yJstFY=; b=x8ZyDrw6ni184t1nPUu9gHzYGnCU4QMuz0CHgZiJdJSkGolahQopXIQzMHUKRX1tuL Sk9VbgqX2HUtPxhGHeN4FRXjhKh1tAahRr6lwwpWuDo763W0ExapWgKq8ZNizk5D6Nj+ cwyjlwYVFmQ1N0AvIKfGAIKpy+GRM3WOTBx+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684523389; x=1687115389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8BlbglpAiZ94wJYkjhcCjsilb7jfKjCG904F6yJstFY=; b=idZrh4zpzjhcaoDFFXFjXB7Ljz+dPZm0vcCCR0h3VnDP6XO9VfL6+nvvEueB1BJLC9 1Xh+K0Ns00ibJJwqNv1ByV69JcCmgNin9o4be7w/ALiHM+/wNzysp5fKecokiVJXE0EX BEHZVicPj2a7eifINjEJZstV2TpfM7ZY+ETVY80/wXe/LlhU1qxDO/OBfT7WMpuXYuJf OMsV7ZL4n3qbr0Oo7MeIj7ErMFfjr/CtwbUl61x+OjHhS7QKbcWS66c6/3TInC2R8X2/ MblMDqI/l4A6wPqOIvHylSRQgF0tJNT6gpWM+O1UU0/R3ef9na5td/YZ0pYQ0/WPQWHp M4lg== X-Gm-Message-State: AC+VfDyE3Ab6tNn5Y9R26nGAMy0GC40enR13R9PgNg7J14jg9dxNTWcE sDo+366Zq8T1VOQ/wU0XEFj+r4vMleWJZBSav2E= X-Google-Smtp-Source: ACHHUZ7k2Kr/gJkiN5S1M+tfEjayIP8g2cDy6n/x0srwgMQ1712z1LJILIPD/wMAeXbKBNfnKX869w== X-Received: by 2002:a1f:5901:0:b0:43f:ea80:e8af with SMTP id n1-20020a1f5901000000b0043fea80e8afmr1449033vkb.4.1684523388940; Fri, 19 May 2023 12:09:48 -0700 (PDT) Received: from joelboxx.c.googlers.com.com (129.239.188.35.bc.googleusercontent.com. [35.188.239.129]) by smtp.gmail.com with ESMTPSA id q20-20020ae9e414000000b0074e1ee30478sm1317611qkc.37.2023.05.19.12.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 12:09:48 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, Shuah Khan , Vlastimil Babka , Michal Hocko , Linus Torvalds , Lorenzo Stoakes , Kirill A Shutemov , "Liam R. Howlett" , "Paul E. McKenney" , Suren Baghdasaryan Subject: [PATCH v2 3/4] selftests: mm: Add a test for mutually aligned moves > PMD size Date: Fri, 19 May 2023 19:09:33 +0000 Message-ID: <20230519190934.339332-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230519190934.339332-1-joel@joelfernandes.org> References: <20230519190934.339332-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds a test case to check if a PMD-alignment optimization successfully happens. I add support to make sure there is some room before the source mapping, otherwise the optimization to trigger PMD-aligned move will be disabled as the kernel will detect that a mapping before the source exists and such optimization becomes impossible. Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/mm/mremap_test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selft= ests/mm/mremap_test.c index 6822d657f589..6304eb0947a3 100644 --- a/tools/testing/selftests/mm/mremap_test.c +++ b/tools/testing/selftests/mm/mremap_test.c @@ -44,6 +44,7 @@ enum { _1MB =3D 1ULL << 20, _2MB =3D 2ULL << 20, _4MB =3D 4ULL << 20, + _5MB =3D 5ULL << 20, _1GB =3D 1ULL << 30, _2GB =3D 2ULL << 30, PMD =3D _2MB, @@ -235,6 +236,11 @@ static void *get_source_mapping(struct config c) unsigned long long mmap_min_addr; =20 mmap_min_addr =3D get_mmap_min_addr(); + /* + * For some tests, we need to not have any mappings below the + * source mapping. Add some headroom to mmap_min_addr for this. + */ + mmap_min_addr +=3D 10 * _4MB; =20 retry: addr +=3D c.src_alignment; @@ -434,7 +440,7 @@ static int parse_args(int argc, char **argv, unsigned i= nt *threshold_mb, return 0; } =20 -#define MAX_TEST 13 +#define MAX_TEST 14 #define MAX_PERF_TEST 3 int main(int argc, char **argv) { @@ -500,6 +506,10 @@ int main(int argc, char **argv) test_cases[12] =3D MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, EXPECT_SUCC= ESS, "2GB mremap - Source PUD-aligned, Destination PUD-aligned"); =20 + /* Src and Dest addr 1MB aligned. 5MB mremap. */ + test_cases[13] =3D MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, EXPECT_SU= CCESS, + "5MB mremap - Source 1MB-aligned, Destination 1MB-aligned"); + perf_test_cases[0] =3D MAKE_TEST(page_size, page_size, _1GB, NON_OVERLAP= PING, EXPECT_SUCCESS, "1GB mremap - Source PTE-aligned, Destination PTE-aligned"); /* --=20 2.40.1.698.g37aff9b760-goog