From patchwork Thu May 18 02:18:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13246057 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 90CEFC77B7A for ; Thu, 18 May 2023 02:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5948900006; Wed, 17 May 2023 22:18:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE2FD280001; Wed, 17 May 2023 22:18:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90EB4900008; Wed, 17 May 2023 22:18:49 -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 75FE3900006 for ; Wed, 17 May 2023 22:18:49 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 47F73160627 for ; Thu, 18 May 2023 02:18:49 +0000 (UTC) X-FDA: 80801767578.08.1F2B386 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf05.hostedemail.com (Postfix) with ESMTP id 75259100012 for ; Thu, 18 May 2023 02:18:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=laThT9Km; dmarc=none; spf=pass (imf05.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684376327; 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=O+pMaJ78vDhX/WJumeumdh2Ew8rPwZqh+d939UbVmCI=; b=HPSRBT2eOgFdWk5bjekY4K2Piok1M/RfHSCz6mLXix7n8+l3vltX5Ea3IZaWGAzpLY4oq4 gdP8jUCHErRTD8kSEhX8Qbt0VOC/teOlFgDayisCcRM5U8lUe1MLC/GflUPCQE7jbEmSF8 5ffyTyaNh35ex6WtxuJPdOVsBQ9V45U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=laThT9Km; dmarc=none; spf=pass (imf05.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684376327; a=rsa-sha256; cv=none; b=pFO3FO+cgcOVpKd4LzNkea6dwKxLkOMnxJ25d5nNeIsoWfst91QSg26A1LRUM7dllxkJie 8uu8oyn4powVUivCjaAkTEFyJ5LjdCkTsce4QHHgO6e6r/adu1SGgLaSySsXPa5AxGhego yatVfJvDqpFcrrdfh0ktgQug6M98Hzs= Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-759200f12baso168394385a.3 for ; Wed, 17 May 2023 19:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1684376326; x=1686968326; 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=O+pMaJ78vDhX/WJumeumdh2Ew8rPwZqh+d939UbVmCI=; b=laThT9KmuWwvZ+2Yoy5xsTan07ApYzz/BleFpSz8wK9Si/Q7ltWEJAFVbUqtOZ4D6L TMd2/Y9xWpgxsYsAa9xV49mMbN1y6fwgjT/pKe1dU8Islleu93aNaPSMOLxKyhX/jNrJ 4p5p9XM83q3qupRwXWj+wCh1LxpyNLzARQFWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684376326; x=1686968326; 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=O+pMaJ78vDhX/WJumeumdh2Ew8rPwZqh+d939UbVmCI=; b=Vi17GFa4tJ1eYNaHnhyUAUFHG55nKt8l4Kue7YOrQoKfCKDuLQqaOU0lpwfXYUISUL OB5bIF8R9vWM1AGlv6BVkTgdVORlIBjVBvl/gjDpDfYURRWi7djQZHCNP6Vp9egj5R9Y VRjaSuaYR6wAGw/tN+R+8AGEaifKCAK510MWMjR1WuRfVmgiHkdAFFAM4N9GjIqdAa9+ yITRIIvMGLtjNjWmWM9OjMyt231bhkaQaRN/UEYLUWBKYUPd9GnNxvkTzmSRjB1VAUCU j8u1uXScIHohKXJs9WCxeNsqLasJ62bf5w1dU7xcC/Q5YJQOgVK0r5Sczs6sBaiecRti R9wQ== X-Gm-Message-State: AC+VfDzV91G1WU2U9V+K+Rr2f5leBiJdb7/sdP1vcMioDdxTMpCtMeY4 iWkgEMcpd4iOlgvlNHh9Nt4VLA== X-Google-Smtp-Source: ACHHUZ6UnCuj5Nq3VC1ze3Rr3HeldoNEZzJlJJp6jYqyiOJjllcKquWS6RDoPMf5upFCbGWuS1xJyg== X-Received: by 2002:ac8:59cf:0:b0:3f5:315f:5c19 with SMTP id f15-20020ac859cf000000b003f5315f5c19mr3147223qtf.62.1684376326582; Wed, 17 May 2023 19:18:46 -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 j13-20020a05620a000d00b007577ccf566asm85082qki.93.2023.05.17.19.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 19:18:46 -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" Subject: [PATCH RFC 3/4] selftests: mm: Add a test for mutually aligned moves > PMD size Date: Thu, 18 May 2023 02:18:24 +0000 Message-ID: <20230518021825.712742-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog In-Reply-To: <20230518021825.712742-1-joel@joelfernandes.org> References: <20230518021825.712742-1-joel@joelfernandes.org> MIME-Version: 1.0 X-Stat-Signature: jx7sao1n14dpfkgo8xmf7u4jqcw73sno X-Rspam-User: X-Rspamd-Queue-Id: 75259100012 X-Rspamd-Server: rspam07 X-HE-Tag: 1684376327-586917 X-HE-Meta: U2FsdGVkX18W4OlHyx4MehrbXfsvbNQxZCW5PEoKwiIV/dyp2PcBZYVn4KtGUf3kzPEeF+G58/NSmeiLkrkTlGezCjOmV4WAwy4K1DCmpOWEWEOEUmBnL0Dhl6EELJShnuaCqDQVvbgrqM8z/S//ZFFIsGc9r7NmXkBRwdEHiO1q8rZVmz1XAhw3+ff7fpAMBe9nSjhPAVh1vlkaaLR6h/gKVUtpJynXavO/cHwVasJL81QyqmpRv1k8TTdjahvuAPMBEZbzozbjs07BzK7T5aHb9pkyHvCiF4T7oCBGaGHJC6AJ0Kx4ISVmnGlJ92l2VIFWxIZUEh0uQ2IMk4uI3GTFWH6xKJ8IknlDP8Dw2CeVFXm5Gk8XwDYMkn96R3Yy6huOERLv2Hdi7nIDGnliZzEwytIfGEQiNy8wEicUK8OLdUY/OIsywJqLAwkLA5m9mjhf4Mg3nzIGAWNP4ofRJe+Ms/MUMs++EiPsCeq2BjNH2mTUVE1ucLkw3ZBU+xVIYAupKpYg0pQf6xzFyhk7+FZRVhKrdm7wXp/RVakuzFh7XrATYyh8Sy5KRzzJQXWqsX4kb72yT/rzvGlIbddbu5gV+BZS6aWHgOaPVtQ4RfYi551/B3EWRMcxCHeQXWtjKL0Z/eT1EUmp0h5wnNIkzBf2/LbfeZ5gJahafioqFjqnHTTnmqxr0iWf95MAoCXrh4QhIntRL9YXgOnX0VfnSNmHlQqsqTHOX4lv0Bmp/beIy9r90lEKl9iITn5/5dyVFryfPeNB1x20M4fA56hyYI30MrDYtcclnZsfBFPMK61MT4ZCHTtYaaKDJR7PxWa8wtNzAFeVwbebGTxpTYG4lk1RGBcXpnnOpb66mMN0WWwepZ7y5QhIn6L1G7gmZZf4MbMd+glgud3Q5p4ZYwHkwyLNzb4R6xQXdcZiiaKzFklrrp3Jff6A7ya3SU+ptn+go887lplWxmJAgDiwJ8t r2e8meGz TYUL/ZWp2MurkAnjpEJhYL4PryVPNUVpLttF19kvGhb4Ze8FOt16Iapc943nkCC7H+BHFkR0JA42WGtP2fbKF0By5bSNK8ChhZjDzFu32k9KM5LdHn6ropb0nFlGlHRPUQyff12X65JzgGJ5NB2B7zwWuAYZlWOpN8lzUJlKwwlKK9VJfGs5Be9N9jN2uz3Vd9IXi74cNDBRQH5y3nVl21VI/7zhi/wCbhoHLvFhsnBg6ZjZlEj0mWATyRDmHgBa41+KAn/ShMECFhj5hEJH+KcqWdNIoHqDnd3H072vr2Z/FOK/TUbHABZ6VGjtIns9bwk9prKCeN6l/NA2Slf6GCuYucBan9OF1k3486JWdJKoIenPNW/cgrzwR5PoRolZEXEXTJ2d0BrPf9vMFBc+O8np21Q== 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: 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/selftests/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 = 1ULL << 20, _2MB = 2ULL << 20, _4MB = 4ULL << 20, + _5MB = 5ULL << 20, _1GB = 1ULL << 30, _2GB = 2ULL << 30, PMD = _2MB, @@ -235,6 +236,11 @@ static void *get_source_mapping(struct config c) unsigned long long mmap_min_addr; mmap_min_addr = 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 += 10 * _4MB; retry: addr += c.src_alignment; @@ -434,7 +440,7 @@ static int parse_args(int argc, char **argv, unsigned int *threshold_mb, return 0; } -#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] = MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS, "2GB mremap - Source PUD-aligned, Destination PUD-aligned"); + /* Src and Dest addr 1MB aligned. 5MB mremap. */ + test_cases[13] = MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, EXPECT_SUCCESS, + "5MB mremap - Source 1MB-aligned, Destination 1MB-aligned"); + perf_test_cases[0] = MAKE_TEST(page_size, page_size, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS, "1GB mremap - Source PTE-aligned, Destination PTE-aligned"); /*