Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1867375lql; Wed, 13 Mar 2024 10:12:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnErGYPeCyGA2Dcmf4gBLzIl0P74OI5kBFb4NLpIuJ37CJWsq+NFJHHZkUa2Goixa/yitwgdxqm0AplENL6+v4qWd38xthU3pbilpInw== X-Google-Smtp-Source: AGHT+IFEB/le8FTaWzOGo3Pulrn3vN/97C3TlUPZTo3JwDMDIWW/YQDBqeuxXNtrLs3hghfet5Xh X-Received: by 2002:ac8:5f0a:0:b0:42f:205f:d20f with SMTP id x10-20020ac85f0a000000b0042f205fd20fmr4456109qta.23.1710349976965; Wed, 13 Mar 2024 10:12:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710349976; cv=pass; d=google.com; s=arc-20160816; b=nkqMP5YRv6fOdnqvTwkQ/zKht9yOlWVscCRP3AbB3Ip9JUZDLvBv9Q802jHhP7bCVB 0PKKICo3KHeNxMnaxEgKh0ut6D3bt6djx0uMfTx797SxltDNeu91Dm61fQFt7X20CVFh HVosx1uJnAzs/jKW0advTAv3PzBBGxq69XkkHO1fxJ8fik1WmvXvITmUY6JGIZXabtDZ 41uADt7+/RON0OooBR+m9/k2V39GSW3ivv0yw4qmCCxSwv3f5lO6ZUGa6WGZelvMBabJ Qvw52Rk4igscpfxB+g7OxvPLzW+rpSwx4+AqTzYBS9fdddwjL9Taxs3AqNEqaEx1deg9 tNlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TrWYfas6GHW46OQiKecjd2Mm9SkGepYZqbnVCm3oGZY=; fh=VmdOd7QNQzytIZLFUjxk4slNkpyWNLckGqmxYqdzuyw=; b=hPLRoULO3t/mtGzGOK5/j1oSoeATkgsKq/zWGPnqB1GGKMJAh9QZ86AjZ9tboyZ3sJ M44+WI/sjjG/B0Mub3h0WMias2g5MxDoRygft0a1lI67am8GAPfbpP0mwros+KAytq5s KgZLEkBgaetV1HR0lfQC72HuedC8zHEEjwbUF3E0HjNRMwxzkJLqWivwMfyQym7bgPji 9BGU7bwOs1aIk/sG+Hx91vxt4meIKwSQJSvkK+UIRlsQov1d1fBQb03R0NsuFBnAz7kM 2FYds4RQ8U5XjWxj35TcmlG2KdaQTF79WbdGDxRIV/XUcIbOO87667nyIZNFlMh6RUCW z1bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ePtzVYHH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d11-20020ac85acb000000b0042f2128b42fsi10369239qtd.459.2024.03.13.10.12.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ePtzVYHH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9DC511C21009 for ; Wed, 13 Mar 2024 17:12:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7B2E82882; Wed, 13 Mar 2024 16:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ePtzVYHH" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED15A823D1; Wed, 13 Mar 2024 16:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348046; cv=none; b=XCEbptudGMmCLh1Q87CGRVZCUgwXEBrDEFN3gDrjQQ6xkTAjaVEq/3u5PpCIZF61+P2+sj29JdLRKMPvhBVS07zJDzOhxhLE6Xkm6jhPd7b2X8wPsFO1NmPLWEBdFr7OPgnC0ieJYmBBwwgEl4E0IewHvCifLJTa93eDUPph0qc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348046; c=relaxed/simple; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sa1hfO11U7Cj1JP/bfolEok864BIlW/rWKcmxTA9DTUomw0eadtmeqD5c8rbefN2+rCC+/5PwjDDHyj2BW0LxRQGwgrzRRmsrlngiTDa7Hw86d9UW9d1oEGhaEWKCizk0j+UIuXNJFJ/OGqdCODZ1tm62RS6LMb/A7uLk1BgHfc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ePtzVYHH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFAA9C433F1; Wed, 13 Mar 2024 16:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348045; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePtzVYHH8MjtMQRQgxsDwEfUcaT/OkcFiLfBH4JZmJl+dPoDda28v0tyH7h+FLz4L HtIoikxyvwP2bgj30BFuOJtkNQ0c6RQKbJ+Wzq/mXh0xS1tajYpccOOHOq1ikxjv8o a7KL2pMkkZ7PKlutObEYH2sCaWndiVRXBGdc4YfhEOW95JSopcA/b0bYUEC77qcAGA QfnszWXlzrpukRr4yxh9zPJA8apdTbNf+hfAPiHpfxaYi12YanslmWrx33wySY9824 1TgbPWmEcfi5UN7ruqWWdUtvHkKahpH/zcAWpuR6omDlwKvkK84fiJT2ROQPQWq4ty gCdVt7+a+g67Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nico Pache , Donet Tom , Shuah Khan , Christophe Leroy , Michael Ellerman , Andrew Morton , Sasha Levin Subject: [PATCH 6.1 39/71] selftests: mm: fix map_hugetlb failure on 64K page size systems Date: Wed, 13 Mar 2024 12:39:25 -0400 Message-ID: <20240313163957.615276-40-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Nico Pache [ Upstream commit 91b80cc5b39f00399e8e2d17527cad2c7fa535e2 ] On systems with 64k page size and 512M huge page sizes, the allocation and test succeeds but errors out at the munmap. As the comment states, munmap will failure if its not HUGEPAGE aligned. This is due to the length of the mapping being 1/2 the size of the hugepage causing the munmap to not be hugepage aligned. Fix this by making the mapping length the full hugepage if the hugepage is larger than the length of the mapping. Link: https://lkml.kernel.org/r/20240119131429.172448-1-npache@redhat.com Signed-off-by: Nico Pache Cc: Donet Tom Cc: Shuah Khan Cc: Christophe Leroy Cc: Michael Ellerman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- tools/testing/selftests/vm/map_hugetlb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c index 312889edb84ab..c65c55b7a789f 100644 --- a/tools/testing/selftests/vm/map_hugetlb.c +++ b/tools/testing/selftests/vm/map_hugetlb.c @@ -15,6 +15,7 @@ #include #include #include +#include "vm_util.h" #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -70,10 +71,16 @@ int main(int argc, char **argv) { void *addr; int ret; + size_t hugepage_size; size_t length = LENGTH; int flags = FLAGS; int shift = 0; + hugepage_size = default_huge_page_size(); + /* munmap with fail if the length is not page aligned */ + if (hugepage_size > length) + length = hugepage_size; + if (argc > 1) length = atol(argv[1]) << 20; if (argc > 2) { -- 2.43.0