From mboxrd@z Thu Jan 1 00:00:00 1970 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 98BC0EE6457 for ; Fri, 15 Sep 2023 13:25:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDA376B036A; Fri, 15 Sep 2023 09:25:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D63136B036C; Fri, 15 Sep 2023 09:25:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C03686B036D; Fri, 15 Sep 2023 09:25:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ACBA36B036A for ; Fri, 15 Sep 2023 09:25:01 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6F2901201D6 for ; Fri, 15 Sep 2023 13:25:01 +0000 (UTC) X-FDA: 81238902402.21.76B09B5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 7D6231A000B for ; Fri, 15 Sep 2023 13:24:59 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AiNDRyDs; spf=pass (imf19.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=1694784299; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YwX0LvGe2IzI2EOEiWJxA7uUIanGLX6c6iCFRhbWEYk=; b=7WJjxOmnVE5twwFTrDioAtQHDULpPLx2zRGS6nS6NsFow9cp2iFWkG15bNfLdR2OIS+y5V obW+uezy8p4/S35WWIH81zjuAqaW3AqwG3PlDJGNDZHadD2jQqjJSftXWUB7k/iGbre5zw cW5p0HX9PsHduRNuQpw3zyFtspYNIeo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694784299; a=rsa-sha256; cv=none; b=NUOsY0r1hFdUIGEQ271ScF/iE82myCTJ4+siSXCSdfT2JZbo3IbGhmIlKCohogC+i9zV+C Yzm4bUTPJtxGrW0DlnuuTW9IMNYYRjSVyYZLSooggviJhR2ZkuwKRnlmtUdvhGKHPYkWZC n+PeEM4A3fwHAGc7MeYXmtsL6g4PiHE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AiNDRyDs; spf=pass (imf19.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=1694784298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YwX0LvGe2IzI2EOEiWJxA7uUIanGLX6c6iCFRhbWEYk=; b=AiNDRyDsRmzTUyZQbEi8ZHf1fALxQTajCPouAVo5o/1bIU7P3XPI9UUWYaNfRWMiXGQwTl FWLurlx32SQx0WSDaOVysOp7ojJoMRWXgMLKPKmogrItSaFPdNPDtWzkjZWW/un08qIYVC 2oVL9ZvPmxbtwO0kLRuGO80jUZrIICA= 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-66-4Bq-zBPcP-SVdF6pYdLdww-1; Fri, 15 Sep 2023 09:24:54 -0400 X-MC-Unique: 4Bq-zBPcP-SVdF6pYdLdww-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 CA13480349B; Fri, 15 Sep 2023 13:24:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6689610F1BE9; Fri, 15 Sep 2023 13:24:51 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <5017b9fa177f4deaa5d481a5d8914ab4@AcuMS.aculab.com> References: <5017b9fa177f4deaa5d481a5d8914ab4@AcuMS.aculab.com> <20230914221526.3153402-1-dhowells@redhat.com> <20230914221526.3153402-10-dhowells@redhat.com> <3370515.1694772627@warthog.procyon.org.uk> To: David Laight Cc: dhowells@redhat.com, Al Viro , Linus Torvalds , Jens Axboe , "Christoph Hellwig" , Christian Brauner , "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" , Andrew Morton , Christian Brauner , "David Hildenbrand" , John Hubbard Subject: Re: [RFC PATCH 9/9] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3629597.1694784290.1@warthog.procyon.org.uk> Date: Fri, 15 Sep 2023 14:24:50 +0100 Message-ID: <3629598.1694784290@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Stat-Signature: nrgx5rcfghdo8rry3m1y3r5oa6xzkrmw X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7D6231A000B X-Rspam-User: X-HE-Tag: 1694784299-649268 X-HE-Meta: U2FsdGVkX1+8UIOApMFbPwvqL7b8YGl323AOfJtnJmbAE3hokTaFlrdW+KHgvDp7RL7RaJWtiqcc0HN7Mc2MOGd8E6Ltk0NSQLRi0LR7igpFyrBxNTpScVI6bMWyGSpQWZVt27vbHnO+OxiUkHiFM3Gu5w+Rh+e3vydPtC1htNLLqGr7pzquuTdIYThRYO7Krw089NvDg5YxN6EaHt2t+EF69V0PiBeJBZliapIEU4K2Ztwpi2t4j/5vXkDIeqkdkRQjZA4Rzu5x92WZLtqmn4vMkk8gHiuleEJFJdVnNca6d4Mdpn985VUrdfnT3nCysWIF+PqA4ek/G+lr21GNCBOAMN9/99iwj2JMVAg2YOmgROmUmeQxeWKUqkGMSEZChLDO06dbRx1nVrIvHrotYW1YJjw4NG643HBIqjewltLOAKaBzR1/oqs93wEkzea8lYtj0bB9oQZ+et53yTgk/ouW8lhML9f5wCA27rUdg79NQqIiGJtnq8PmQ6JSAEESx1HvPfOOvs6bWcltyWHhGUruNkS768FAaQbGjHXZtYJr2+nyZWnGaPhJustjbcwHsDNYTU3bK69s8Djl5B00N0uPcKL6L+L5Orvuxr1GtH4lXlGqwalVs9GJ0g4iyQ9PgctUqnprTLergdxUm9JtFLeGCcu6VvSoM2dSJ3Kiu8knJ/DNQ6+F5r4cCc/rFA39Ai1DM1qVJrC3jssLwFrbVjOC6muBbUOTo6B2N3tW1XYqLYIJGplnKm30eshSo4wIwwPnMq0qiwI4uvbVl9pU+lDPAHZWWqNyc1wadV8pw6OC5/1quKICFMk56Zey1oM+Wa0JiYRrvjW3axJPj9efaGoDrlBrDPV+BEmtvcT7nvGu3SwGXIz5oz414hwanZsDD3Nk9+8Wy9b44mtv0erqVziYdPVnff3bNmLoChVRy3sKDvn4queoxwjqqr+CM3zWpbyc8Spn2lwtREgvqNd Pi2zQdB3 ttCeWKQpna09AM36FRGKayjiUBonX3b+KNPzpaANCxICwYDN/rMkk8PXhq/1hWV0/rXD24qMxiYpSuVxfKr7/bv9OllBZw+sjefMwFsBlqywFQzSa8KCuy01wNbBYyXdXfCy2eEdo1LaZbL90Mz/jAHYzTGp6IT71uPpgZTm/N7WlQ6sNHav46fAzp89PWDVexfi112Zy4t/Zxucv/5luXfH6OD5qZApsLFQ22pDsVtPXkeGvdJYZopUQ9e/c57UdxjKpYhskp0e0TEOx/o4ibbwqBlgddLOEvzFkWqRtoVbeH3I= 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: David Laight 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