From patchwork Wed Jan 31 14:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13539499 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 65D3DC47258 for ; Wed, 31 Jan 2024 14:05:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5625A6B00A1; Wed, 31 Jan 2024 09:05:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EBA76B00A2; Wed, 31 Jan 2024 09:05:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33D9A6B00A3; Wed, 31 Jan 2024 09:05:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1BED66B00A1 for ; Wed, 31 Jan 2024 09:05:44 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D3A861C1094 for ; Wed, 31 Jan 2024 14:05:43 +0000 (UTC) X-FDA: 81739779366.28.AF56CE8 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf14.hostedemail.com (Postfix) with ESMTP id 0B49410002C for ; Wed, 31 Jan 2024 14:05:41 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=3f+BaCVH; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf14.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706709942; 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=VFQwNGH05nCWaWpiZ45L92UGGZtWmAJBYHuhIMWMRD8=; b=wn1p7kaYt7VM6qN/4yfp/4af5IMu9xV72SNygiki6Dxt127+WztMXj5zsEv0/hqh5oF7vq /Wq8bZu+dam4vo8ICwpTqVzsWWEJvP6c9M1htP0kCp0MWZ36tmEUYBv/3B1MYtvkLhRVCX E4AN6AkFTG+xR/5xe3ls3adBGHfILwo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=3f+BaCVH; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf14.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706709942; a=rsa-sha256; cv=none; b=NsdnxzhBPRvgVgg9eetr4IUKC6ljkX9pZxX19Hkmy+TsEr7pu1XLv+bAuTHzfs2wPUzL+d WV1X7mDX6pGHtVhfIjSreEZilgAnwcNsfc53WkTtw+Hkxo5bgdzCOdo2Wcc077sFHgzQo7 2R6kw6py3L0YwRxPF4krvgmFMCg8u7k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706709940; bh=oFf1K2mfeMM9jrFoVwJzVfcP3pmuBYS1DF+vRN85jqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3f+BaCVH11VOm4tY8FHrLyoUrRQ7PU62w2wjDp5L7h/Jdn4OXG4mCaiCuKGRLr7tb RPpfVphdNKWzhuFSWjW1iJtzU4WlOyl7f9eNoZI9GtjICj7Eh3l6aTIgqfMllXCJe0 eI9UrT1cjnQIG3FCqyqOflwg7Nx09sTv1sQbMfV8DeRyEGr6ZHHHDhWTAdlUUUAvyP yOCM0hF1ZMN6uXQgiCZkJLmsQ3/sYAHz0P91TtCaGz8YT0KL+OyugYk+WJAbHpgl8J 57df//bvcexHayvkMJQFhPIgQMS5VBA4VKOWZRpExyZy2XfgLXS8AwfMjcIB5M45Fc 5iU2blGJ+E+nw== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 438843782081; Wed, 31 Jan 2024 14:05:39 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/12] selftests/mm: transhuge-stress: conform to TAP format output Date: Wed, 31 Jan 2024 19:05:21 +0500 Message-ID: <20240131140528.320252-11-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240131140528.320252-1-usama.anjum@collabora.com> References: <20240131140528.320252-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0B49410002C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: q6bhpf6xmb6iii3f19azmtfz3s9ogrnk X-HE-Tag: 1706709941-628828 X-HE-Meta: U2FsdGVkX18srxE9VSJ/SghzDTg0rE7gTUInfiFn2YNmXsLZKxrJtuG1saciricXFEh2Ub56b8wbe6CJGaBpy2I58SKwlPca0NoMwBZPqGwuS3cI9I2O7HT+UEIYm5LyNHaAndhvDQpcczSq+gnTBwF2mExb+/HcDuLMeanKQFfAgcY8xBrX0nNrn6/ycQqFo6ngbWNN5irdqBIWadeah2vkpLvWwVv7oi8PMvtCsu16Td7R2G1ohxNbZ52XT6gkRyqyWImdOX4OHqZNXhNYSzhpw+9TW3fnc6V6/PiFNYYVv9GBQnv3qQsYcWdVvUNfQG+AYReLEQ/FvWM0DApnMO2JEuORNtFxPXOfLR1g62DMq79IrotzDoAgQNDB/huFHiPJBCkJcTTUK6oRIt1hZhpNDEtqobosyOTcKxsTKGYjPUYfd2xA4eY2UDBP2sDpYZdDHukt/nwOGfzBzSiwQBrl/osIJHq725DuQENbKPfaowIWd0N6nw8sS0cZOdCeuVt/DLNq5ClxWXSHPdeVPbq1r8vIWsPKnaKveb4PvfQg8tE1nKCtTKhaDBzMJtLCAL5BIHWV8k5Sla2nO5ezgGsr/5j6nSzm/7wmsYMZ/rOlnhsu7dsacsAt9qBy058DbAZb35Z5aWAuPUVFHwT9LddoTwmsNl2IL8kvx3xbIWIGNRWOYeUfM3KrYMWcTiqpju78MoSREBICiH4DoQZsxiSrVmsfZmIGjF08NVBLzXBdGn1rs6st+kILeojLdrOr3IdqctbO4FSfjSMY3mP3wCThsiznNHjrvFeWgUy5K5bm6+7jcDj7ezjY++9nX8nC+ViT1exh/wxGCCi+Wo1RRAvfMpafBobo6YAd/2Pzd0Q0haRkvceO37SysVszvRXZuj5oVgslxqUKRBwo9ROK3sPxvEmYoyJ9sepNl8DzUO6/8oafUab3erV5pXSg0g60oB9brXjIEcqkjvSxJHI auiv6bsd ia68t/WXwdubPoNZhD8Ye6p5acDfH2ZI5cS1d4txWSxyzrv+df9o+vnlb6rOrxOhoHJbO8nvM/onZRp34Idj7HzdI+R21CNe60iBQ7d6+zlzTBkdy+khDiNg8X++tZoA10/QaOlCatJ556D9kOLkwOmbYHPzg2rnyWKy7L+Zu/lJNdFqN5/oA4URGv8VjxOn19LLcFLRnzvgQaspk427XooHDgpygIsotHFyYpQraYTjanL0RswMgA9Nmtg== 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: Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/transhuge-stress.c | 36 +++++++++++-------- tools/testing/selftests/mm/vm_util.c | 6 ++-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c index c61fb9350b8c2..68201192e37c8 100644 --- a/tools/testing/selftests/mm/transhuge-stress.c +++ b/tools/testing/selftests/mm/transhuge-stress.c @@ -16,6 +16,7 @@ #include #include #include "vm_util.h" +#include "../kselftest.h" int backing_fd = -1; int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE; @@ -34,6 +35,8 @@ int main(int argc, char **argv) int pagemap_fd; int duration = 0; + ksft_print_header(); + ram = sysconf(_SC_PHYS_PAGES); if (ram > SIZE_MAX / psize() / 4) ram = SIZE_MAX / 4; @@ -43,7 +46,8 @@ int main(int argc, char **argv) while (++i < argc) { if (!strcmp(argv[i], "-h")) - errx(1, "usage: %s [-f ] [-d ] [size in MiB]", argv[0]); + ksft_exit_fail_msg("usage: %s [-f ] [-d ] [size in MiB]\n", + argv[0]); else if (!strcmp(argv[i], "-f")) name = argv[++i]; else if (!strcmp(argv[i], "-d")) @@ -52,10 +56,12 @@ int main(int argc, char **argv) len = atoll(argv[i]) << 20; } + ksft_set_plan(1); + if (name) { backing_fd = open(name, O_RDWR); if (backing_fd == -1) - errx(2, "open %s", name); + ksft_exit_fail_msg("open %s\n", name); mmap_flags = MAP_SHARED; } @@ -65,21 +71,21 @@ int main(int argc, char **argv) pagemap_fd = open("/proc/self/pagemap", O_RDONLY); if (pagemap_fd < 0) - err(2, "open pagemap"); + ksft_exit_fail_msg("open pagemap\n"); len -= len % HPAGE_SIZE; ptr = mmap(NULL, len + HPAGE_SIZE, PROT_RW, mmap_flags, backing_fd, 0); if (ptr == MAP_FAILED) - err(2, "initial mmap"); + ksft_exit_fail_msg("initial mmap"); ptr += HPAGE_SIZE - (uintptr_t)ptr % HPAGE_SIZE; if (madvise(ptr, len, MADV_HUGEPAGE)) - err(2, "MADV_HUGEPAGE"); + ksft_exit_fail_msg("MADV_HUGEPAGE"); map_len = ram >> (HPAGE_SHIFT - 1); map = malloc(map_len); if (!map) - errx(2, "map malloc"); + ksft_exit_fail_msg("map malloc\n"); clock_gettime(CLOCK_MONOTONIC, &start); @@ -103,7 +109,7 @@ int main(int argc, char **argv) if (idx >= map_len) { map = realloc(map, idx + 1); if (!map) - errx(2, "map realloc"); + ksft_exit_fail_msg("map realloc\n"); memset(map + map_len, 0, idx + 1 - map_len); map_len = idx + 1; } @@ -114,17 +120,19 @@ int main(int argc, char **argv) /* split transhuge page, keep last page */ if (madvise(p, HPAGE_SIZE - psize(), MADV_DONTNEED)) - err(2, "MADV_DONTNEED"); + ksft_exit_fail_msg("MADV_DONTNEED"); } clock_gettime(CLOCK_MONOTONIC, &b); s = b.tv_sec - a.tv_sec + (b.tv_nsec - a.tv_nsec) / 1000000000.; - warnx("%.3f s/loop, %.3f ms/page, %10.3f MiB/s\t" - "%4d succeed, %4d failed, %4d different pages", - s, s * 1000 / (len >> HPAGE_SHIFT), len / s / (1 << 20), - nr_succeed, nr_failed, nr_pages); + ksft_print_msg("%.3f s/loop, %.3f ms/page, %10.3f MiB/s\t" + "%4d succeed, %4d failed, %4d different pages\n", + s, s * 1000 / (len >> HPAGE_SHIFT), len / s / (1 << 20), + nr_succeed, nr_failed, nr_pages); - if (duration > 0 && b.tv_sec - start.tv_sec >= duration) - return 0; + if (duration > 0 && b.tv_sec - start.tv_sec >= duration) { + ksft_test_result_pass("Completed\n"); + ksft_finished(); + } } } diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c index 05736c615734f..5a62530da3b56 100644 --- a/tools/testing/selftests/mm/vm_util.c +++ b/tools/testing/selftests/mm/vm_util.c @@ -232,17 +232,17 @@ int64_t allocate_transhuge(void *ptr, int pagemap_fd) if (mmap(ptr, HPAGE_SIZE, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0) != ptr) - errx(2, "mmap transhuge"); + ksft_exit_fail_msg("mmap transhuge\n"); if (madvise(ptr, HPAGE_SIZE, MADV_HUGEPAGE)) - err(2, "MADV_HUGEPAGE"); + ksft_exit_fail_msg("MADV_HUGEPAGE\n"); /* allocate transparent huge page */ *(volatile void **)ptr = ptr; if (pread(pagemap_fd, ent, sizeof(ent), (uintptr_t)ptr >> (pshift() - 3)) != sizeof(ent)) - err(2, "read pagemap"); + ksft_exit_fail_msg("read pagemap\n"); if (PAGEMAP_PRESENT(ent[0]) && PAGEMAP_PRESENT(ent[1]) && PAGEMAP_PFN(ent[0]) + 1 == PAGEMAP_PFN(ent[1]) &&