Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1877831lql; Wed, 13 Mar 2024 10:32:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnb5AXK+5AQmNJDwSPeptb1TGVDtQBxOK4BpGO8WgRG+X7dg/ewX+c8dYRQDh/xYo/+z9GrXGBdJguNQdkAJZX4Mhq3xtsujYBZxIiVw== X-Google-Smtp-Source: AGHT+IESeiEI+PwItg1Nrn469UGHzj4qFDNZcPLChutV5KrZMWCW657ajQJSlGaOfdnBJjtZwcMc X-Received: by 2002:a05:6358:1081:b0:17b:557a:e593 with SMTP id j1-20020a056358108100b0017b557ae593mr856843rwi.12.1710351134445; Wed, 13 Mar 2024 10:32:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710351134; cv=pass; d=google.com; s=arc-20160816; b=iJQWrDkxlhxvcAriITrFp3PCouePxu5E33sr3ieSuBbb0UOcBWoEKNEC1gET4Mj9I2 lpz2DVoe9kCXMo47vQhDUf+V6p2X466zjjv8vaAaPd1eh14uILqRIEAZv02dUinVFRF9 tS4vHjwnkeEGB8UNvT184H2R0HnS/ElqKRUVkTK6XUSpVctaHtsGDE+krZFrbfAi9zuv ebpAnyowYmz3KmWBzboJx+tEZpww9AUfUCwJ9ZWvh3Utt3BBZJ39olEQurpNFuEJrAC8 UF8T0lEpa8gcjTr/8/D0QnyLbUm+yzZv7qO+/I1Ar/rgxtN5Cby2ta62D5gjSY/CqgMM c2Vw== 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=On3cztOP5oSTVS5bTfv07AbxDc6wGZ9Bi2A1iZPoPdVVgsDuFlqVEXCdkWaT/cpKzN VcN2m1ANdfkgoUugre6Nn1VhMgwiCnl+1SRnjLjfg6rWELzcBG/R9itFGePz1fZDed0q Oq5IJ3+hKZPYVmYpP1FRR0BRIZAGKEsk2tkNt7r3TNeNE/VpEGUgeMfaCBSJ+HBcpaa3 GnBMpBNp1695WPmP+hkWxhmDHMK3nBfml84Y3HwafhixWk+JVeEpJC3rPuO6cEQAyDdi u6ijl1ORKze5E1Ey5+RFWYBCohrU4DmwTx6iZxMPg6sN+GOQ0yvqW91N4aEa4Od8FeTX kUUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iQ5ifE9a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b10-20020a63a10a000000b005e437941b3dsi9457576pgf.874.2024.03.13.10.32.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iQ5ifE9a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101983-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 924BB282063 for ; Wed, 13 Mar 2024 17:31:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C44A1482EC; Wed, 13 Mar 2024 16:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iQ5ifE9a" 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 567011474D6; Wed, 13 Mar 2024 16:43:13 +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=1710348194; cv=none; b=LljcWItLxqO+P1sgLQR+SfjOruvRmOwpHHRMOkUA43cGGO3qu8Rcx0O+uUAYCvtcC5FkSy1c5cKUI9n4fObniMF7vafX08zFJOwgQeixbQJNPSc74VAF7QaP86JEPaSjT5Bq3JPbvPst+KriX+XVGolY3MPJSeciNaAByahpy2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348194; c=relaxed/simple; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OAwDq9SfKcSMHqef/67AXiSCHV0xzN6hiKUUzlZy0JBKAnhRudfdaTiO21sCwNhTxpb1gkheavGNeL+0Oh92KBwSGD1VlgjKO3lrdzkp++wEyFLLFOkCgZx5oUo/mV9AV+SHBw2VQ3NVOwNdTrzftfLag0WHxT5Kb/b5+N8sOJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iQ5ifE9a; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A847BC433C7; Wed, 13 Mar 2024 16:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348193; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQ5ifE9aia5Mbincn25yXaMxvSa/5/wJmwqgxBI4kw75OiY8UXZckWRCbyHcsXQYQ 9JElXJLhtWWh622jthwcZlJfKCTKPflhG4EbTv032mTyodaVKV1yryGo16Xh5YQy+y /mofkCNak+QqQVZbTyczapK6hlbtY6NCCV4Hx2ssDFx1RwJOCHkzLv03puT0tP/wul chYgGKuYFmNgkf+k4fzIs4dW175rxtsaUi0MKGcp2P8DdCF6RceqC1ImIF4W5/thOP 3BUsHvuA5WJhLtR+RCoSFTdCjb8ZHur21KS3/KWyo4DxZkUP9jSi+mL8Oevn/gcwge QNT0Csay7LQSA== 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 5.15 43/76] selftests: mm: fix map_hugetlb failure on 64K page size systems Date: Wed, 13 Mar 2024 12:41:50 -0400 Message-ID: <20240313164223.615640-44-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-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/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+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