From patchwork Wed Sep 20 13:03:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13392741 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 DB1F0CE79CF for ; Wed, 20 Sep 2023 13:04:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46DCA6B0092; Wed, 20 Sep 2023 09:04:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F5C66B009B; Wed, 20 Sep 2023 09:04:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26F196B009C; Wed, 20 Sep 2023 09:04:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0E7486B0092 for ; Wed, 20 Sep 2023 09:04:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 872AB40C5D for ; Wed, 20 Sep 2023 13:04:36 +0000 (UTC) X-FDA: 81256994952.25.00624A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id A5BDC12008E for ; Wed, 20 Sep 2023 13:04:14 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LbCcUnir; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695215054; 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:references:dkim-signature; bh=3xEcAxdVo0QbYUsmze3l+A9lWAZy7tCqYqfeJQv6WXY=; b=AKfwyDP2bIo2tPp8mY19tBca0xtnvNNHYOTlKoKa+3skl0GF/LPRF1ObAQ9tNGeROK3ypn XtH/odeiphb4ehdijMmLITeD18ymLmaumWbpGRbIKJ88sr7giLH1eAFgIYach72lTWA2o1 wRWNHNo0ePyTpa8R5YgS7C+vW5OJDns= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695215054; a=rsa-sha256; cv=none; b=58Hrx7K2rKXBJJYItVJfN6k9KKxiY75U44g44TBgY7z0brAsY2WaRO6XhgFfI3D8RTsmc/ tx5RhUkl5KMn2VFOmqwx4S2R+3/1XYDKoXo+pia8+bNF5EHkFRbXz8qOrX1i8Q6ObeWjiV cZuKpsxgqN3BRD0DplRPJA3erJZA9Q8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LbCcUnir; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695215054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3xEcAxdVo0QbYUsmze3l+A9lWAZy7tCqYqfeJQv6WXY=; b=LbCcUnirnTFMKJ6NzaUxNqi97EN6uDPfeBMl8vlEOJC5dSrUE0OGvKCVAquHs1b3F4Sq7K qBBrCDbJV4oLZuFUbbnKdG34/bygZRbuagiiNd78cJOEv6uQnBpBS0Cyq9Bo3kdkMTHkQ4 eNOA6TeWnQHamZ63i8LZr+lVxNc8krY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-602-mff24TgoP1-vGnBtTIgghw-1; Wed, 20 Sep 2023 09:04:08 -0400 X-MC-Unique: mff24TgoP1-vGnBtTIgghw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A1BA03812592; Wed, 20 Sep 2023 13:04:07 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB7DA10F1BE7; Wed, 20 Sep 2023 13:04:03 +0000 (UTC) From: David Howells To: Jens Axboe Cc: David Howells , Al Viro , Linus Torvalds , Christoph Hellwig , Christian Brauner , David Laight , Matthew Wilcox , Brendan Higgins , David Gow , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 0/9] iov_iter: kunit: Cleanup, abstraction and more tests Date: Wed, 20 Sep 2023 14:03:51 +0100 Message-ID: <20230920130400.203330-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: A5BDC12008E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: m1uw8wbdos4jasawaqrct6n4rfctpeqw X-HE-Tag: 1695215054-831851 X-HE-Meta: U2FsdGVkX18fAaHh3hLKgyWAe+BSJcsQtxTlYGToTPs/hT3a99huB9YI//VvAat/93ZKT6xw477WdJvY4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29Frm75nneKCOoI74Z6gblVWq4qua6DrYFOmdToP/srlp3zdDc5PtYUYl0uOTokZ+3YiojRefCF1U3jL9aB1jdnvDmvgkEA== 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: Hi Jens, Can you consider taking this through the block tree? These patches make some changes to the kunit tests previously added for iov_iter testing, in particular adding testing of UBUF/IOVEC iterators and some benchmarking: (1) Clean up a couple of checkpatch style complaints. (2) Consolidate some repeated bits of code into helper functions and use the same struct to represent straight offset/address ranges and partial page lists. (3) Add a function to set up a userspace VM, attach the VM to the kunit testing thread, create an anonymous file, stuff some pages into the file and map the file into the VM to act as a buffer that can be used with UBUF/IOVEC iterators. I map an anonymous file with pages attached rather than using MAP_ANON so that I can check the pages obtained from iov_iter_extract_pages() without worrying about them changing due to swap, migrate, etc.. [?] Is this the best way to do things? Mirroring execve, it requires a number of extra core symbols to be exported. Should this be done in the core code? (4) Add tests for copying into and out of UBUF and IOVEC iterators. (5) Add tests for extracting pages from UBUF and IOVEC iterators. (6) Add tests to benchmark copying 256MiB to UBUF, IOVEC, KVEC, BVEC and XARRAY iterators. (7) Add a test to benchmark copying 256MiB through dynamically allocated 256-page bvecs to simulate bio construction. Example benchmarks output: iov_kunit_benchmark_ubuf: avg 4474 uS, stddev 1340 uS iov_kunit_benchmark_iovec: avg 6619 uS, stddev 23 uS iov_kunit_benchmark_kvec: avg 2672 uS, stddev 14 uS iov_kunit_benchmark_bvec: avg 3189 uS, stddev 19 uS iov_kunit_benchmark_bvec_split: avg 3403 uS, stddev 8 uS iov_kunit_benchmark_xarray: avg 3709 uS, stddev 7 uS I've pushed the patches here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-kunit David Changes ======= ver #2) - Use MAP_ANON to make the user buffer if we don't want a list of pages. - KUNIT_ASSERT_NOT_ERR_OR_NULL() doesn't like __user pointers as the condition, so cast. - Make the UBUF benchmark loop, doing an iterator per page so that the overhead from the iterator code is not negligible. - Make the KVEC benchmark use an iovec per page so that the iteration is not not negligible. - Switch the benchmarking to use copy_from_iter() so that only a single page is needed in the userspace buffer (as it can be shared R/O), not 256MiB's worth. Link: https://lore.kernel.org/r/20230914221526.3153402-1-dhowells@redhat.com/ # v1 David Howells (9): iov_iter: Fix some checkpatch complaints in kunit tests iov_iter: Consolidate some of the repeated code into helpers iov_iter: Consolidate the test vector struct in the kunit tests iov_iter: Consolidate bvec pattern checking iov_iter: Create a function to prepare userspace VM for UBUF/IOVEC tests iov_iter: Add copy kunit tests for ITER_UBUF and ITER_IOVEC iov_iter: Add extract kunit tests for ITER_UBUF and ITER_IOVEC iov_iter: Add benchmarking kunit tests iov_iter: Add benchmarking kunit tests for UBUF/IOVEC arch/loongarch/include/asm/page.h | 1 + arch/s390/kernel/vdso.c | 1 + fs/anon_inodes.c | 1 + kernel/fork.c | 2 + lib/kunit_iov_iter.c | 1241 ++++++++++++++++++++++++----- mm/mmap.c | 1 + mm/util.c | 3 + 7 files changed, 1058 insertions(+), 192 deletions(-)