From patchwork Fri Sep 8 16:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13377650 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 72540EE8019 for ; Fri, 8 Sep 2023 16:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B10E16B00DC; Fri, 8 Sep 2023 12:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A99DD6B00DD; Fri, 8 Sep 2023 12:03:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 961506B00DE; Fri, 8 Sep 2023 12:03:38 -0400 (EDT) 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 82E8B6B00DC for ; Fri, 8 Sep 2023 12:03:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5A565B46B3 for ; Fri, 8 Sep 2023 16:03:38 +0000 (UTC) X-FDA: 81213900516.05.8B42D2A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 529CF20034 for ; Fri, 8 Sep 2023 16:03:36 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIvZoT+Q; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694189016; 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=Sg3a7A43hEMYTaK7v8cHzLS7F7QYnrJJZ8kuLsBU9fQ=; b=gqL648PBoSQnDitZXZFPF2zWUH9F5lPiqCLsRXTxzdesDdN7CJ3eiryM5fAnK1vIirAvw7 Zl8BVCPCdgLGQPsTYB/3GHQGBDwCretFUUBo2qBHS7Cmu/SFOHkxSunKyElVFhPLoL5v1W y72SxclKYnFfXZnyiPK7BEaYwLdNcpE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIvZoT+Q; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694189016; a=rsa-sha256; cv=none; b=XCMNlujhvV1A5VX1uDMNdZokJUK5Z3EHGehmvazuHiQO0AWYT1yt+MBmO/oWpjW/CmlOAM V1XwynzLcNwF07zIgYKQ3FXdV2qOl30V6EyzzhhsZzgwdugUUhPme2SPYmyB5rNqD2C3rj BteEbsWcMkHyg9KpVKaytKyHAsR2vek= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694189015; 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=Sg3a7A43hEMYTaK7v8cHzLS7F7QYnrJJZ8kuLsBU9fQ=; b=hIvZoT+QnLhFbnGa+QFcU7D517LIEINxQcUw/kTBAa3qwjYQMKBLPVw51+JYhVZtygKKBr FW/nnVv0Kz4Nj1VQpTFlqrf1VcTQcOQSL+/duLs3WQKUwUPOf1ciOiIwqIRRLNio2ocG6T Dg8S+skg8G++aDbsPwjaif+ccg0nYO4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-15-IdWsmPpvOLu2t5V-Jpa52w-1; Fri, 08 Sep 2023 12:03:30 -0400 X-MC-Unique: IdWsmPpvOLu2t5V-Jpa52w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 6E4CF916C82; Fri, 8 Sep 2023 16:03:29 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1A7463F6C; Fri, 8 Sep 2023 16:03:27 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Christian Brauner , David Hildenbrand , John Hubbard , Jeff Layton , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] iov_iter: Add kunit tests and fix iov_iter_extract_pages() Date: Fri, 8 Sep 2023 17:03:19 +0100 Message-ID: <20230908160322.1714302-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 529CF20034 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: itgogbpa768gftfrx3b8myoroeqp1dj9 X-HE-Tag: 1694189016-283745 X-HE-Meta: U2FsdGVkX19lFdO9zxKAbVWn1X5mwrwyJjZyMu8wBO02CwFLJkCX+DCy6+xIcb7bNJzi1vmg5dU13EN7bTaRpUfU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jLM2hGCmHjfsWSAAzNIPLM+wwJB3ys86+u3oad07JVSjkeLBQCD0ntxqE8wNhJSWwtj62dZG5xAiSb3 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, Christoph, Al, Here are two patches to add some kunit tests for the iov_iter stuff and a patch to fix a couple of bugs found by these tests. It's by no means comprehensive, but it does at least test the basic copy_to_iter(), copy_from_iter() and iov_iter_extract_pages() for ITER_KVEC, ITER_BVEC and ITER_XARRAY. I've left ITER_UBUF and ITER_IOVEC untested for now as they require userspace VM interaction and I'm not sure if that's possible under kunit tests. I've also left ITER_DISCARD for the moment as that does nothing and can't be extracted. The kunit tests should also perhaps be using folios rather than pages, but for the moment I'm using pages because I'm using vmap() and also iov_iter_extract_pages() doesn't yet have a folio equivalent. I've pushed the patches here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-fixes David David Howells (3): iov_iter: Fix iov_iter_extract_pages() iov_iter: Kunit tests for copying to/from an iterator iov_iter: Kunit tests for page extraction lib/Kconfig.debug | 11 + lib/Makefile | 1 + lib/iov_iter.c | 30 +- lib/kunit_iov_iter.c | 777 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 804 insertions(+), 15 deletions(-) create mode 100644 lib/kunit_iov_iter.c