From patchwork Thu Jul 13 13:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1853420vqm; Thu, 13 Jul 2023 07:12:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwJL2BvUUTVbtJQB969OesvkI8cj468NL0uMyeWO3rm3Z0ydJ4jhVF1/iFKpT9ZWoobt+A X-Received: by 2002:a05:6512:3710:b0:4fb:7de4:c837 with SMTP id z16-20020a056512371000b004fb7de4c837mr1385577lfr.68.1689257578873; Thu, 13 Jul 2023 07:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257578; cv=none; d=google.com; s=arc-20160816; b=BbLX3WOw2RqGLitGuOtuvSoLBe4mtA0ymJduKYZ5lsIRGNqsAE3P2foPchpIJmYgg3 CifBjuQiwLjoAOKMvyr+VbqHCzeZuRK0prQFOygg2t+x02IujHXCm6aY2oBpaBrVaHUR ernT2JcZepIyg4RXHD+doMQaocsGEo4vY7SdGci+XIJlGF3/MW4OhCvWY4KmUb7gCNoE KDsMroOvCdDXBkqFHwCigwu5XjVzts5FhXU3IPvDNs7bwiIVhiHyI830ea60cKgRgv3v Pd9vkidoXYuECy/rAqaHyzKVTblOanSKfFHw9jUhYbUNAWeqQPnfvxQ8F16CAR1KFzDy 13pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/uEzG53FLjd2glqlFJWx0HAfJNrq3vkp38/U3IednXU=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=HNRw1e3p/HI8iw+xFwFtgErnES76muD5ttO57dtRdw+XS16KxpZUEQgKJKYz9XgZdd Z3C44KhbxaLhS/1jo3toUFav7kLDM0S5Kw3cMICErYWDMwSds6NW/DR85QX3mq5a43RW nfUKwv+awBzXgfhuwEnbUd12cqyOZI0TfgPuT+eXClLPU+AIfDE/4rR85WOwB0vTGoAH YKnM0clOkWOdHIdm2/lEp/RkDkTkEkSP3w8ssqvPvIWrUun9isWtO30JFlkFYADoxTIy F2l13i+MxRSJ0r20O87SQbyMoPLdWpv9aQH7I1cnVt3pwhj/jkG1iH03rqJ4Nd87dxhc QSIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a170906d11200b00992ee6da875si7553590ejz.218.2023.07.13.07.12.34; Thu, 13 Jul 2023 07:12:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232453AbjGMNzM (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjGMNzA (ORCPT ); Thu, 13 Jul 2023 09:55:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6DEF71995; Thu, 13 Jul 2023 06:54:59 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6F501595; Thu, 13 Jul 2023 06:55:41 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACC483F73F; Thu, 13 Jul 2023 06:54:57 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 5/9] selftests/mm: Fix thuge-gen test bugs Date: Thu, 13 Jul 2023 14:54:36 +0100 Message-Id: <20230713135440.3651409-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771314955113547641 X-GMAIL-MSGID: 1771314955113547641 thuge-gen was previously only munmapping part of the mmapped buffer, which caused us to run out of 1G huge pages for a later part of the test. Fix this by munmapping the whole buffer. Based on the code, it looks like a typo rather than an intention to keep some of the buffer mapped. thuge-gen was also calling mmap with SHM_HUGETLB flag (bit 11 set), which is actually MAP_DENYWRITE in mmap context. The man page says this flag is ignored in modern kernels. I'm pretty sure from the context that the author intended to pass the MAP_HUGETLB flag so I've fixed that up too. Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/thuge-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/thuge-gen.c b/tools/testing/selftests/mm/thuge-gen.c index 380ab5f0a534..16ed4dfa7359 100644 --- a/tools/testing/selftests/mm/thuge-gen.c +++ b/tools/testing/selftests/mm/thuge-gen.c @@ -139,7 +139,7 @@ void test_mmap(unsigned long size, unsigned flags) before, after, before - after, size); assert(size == getpagesize() || (before - after) == NUM_PAGES); show(size); - err = munmap(map, size); + err = munmap(map, size * NUM_PAGES); assert(!err); } @@ -222,7 +222,7 @@ int main(void) test_mmap(ps, MAP_HUGETLB | arg); } printf("Testing default huge mmap\n"); - test_mmap(default_hps, SHM_HUGETLB); + test_mmap(default_hps, MAP_HUGETLB); puts("Testing non-huge shmget"); test_shmget(getpagesize(), 0);