From patchwork Mon Jul 24 08:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1655814vqg; Mon, 24 Jul 2023 01:35:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlExSrWw+954T4IGE/KzHCB+bSl+VCHGYIACbpjuAg4vPJZF6oZJ10rEZJRLAk7tm1I+76am X-Received: by 2002:a05:620a:22d3:b0:767:f14f:ea29 with SMTP id o19-20020a05620a22d300b00767f14fea29mr7524509qki.75.1690187710737; Mon, 24 Jul 2023 01:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690187710; cv=none; d=google.com; s=arc-20160816; b=pnV0jwmt1sCKJpw3dBOvvKeIkz3M+UyfKqL7AZSlHcuaRIVMB795I56sxyS398oBx/ cDebwG8bJviE1gVtIJGNV01bPY43bH+M4EIN+5aSYtHbvCOPGtL0S2s9DenSNR4CNf5i pBLnZjUkPiu2VeMqSvh67R6iSki/dcY5orr1lvMqET7kw4UHuqToFEKxP6GIiOxAcvzZ wBKDYrm2r6GkuvWOj/tY5aNTC7apeSlCgnm+zYpolKH60ymsCA5XT3AIN6DZx3Tmi8xN vJff/kV6RClgSfeg+v6z1LHyI8XjqZ1nInIq9+LOe3weqpMbO2LI/qY4ijrUzyTDclfi 8PPA== 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=RlF+OWSt7Xg4Y8gUX/1pDNyyb2oDlnFwm/E3+/VsYzs=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=itEgx7LF9TM2mm/V0M1KuUM6k1p9INLNwW94ui9hDtlzZe/kNNsuMBZjkpHU6b3i3U o29TtPygdvgo/f3Vfl4d6sRsfyPmZ3qEVCGeNaA0T3VC4//JDj+dbdSXOZ1b4SUf/Kn6 37kr6rZG+2g2fcuGJxSLHAHDhb8IWtzKSKLoye+UixB2sIvG7s2fwbdPaQPoUr7NaLEr HZJfoBYw+mJZCmDIctjh1gmdNxdTCVjd5EKJvveHNvEVbgPaNkE8sEhOee4jOaXeTL0e Ja2ZZv7cYfusHc4+yLspgYzdFDI698qHX8o41X1BU8bWlg1zetKE5ZHdyygIuwJXVks/ UQFg== 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 nv9-20020a17090b1b4900b00263a99b8448si9390563pjb.113.2023.07.24.01.34.57; Mon, 24 Jul 2023 01:35:10 -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 S231484AbjGXIZw (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbjGXIZl (ORCPT ); Mon, 24 Jul 2023 04:25:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA30B133; Mon, 24 Jul 2023 01:25:40 -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 BDAAB11FB; Mon, 24 Jul 2023 01:26:23 -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 DA6DE3F67D; Mon, 24 Jul 2023 01:25:38 -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 v3 4/8] selftests/mm: Fix thuge-gen test bugs Date: Mon, 24 Jul 2023 09:25:18 +0100 Message-Id: <20230724082522.1202616-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290268877569652 X-GMAIL-MSGID: 1772290268877569652 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. Reviewed-by: David Hildenbrand 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);