From patchwork Fri Jan 19 12:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 13523757 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 0F5DFC4725D for ; Fri, 19 Jan 2024 12:58:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CDE26B007D; Fri, 19 Jan 2024 07:58:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 77E056B007E; Fri, 19 Jan 2024 07:58:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66CC06B0081; Fri, 19 Jan 2024 07:58:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4D6006B007D for ; Fri, 19 Jan 2024 07:58:19 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C29D9A0D9D for ; Fri, 19 Jan 2024 12:58:18 +0000 (UTC) X-FDA: 81696063876.02.99AB491 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 08A434001C for ; Fri, 19 Jan 2024 12:58:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M51iYifA; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705669097; 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:dkim-signature; bh=tSl8vraS51FiTpTDwvXe67q3UpTXFaFfY6Fu62WAl5w=; b=EXyIoEgqkEcxKgm+pvwWwxNO3zK+M6d3FtUDlwH7qHUKvideTm3LhwxVNCkd+G0sAsIuil wqn61FUIlSlH9QCg8SrLZq1T32dYg39BvJk0nqGRlK7k/kwAXj0xsLCtbOXn0kqjqstISu ZYI+naTYKc2GK6YhBaMt4pTIvVtfBNE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M51iYifA; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705669097; a=rsa-sha256; cv=none; b=l5zDsMBEhkGdKIu1I1lTXr+6W4QoJ1IkhLc7Gk7mNL5AmtR4LhiAWle6Xh/XXr2Zyd18yf IPhhBNb9bIA1CWlaxg1YMpOZc2J5z+e+zEPPtens9Rg8vucnb4tb5WVk53zDA18WLLieDM WImu/neAYBdS5pfI2olUrhkp+LLKl/0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705669096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tSl8vraS51FiTpTDwvXe67q3UpTXFaFfY6Fu62WAl5w=; b=M51iYifAULJULUrki9vrbZfhZmY2sJddlgOm8ZrNJ2K2SONrSxUcEMiK5HgHdxuaywq1Ba WUlgn064jYBSZG2K7C97GLeDHF9tlmgsog6kzKEVNtw3VOqWr/WwxjUaLBtr+dHNZbIkgG ymiveC2z3+vAtu1xMz6qOSKi6r+cVsA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-56YpH6c8NtiCuO0XfASFRw-1; Fri, 19 Jan 2024 07:58:12 -0500 X-MC-Unique: 56YpH6c8NtiCuO0XfASFRw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AB5585A597; Fri, 19 Jan 2024 12:58:12 +0000 (UTC) Received: from localhost.redhat.com (unknown [10.22.32.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id A227DC1690E; Fri, 19 Jan 2024 12:58:11 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, shuah@kernel.org, donettom@linux.vnet.ibm.com Subject: [PATCH] selftests: mm: fix map_hugetlb failure on 64K page size systems Date: Fri, 19 Jan 2024 05:57:53 -0700 Message-ID: <20240119125753.152354-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 08A434001C X-Stat-Signature: 8ftihhm5dohhchybdxutw7881dkm9oyb X-HE-Tag: 1705669096-697873 X-HE-Meta: U2FsdGVkX1+AeyJLGuil0f6PO7Zpwx1aXHHnysS+dBxmZhqcBB9vVeUyVYpw7XyMTERxrcoXJAsMWT9BpmM5FQpMtKP/hGknqfoaRHFUbGUdEzWFfHbLD1jSt96SNNudWv03FXa39GE9WE2nmOkxFd1M9fJ/ZLjwwvf4weyFKDhxULW8E013B0J+6cJzMomkIX8jhi1pNQvrLjKj+f3bTjXNHsmQLJ4YPhK7rLMVTBf+dQ7NVzvh6ULwRsBA5g7J9QGvPP59Xcln0/UUweLxBBOKN1EiImwjOKv8bzJpeRWgJR641YF7YeMBLcELiysRWE1VCE7UQhb2Xeq/QJPBI68x/xZFNs4qZX+k3NzSiVbVfUxEuJ9KE5XHi1o9BgCIG0eHG/p314O9JdOBZudGWb+PQZ0/wjX8jqdIskyHb/AMUqRyP/BcOYKKL8CT2tBqItAiZD+Ad0U1hZGxyG6hKuIsUW7KobDG+i8gycHBG7InrHt8thViBIzAn7FHQUWHWb4DCKrvBUTODq8d6hl1LKfstiSVOz4Fib1XZxCFjaxpFYeU16yG6i3Ec1YirAr5gQvyNM/GrVD4q/vExDXXcn3IwUtTnrj/m2/HvQZlh/slbJVctCH3M02yFuiZU0xJwoge/FBID42bxWEtCnJorBpipCeVHrNQsOiPGO2OzTehsNk7+jRvSm2b/BBIroVzUUgn5PH6PFvVPir97YxHCEvg5fCRHk5KmaUzW+BABWPvfpwb6qKkAdYqPJdKSyJix3A49/pS+25xMHa/RtOEDb2XE4lHtZgMml6vpGLgJcstEKgCHHgckI+4rbPkKfIoAZ7zSAQiTYsMEC9wkyJ8hPwJCNkEiPb4R+nQ9DHi6PZCzc+Boh7RzgADsCSQ8A8ROR0IL8caD5DMjUKVit75wvPc8tkqoEA7X1xBzz3McWDiSSVdag+g29nefqJHJi963Pbr+rQeIW90qmmcSvu NJaRy/QZ QfTI0u3LcX4Rdt5dDUOjwwN3+slPmV/9VASERkEL4gX74e/sIqf5oHz8a1Pom8WL4OGqKbsUlnuGHwnHiie2xbUKIHHg173CdXMLQi5DJIQ+30Tn5ejvvafNkuDxzeJD6JUrzSy+wczV1QFIK512ILYI6DViKj/XN7TBmeEGSroZa+fxM9uJKDxZ56jTNGLJzpP+5RPJvXU/51YBz0ac9qDrpjw== 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: 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. Signed-off-by: Nico Pache --- tools/testing/selftests/mm/map_hugetlb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/mm/map_hugetlb.c b/tools/testing/selftests/mm/map_hugetlb.c index 193281560b61..dcb8095fcd45 100644 --- a/tools/testing/selftests/mm/map_hugetlb.c +++ b/tools/testing/selftests/mm/map_hugetlb.c @@ -58,10 +58,16 @@ int main(int argc, char **argv) { void *addr; int ret; + size_t maplength; size_t length = LENGTH; int flags = FLAGS; int shift = 0; + maplength = default_huge_page_size(); + /* mmap with fail if the length is not page */ + if (maplength > length) + length = maplength; + if (argc > 1) length = atol(argv[1]) << 20; if (argc > 2) {