From patchwork Sun Nov 10 06:49:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donet Tom X-Patchwork-Id: 13895574 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 5FC73E7716D for ; Thu, 5 Dec 2024 15:28:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98F156B00C5; Thu, 5 Dec 2024 10:19:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 029AC6B0114; Thu, 5 Dec 2024 10:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6680D6B0101; Thu, 5 Dec 2024 10:19:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 048506B0083 for ; Sun, 10 Nov 2024 01:49:18 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7D4921A13A7 for ; Sun, 10 Nov 2024 06:49:18 +0000 (UTC) X-FDA: 82769257620.26.78EED35 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf08.hostedemail.com (Postfix) with ESMTP id 5AEC9160002 for ; Sun, 10 Nov 2024 06:48:50 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sHDeDuEH; spf=pass (imf08.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731221126; 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:in-reply-to:references:references:dkim-signature; bh=jvYaJb6azWo0m8bn11g8QslqBFijvCyAEzFxfFrmX5w=; b=ngZzaI0wOcS8pke9XV9t+WYOWbSxhiYr/w3V31NXMHrgJiM+bWRBKbHATTUKdRbRGqb6tc a3oWFl+/YbfJqH3HMqbvnTBiDkMFoll9HCfyn+7riEryp60vl7dO6x/UOBRlak63RTnGQ1 V0w3t9vqi81SnBdJ8DUjRtXgltsKcCM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sHDeDuEH; spf=pass (imf08.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731221126; a=rsa-sha256; cv=none; b=cT9zzgxBfUbePfnnliF+VjGOvUtlAXTu9Qj6jwQPIBUG7o/SAij2VAlQ7nQxFouF4Z+d5d vbOek9gOKLbpwWLhAtLZykUWNK3Ton6axi9hxVqqK7ZXoPjQYXSR6K/NMl3B28k6r/j2lm yzAym+BOjTAQBf4QuyYg542CWRhwilg= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AA5v6kp000347; Sun, 10 Nov 2024 06:49:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=jvYaJb6azWo0m8bn1 1g8QslqBFijvCyAEzFxfFrmX5w=; b=sHDeDuEHD50TLYtl5RDeIIE/DQxShVfjp K68y9GQSndOclvoDb9vBinM0ANo7kCcF7kxL7Huxpvcrs8gsTV7w8xhiZl9xl7t0 V8ALNZJtxrO/dGhq/r07a31k9WUmE6VHOTzq699Xz6BjlwfhcXQvJr3G3byiWGvs gbhiDPqZ6oJD6cN2j7tFcmFOGNkmI7r3Diyu4OtyS7yj+81aYdwwNkmIF5pJDUhL vWqpPhOBKO/BNSjacmDpujNmtY8Tsiz2XTsQL0pGnATQg0yihUpSCKT3fRvczr06 imkLVoAdsZfGuCsBItfPRyoA0p2I07VXa9sgFASW+N7An8AYK/rIg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42tjg3910e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 10 Nov 2024 06:49:12 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4AA0BMXh010521; Sun, 10 Nov 2024 06:49:11 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tj2s0e84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 10 Nov 2024 06:49:11 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4AA6nA9U21103048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 10 Nov 2024 06:49:10 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 255D020049; Sun, 10 Nov 2024 06:49:10 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C888F20040; Sun, 10 Nov 2024 06:49:08 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.40.194.31]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 10 Nov 2024 06:49:08 +0000 (GMT) From: Donet Tom To: akpm@linux-foundation.org Cc: Usama.Anjum@collabora.com, donettom@linux.ibm.com, kernel@collabora.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, shuah@kernel.org Subject: [PATCH] selftests: hugetlb_dio: Fixup Check for initial conditions to skip in the start Date: Sun, 10 Nov 2024 00:49:03 -0600 Message-ID: <20241110064903.23626-1-donettom@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109223436.3ddeaf1d60e1ade8f562d757@linux-foundation.org> References: <20241109223436.3ddeaf1d60e1ade8f562d757@linux-foundation.org> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tCo3NsxOEUKn0qsJpazH5rZ1MBq6zfoW X-Proofpoint-GUID: tCo3NsxOEUKn0qsJpazH5rZ1MBq6zfoW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 mlxlogscore=689 lowpriorityscore=0 adultscore=0 mlxscore=0 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411100058 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5AEC9160002 X-Stat-Signature: oxao36qb4m39kuamw9uwc3x33beopfxg X-Rspam-User: X-HE-Tag: 1731221330-809425 X-HE-Meta: U2FsdGVkX18HaDg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deVj+7dMF7y7K7ygKZ0+m88uJcBx8t7vASzZSfhbEjjzaCTo05alIU4IMJWzkf+zcuCION3vdfUMoiuJRChzFsbhLbd/9ugITUIARGYxC0Hn/SxddJ+nmArhhRPczznenBkhQGUWbX7BjxNHMCc8ihZBJkc+XmWhgbbI6JLEpE8dr+HqHSaAOfyw3Tjeb73A6WDxxczPoWpkyDH4UUvsFmirIHK3bLDLoP6P90GOEJXwW/z3HmO9B8xsE10u1sRQtPUwKZHBwLC4JtNWYGUEwo4qA== 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: This test verifies that a hugepage, used as a user buffer for DIO operations, is correctly freed upon unmapping. To test this, we read the count of free hugepages before and after the mmap, DIO, and munmap operations, then check if the free hugepage count is the same. Reading free hugepages before the test was removed by commit 0268d4579901 ('selftests: hugetlb_dio: check for initial conditions to skip at the start'), causing the test to always fail. This patch adds back reading the free hugepages before starting the test. With this patch, the tests are now passing. Test Results without this patch ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 1 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 3 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0 Test results with this patch. ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 1 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 3 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0 Fixes: 0268d4579901 ("selftests: hugetlb_dio: check for initial conditions to skip in the start") Signed-off-by: Donet Tom --- tools/testing/selftests/mm/hugetlb_dio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c index 60001c142ce9..432d5af15e66 100644 --- a/tools/testing/selftests/mm/hugetlb_dio.c +++ b/tools/testing/selftests/mm/hugetlb_dio.c @@ -44,6 +44,13 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n"); + /* Get the free huge pages before allocation */ + free_hpage_b = get_free_hugepages(); + if (free_hpage_b == 0) { + close(fd); + ksft_exit_skip("No free hugepage, exiting!\n"); + } + /* Allocate a hugetlb page */ orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer == MAP_FAILED) {