From patchwork Tue Jan 14 08:08:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Kasireddy X-Patchwork-Id: 13938514 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 43B9EC02184 for ; Tue, 14 Jan 2025 08:38:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB7E7280002; Tue, 14 Jan 2025 03:38:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C65C46B008A; Tue, 14 Jan 2025 03:38:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2DBE280002; Tue, 14 Jan 2025 03:38:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 98DD56B0089 for ; Tue, 14 Jan 2025 03:38:17 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 428451A0813 for ; Tue, 14 Jan 2025 08:38:17 +0000 (UTC) X-FDA: 83005405434.27.3E442E1 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by imf16.hostedemail.com (Postfix) with ESMTP id 2CEEB180002 for ; Tue, 14 Jan 2025 08:38:15 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iHKwPOat; spf=pass (imf16.hostedemail.com: domain of vivek.kasireddy@intel.com designates 192.198.163.18 as permitted sender) smtp.mailfrom=vivek.kasireddy@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736843895; 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=1ykSolZ+bOZ3EXHEtPKwmtW1jxO/+EOCqCjzkP8S278=; b=f+nApQcWxfqLV1nzvXhc80YaXmlsgnxDeEIyjhETowIdhRi7OfJAa6QenGVU+yKTuRq8kD eKldb4/KS8Qtx0lgaQjTm8BxIAwou8iDhn9Oz4GBUVnhPoc8nzcUsaiJo4FpmmIdL9Onlq tO8YUumFnwdlavFcKMFg5eVU9iOiiWM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iHKwPOat; spf=pass (imf16.hostedemail.com: domain of vivek.kasireddy@intel.com designates 192.198.163.18 as permitted sender) smtp.mailfrom=vivek.kasireddy@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736843895; a=rsa-sha256; cv=none; b=05MWBvwU/ctsN40GyBCHIqyVt8ZyzVC1fDTNxRLULxOevrRlGl7K9PXJ6f5qeFOd+/c2yv OHOSC/A8VJ69e5hGwBRYiE3k9VyAAszYrGv/ktExL4sJcnpgT28AdtPKiULrfnpKuqtwwy 5VrlEaBsYycJCVuagUN/6IuBmJl1SYo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736843895; x=1768379895; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SkjdjBC9EFZ/ZMbL21szG1Ln9nKeFx8PXdK5k9949F8=; b=iHKwPOat4ew23C7MiO5eRSIIyVPPjE7Vrre7veGxg1B/E749IHAY1JD8 dkeHNKMgDNovrXQjfnF9meJnhSeZvmD8aU7XZvBdZYT9H3xGiZ4g4U0Al X5mCBQBYvBug8ERjWANF6EgdnWn7MGZ4ArS7fzf3g2NYz2nDbPy4CAQiA o36I7jrU7XI12zlWKJnum6xPqrRKsaPzKNF+U+gSdKRq3dgWG4jmEoAxj QdyVt4YSoregk0jBhdjPinapWYLerNJmFoUna5OxiMb1c1h3CoHf6dzpQ XMQM5xQQ++WZozWcPDeoVm2mqJfXspn7aVZ4IR+zdPCmQEXX2URClZtpc w==; X-CSE-ConnectionGUID: KUqzkhqvQkOs3k4INPXAgw== X-CSE-MsgGUID: TTBay2XBQV+3Q1zwnUnbBQ== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="36418231" X-IronPort-AV: E=Sophos;i="6.12,313,1728975600"; d="scan'208";a="36418231" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2025 00:38:10 -0800 X-CSE-ConnectionGUID: MIBaAp+kQJWMZHMHfvrFGA== X-CSE-MsgGUID: NJYwNdkURa+kz9q+3dgLXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,313,1728975600"; d="scan'208";a="105251580" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2025 00:38:10 -0800 From: Vivek Kasireddy To: dri-devel@lists.freedesktop.org, linux-mm@kvack.org Cc: Vivek Kasireddy , Gerd Hoffmann , Steve Sistare , Muchun Song , David Hildenbrand , Andrew Morton Subject: [PATCH v2 2/2] selftests/udmabuf: add a test to pin first before writing to memfd Date: Tue, 14 Jan 2025 00:08:01 -0800 Message-ID: <20250114080927.2616684-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114080927.2616684-1-vivek.kasireddy@intel.com> References: <20250114080927.2616684-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2CEEB180002 X-Rspamd-Server: rspam12 X-Stat-Signature: zqynwxh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z8Xk9yn4wVFjmiq3a+O7vSkzeKCoZZMcAY5HH8QI7zagDUXiTb7efs4OkhC12wz7HG/d+3J7xkOj9ZpAdIB2VW+76Z2LEnYfSnYPoXzEsgEVodBdtuzx1EvDIAhSJocX8+Q6ekQRlqg574tUMqowZsLhHtO6KY5UzaP+8qKgjlofn9Q/fTK1W6Ji2iCKZT1QjIzWYdBrf6z0mwGIcLxfk5ISd9HRzWfz9X34OBuLS1GWNDcpcI5sBhxEQy14SItfoCXzw61sC9EsDCdXg1BQhIMVdmNHdirGAqlyjI6/wXjoYxsr X-Bogosity: Ham, tests=bogofilter, spamicity=0.059667, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Unlike the existing tests, this new test will create a memfd (backed by hugetlb) and pin the folios in it (a small subset) before writing/ populating it with data. This is a valid use-case that invokes the memfd_alloc_folio() kernel API and is expected to work unless there aren't enough hugetlb folios to satisfy the allocation needs. Cc: Gerd Hoffmann Cc: Steve Sistare Cc: Muchun Song Cc: David Hildenbrand Cc: Andrew Morton Signed-off-by: Vivek Kasireddy --- .../selftests/drivers/dma-buf/udmabuf.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c index 6062723a172e..77aa2897e79f 100644 --- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c +++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) void *addr1, *addr2; ksft_print_header(); - ksft_set_plan(6); + ksft_set_plan(7); devfd = open("/dev/udmabuf", O_RDWR); if (devfd < 0) { @@ -248,6 +248,24 @@ int main(int argc, char *argv[]) else ksft_test_result_pass("%s: [PASS,test-6]\n", TEST_PREFIX); + close(buf); + close(memfd); + + /* same test as above but we pin first before writing to memfd */ + page_size = getpagesize() * 512; /* 2 MB */ + size = MEMFD_SIZE * page_size; + memfd = create_memfd_with_seals(size, true); + buf = create_udmabuf_list(devfd, memfd, size); + addr2 = mmap_fd(buf, NUM_PAGES * NUM_ENTRIES * getpagesize()); + addr1 = mmap_fd(memfd, size); + write_to_memfd(addr1, size, 'a'); + write_to_memfd(addr1, size, 'b'); + ret = compare_chunks(addr1, addr2, size); + if (ret < 0) + ksft_test_result_fail("%s: [FAIL,test-7]\n", TEST_PREFIX); + else + ksft_test_result_pass("%s: [PASS,test-7]\n", TEST_PREFIX); + close(buf); close(memfd); close(devfd);