linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: dhowells@redhat.com, Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jens Axboe <axboe@kernel.dk>, "Christoph Hellwig" <hch@lst.de>,
	Christian Brauner <christian@brauner.io>,
	"Matthew Wilcox" <willy@infradead.org>,
	Brendan Higgins <brendanhiggins@google.com>,
	David Gow <davidgow@google.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"kunit-dev@googlegroups.com" <kunit-dev@googlegroups.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christian Brauner <brauner@kernel.org>,
	"David Hildenbrand" <david@redhat.com>,
	John Hubbard <jhubbard@nvidia.com>
Subject: Re: [RFC PATCH 9/9] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC
Date: Fri, 15 Sep 2023 14:24:50 +0100	[thread overview]
Message-ID: <3629598.1694784290@warthog.procyon.org.uk> (raw)
In-Reply-To: <5017b9fa177f4deaa5d481a5d8914ab4@AcuMS.aculab.com>

David Laight <David.Laight@ACULAB.COM> wrote:

> You could also just not do the copy!
> Although you need (say) asm volatile("\n",:::"memory") to
> stop it all being completely optimised away.
> That might show up a difference in the 'out_of_line' test
> where 15% on top on the data copies is massive - it may be
> that the data cache behaviour is very different for the
> two cases.

I tried using the following as the load:

	volatile unsigned long foo;

	static __always_inline
	size_t idle_user_iter(void __user *iter_from, size_t progress,
			      size_t len, void *to, void *priv2)
	{
		nop();
		nop();
		foo += (unsigned long)iter_from;
		foo += (unsigned long)len;
		foo += (unsigned long)to + progress;
		nop();
		nop();
		return 0;
	}

	static __always_inline
	size_t idle_kernel_iter(void *iter_from, size_t progress,
				size_t len, void *to, void *priv2)
	{
		nop();
		nop();
		foo += (unsigned long)iter_from;
		foo += (unsigned long)len;
		foo += (unsigned long)to + progress;
		nop();
		nop();
		return 0;
	}

	size_t iov_iter_idle(struct iov_iter *iter, size_t len, void *priv)
	{
		return iterate_and_advance(iter, len, priv,
					   idle_user_iter, idle_kernel_iter);
	}
	EXPORT_SYMBOL(iov_iter_idle);

adding various things into a volatile variable to prevent the optimiser from
discarding the calculations.

I get:

 iov_kunit_benchmark_bvec: avg 395 uS, stddev 46 uS
 iov_kunit_benchmark_bvec: avg 397 uS, stddev 38 uS
 iov_kunit_benchmark_bvec: avg 411 uS, stddev 57 uS
 iov_kunit_benchmark_bvec_outofline: avg 781 uS, stddev 5 uS
 iov_kunit_benchmark_bvec_outofline: avg 781 uS, stddev 6 uS
 iov_kunit_benchmark_bvec_outofline: avg 781 uS, stddev 7 uS
 iov_kunit_benchmark_bvec_split: avg 3599 uS, stddev 737 uS
 iov_kunit_benchmark_bvec_split: avg 3664 uS, stddev 838 uS
 iov_kunit_benchmark_bvec_split: avg 3669 uS, stddev 875 uS
 iov_kunit_benchmark_iovec: avg 472 uS, stddev 17 uS
 iov_kunit_benchmark_iovec: avg 506 uS, stddev 59 uS
 iov_kunit_benchmark_iovec: avg 525 uS, stddev 14 uS
 iov_kunit_benchmark_kvec: avg 421 uS, stddev 73 uS
 iov_kunit_benchmark_kvec: avg 428 uS, stddev 68 uS
 iov_kunit_benchmark_kvec: avg 469 uS, stddev 75 uS
 iov_kunit_benchmark_ubuf: avg 1052 uS, stddev 6 uS
 iov_kunit_benchmark_ubuf: avg 1168 uS, stddev 8 uS
 iov_kunit_benchmark_ubuf: avg 1168 uS, stddev 9 uS
 iov_kunit_benchmark_xarray: avg 680 uS, stddev 11 uS
 iov_kunit_benchmark_xarray: avg 682 uS, stddev 20 uS
 iov_kunit_benchmark_xarray: avg 686 uS, stddev 46 uS
 iov_kunit_benchmark_xarray_outofline: avg 1340 uS, stddev 34 uS
 iov_kunit_benchmark_xarray_outofline: avg 1358 uS, stddev 12 uS
 iov_kunit_benchmark_xarray_outofline: avg 1358 uS, stddev 15 uS

where I made the iovec and kvec tests split their buffers into PAGE_SIZE
segments and the ubuf test issue an iteration per PAGE_SIZE'd chunk.
Splitting kvec into just 8 results in the iteration taking <1uS.

The bvec_split test is doing a kmalloc() per 256 pages inside of the loop,
which is why that takes quite a long time.

David



  parent reply	other threads:[~2023-09-15 13:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 22:15 [RFC PATCH 0/9] iov_iter: kunit: Cleanup, abstraction and more tests David Howells
2023-09-14 22:15 ` [RFC PATCH 1/9] iov_iter: Fix some checkpatch complaints in kunit tests David Howells
2023-09-14 22:15 ` [RFC PATCH 2/9] iov_iter: Consolidate some of the repeated code into helpers David Howells
2023-09-14 22:15 ` [RFC PATCH 3/9] iov_iter: Consolidate the test vector struct in the kunit tests David Howells
2023-09-14 22:15 ` [RFC PATCH 4/9] iov_iter: Consolidate bvec pattern checking David Howells
2023-09-14 22:15 ` [RFC PATCH 5/9] iov_iter: Create a function to prepare userspace VM for UBUF/IOVEC tests David Howells
2023-09-14 22:15 ` [RFC PATCH 6/9] iov_iter: Add copy kunit tests for ITER_UBUF and ITER_IOVEC David Howells
2023-09-14 22:15 ` [RFC PATCH 7/9] iov_iter: Add extract " David Howells
2023-09-14 22:15 ` [RFC PATCH 8/9] iov_iter: Add benchmarking kunit tests David Howells
2023-09-14 22:15 ` [RFC PATCH 9/9] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC David Howells
2023-09-15  7:09   ` David Laight
2023-09-15 10:10   ` David Howells
2023-09-15 10:51     ` David Laight
2023-09-15 11:23     ` David Howells
2023-09-15 12:10       ` David Laight
2023-09-15 12:36       ` David Howells
2023-09-15 13:08         ` David Laight
2023-09-15 13:24     ` David Howells [this message]
2023-09-15 12:19   ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3629598.1694784290@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=brendanhiggins@google.com \
    --cc=christian@brauner.io \
    --cc=david@redhat.com \
    --cc=davidgow@google.com \
    --cc=hch@lst.de \
    --cc=jhubbard@nvidia.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).