Message ID | 20240119125753.152354-1-npache@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp985954dyb; Fri, 19 Jan 2024 04:59:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAJ+z4+htvymko4A78bKnBaKjixnFvR6Fq+dsU4Aph6C1A8cn60K0C0XWD3eiF1pBleXaJ X-Received: by 2002:a05:6870:4690:b0:205:da63:2626 with SMTP id a16-20020a056870469000b00205da632626mr2602994oap.1.1705669178139; Fri, 19 Jan 2024 04:59:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705669178; cv=pass; d=google.com; s=arc-20160816; b=wbpqDNY9HKMxdidi+l7EEL1aPCLsiy+n6axHqyaPsPGdzD47XWDwtLxI21+boDBoR2 vpJn1vFBkTcq9+TlFeL9Rol4fk6MISXzuPWqpFHDKkDdZlaWjqvrYEzRAHQ7VxOY07Wl 2FgHxHXYiAsOnnyT9XnNYOqGp80nELqDyRnH943vzBXw9AEr9exvM8aEZTTZ5av5FmLG +nXOyPM99Cr7F43PX+b+cgw/+Idr/iY/pA9h96tVlwQe12PnQHN3spCQs2ohpJ4PsFvq 8PcJBKdEsLMTn9pCOryifTtko7V5W4nQKKGd+lsqOfFqC2sFLwb6YCryjpoaU2nm27kU iStw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=tSl8vraS51FiTpTDwvXe67q3UpTXFaFfY6Fu62WAl5w=; fh=ZPY9JeJLmTgS9LZKdhZ5ggio5HJ93IiZ6ENH9S+9zM0=; b=my9XaQOKnG9YxI1qZyrkmugUR/qIxcv/GmV5ssHkUnM1XFYA3JcizVuuMddLLKK+Ep wD5cAkWAqU2kcQhpF04e01TdMdyUrpe18pWkJXMirLx9D1u5oO+idhM8KSU/nYxI7rq3 w/CkPjuoT1Q2IrY3utLear781ygevdh3ELo5pJi9JvhSYv9ggS8eKcX219ByE1lQNqHI Y3vMXXZbsHAqbbVxMoHnxHmSFFFwVDdugD7d4XDJdRdyamBPAmddUMLSq5VB6ud54iX1 E+BkyFtEYbXLSeuMMmcGrtsl3AImnseSe9GCzqYCnRNySzAvxi208wHDV6vvoQ+IhG52 zsEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aSKS9lGr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c1-20020a63d501000000b005cde42fcb11si3332883pgg.707.2024.01.19.04.59.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 04:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aSKS9lGr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31151-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A4EC5B231B5 for <ouuuleilei@gmail.com>; Fri, 19 Jan 2024 12:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A15F8537EA; Fri, 19 Jan 2024 12:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aSKS9lGr" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 6FA9351C38 for <linux-kernel@vger.kernel.org>; Fri, 19 Jan 2024 12:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669100; cv=none; b=T0LokoFtKxebuO3gx4YXL0Uo2Sxu1Pw2fhVCLBG62f9KWLlm3SypE6YwL3m4DeO/qw7jPL7RER2Q7tgmcLTT+u2CdVI8Es927Y6rcfpIZOwMcOuGX5tK5CU5+RPSAjrhCdzWXfi5DNE4WyAPla30JAlHP27/IIUhn6AXgENktTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669100; c=relaxed/simple; bh=9oN8WEtKHa5I91ygCWQnS1mqKVl+6aTCIb+eEtvC21Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Y6vV+3mWQStj5UjwW/AxKHyqjiFgej28MN9A/Kgtn8XsSbEovYvJp1lD679LHnrgaQqmsfMW4xyixqF+UggD5p/NKReqaDDTelaFZb9S+vjlLtwsHoLI114li4exdiD7/CmPx2V9qpxAn1FQh+ys7n3N2ClRLrUF0FtvqRinunY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aSKS9lGr; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705669097; 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=aSKS9lGrwXqJJHj1TYgcO3vzw2WJeCu8XJqCHafkVI0Sn/EjwuIQYrsGbF5FEvfiR5PdK1 Y2F/sypdGIUOKmON9RfMFmJEc9POgUYA57zGr975TL3q0RlBYISN51D3bEX1uzp+yknhCb l+TAyoiYYAdCZEf+3LZmxUns7rgzriQ= 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 <npache@redhat.com> 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788523764300505483 X-GMAIL-MSGID: 1788523764300505483 |
Series |
selftests: mm: fix map_hugetlb failure on 64K page size systems
|
|
Commit Message
Nico Pache
Jan. 19, 2024, 12:57 p.m. UTC
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 <npache@redhat.com>
---
tools/testing/selftests/mm/map_hugetlb.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
NACK. I accidentally sent an older version of this patch. Following up with V2. On Fri, Jan 19, 2024 at 5:58 AM Nico Pache <npache@redhat.com> wrote: > > 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 <npache@redhat.com> > --- > 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) { > -- > 2.43.0 >
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) {