From patchwork Mon Jul 17 10:31:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1030166vqt; Mon, 17 Jul 2023 03:50:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxA2eFJwdmmiMKMnRQ6RfvTBGl5Rh25xiBfa0ZKzMyCf0ld3w8x7W8Qh/lWLGVRg9OZ7MF X-Received: by 2002:a17:902:e74d:b0:1b8:95fc:d19 with SMTP id p13-20020a170902e74d00b001b895fc0d19mr13234388plf.52.1689591035636; Mon, 17 Jul 2023 03:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591035; cv=none; d=google.com; s=arc-20160816; b=Cl2Hem7dSuV6xKJMCgeLdYLbpnNuOV3+6PLFjs3GOPcLZNyMrUKWPxh2mD2/yp13hG 3rrtmZncTq4sJg1KaGf8MV/vdVyztAX2LKa3P8GZ5pfowuj9Q8pxUGQfcl42yyw1JOfV NK+H555DCsuyk0BLjNCicziFZApVPECMQuZXbCJYhDIlzOMETY1TbgZW4vncnRfOiVMt gML1KaTGPqfKxnFT0EnGwUybuQkAa2L5cAfPvDuo6tumzjV8RA3jyxSExYeSrS2L0t8w Ehw4aMqDV1hKiLcuKobjt9crEGCE1Eb2SQOA4ZeautTsKsh1N6wrjb0JpfBrUs8OjLfT NQSg== 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=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=qW6qCqVo0gfjSXBf6E2he21tfchY1IRnd+ZLrMyJxCcL787YWgy6Fpj31DeeggVTGD UMFnbcXsWCGTq1ruQn5besPisB6efvLfaHD6ALBVlwaPdg3NTd4Abh8yHMd7mXjswBVE fSjHjj9q0TMdGF57j7yT5G99S7ok4GU3ipEcmy+nxwO5P2XBTaboUT6d9yYWO8/jIYH5 Xbq9FFqKSkcbaL0iwCotgsvuhP2HBNCoNU4sXAzehKc9LzazxI81tjsm5ogivymOsfUK ii3iSP0P64ibCxBN2zB2tPA1yywAvR3wQrfROicKkpsdDNdwhowZGQcTX4llwGxqA5sA O+Ew== 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 kf12-20020a17090305cc00b001b9d03d0bdesi6516326plb.79.2023.07.17.03.50.19; Mon, 17 Jul 2023 03:50:35 -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 S230263AbjGQKcU (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjGQKcP (ORCPT ); Mon, 17 Jul 2023 06:32:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 65D26A6; Mon, 17 Jul 2023 03:32:14 -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 7416A2F4; Mon, 17 Jul 2023 03:32:57 -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 7B42D3F67D; Mon, 17 Jul 2023 03:32:12 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , Peter Xu Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 4/8] selftests/mm: Fix thuge-gen test bugs Date: Mon, 17 Jul 2023 11:31:48 +0100 Message-Id: <20230717103152.202078-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-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: 1771664609866576072 X-GMAIL-MSGID: 1771664609866576072 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 Reviewed-by: David Hildenbrand --- 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);