Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2291096rdb; Thu, 17 Aug 2023 17:23:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVrk7FJC0b5/apyIUntj3RrkWwvyUzkiZBGeH8/Cslf2yCrbsT0zn+r+DjdFpm1YDlm2cI X-Received: by 2002:a17:906:53cb:b0:999:37ff:be94 with SMTP id p11-20020a17090653cb00b0099937ffbe94mr703056ejo.71.1692318205425; Thu, 17 Aug 2023 17:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692318205; cv=none; d=google.com; s=arc-20160816; b=nIo5ZHJ1NDbY35g+eCeiGOj2haWejMDgnQBUIIzgpMxTZl9XBLaJzQX3Al88s3qoR/ U9eYml1vzdWEBo4FBWdBfg9CSBXbdDmN+fgWe/EhR/48tWJoEIxtUNRaTtab3xa+CJs/ mIP9PxqNa3OxJkF64UrurR8JPjnc3wFDjEpUnAAay0aNgKFjZabwwSmKEKoqjMnnuq0n U5DjzH8K9kSuNlVlWwBtKH+dQOkMpYRufq0WifCGQ+BwtzT5cHTutNKxk50WkRGxvtmz pLgtU/9xkYma3CT5UB/X9WUpmODAfkXR6RHiG96PY5NNE3npwZ37tzlgT5fBZYNphgwX Uptw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=56sfdmU9drIqXA2AY+ObCS/iWvUnAHAZxmo5JruXbIk=; fh=E+gWjJpLMwC8NPC4fKG1wzSBCuz7nGctpCwV/kCWeok=; b=zPnDgJ6skZ1qhUPuWXxDrZ4bLisoC3gEHKvnyJMUeqlXEccwNeo7hrZxdPYnXV2RAz ezgtegVuCqzHvqfsG48Cq8zt3uNQRn5+Ud/VfhVkqQz+zW5kNigJGMSY6uHGrnRd/ulV KqjJ6fLBCcSWar8BtH8W2enIXWe5rF9+H2/6rTI9FIYcKoXO+K/6RMGDQu4iPyXi4TXS QuFu3YNefH/C5x8BSADmNSBeucLx611hwec4I5PeogeuCLomkqdutOsmF/eoKHZbzjpV CYbscWzvsgyMckAnXEalRbUtsfxCec2mcMJgSSKQzuZim4CFYe/+lKJXJIlYNHu/gMQZ S+bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13-20020a170906444d00b00992a9bc7432si455265ejp.936.2023.08.17.17.23.01; Thu, 17 Aug 2023 17:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243046AbjHPIsR convert rfc822-to-8bit (ORCPT + 99 others); Wed, 16 Aug 2023 04:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243159AbjHPIsH (ORCPT ); Wed, 16 Aug 2023 04:48:07 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720952D7E for ; Wed, 16 Aug 2023 01:31:57 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-102-GQJWoHGIPVK3nlIn0yNs6w-1; Wed, 16 Aug 2023 09:30:54 +0100 X-MC-Unique: GQJWoHGIPVK3nlIn0yNs6w-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 16 Aug 2023 09:30:52 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 16 Aug 2023 09:30:52 +0100 From: David Laight To: 'David Howells' , Linus Torvalds CC: Alexander Viro , Jens Axboe , Christoph Hellwig , Christian Brauner , Matthew Wilcox , "jlayton@kernel.org" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: RE: [RFC PATCH v2] iov_iter: Convert iterate*() to inline funcs Thread-Topic: [RFC PATCH v2] iov_iter: Convert iterate*() to inline funcs Thread-Index: AQHZzvgmq2lQZxPz+UuF+eoksadYZ6/rhpfw Date: Wed, 16 Aug 2023 08:30:52 +0000 Message-ID: <8722207799c342e780e1162a983dc48b@AcuMS.aculab.com> References: <855.1692047347@warthog.procyon.org.uk> <5247.1692049208@warthog.procyon.org.uk> In-Reply-To: <5247.1692049208@warthog.procyon.org.uk> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells > Sent: 14 August 2023 22:40 > > > > _copy_from_iter inc 0x36e -> 0x395 +0x27 > > Here a disassembly of _copy_from_iter() from unpatched and patched, marked up for > the different iterator-type branches. To summarise: > > UNPATCHED PATCHED > START LEN START LEN > ======= ======= ======= ======= > Prologue 0 77 0 76 > UBUF 77 36 76 36 > IOVEC 113 148 112 105 > BVEC 261 159 217 163 > KVEC 420 125 380 116 > XARRAY 545 286 496 374 > DISCARD/Epi 831 42 870 42 > Return 873 - 912 - > > > The overall change in the entire file, according to size, is: > 19855 744 0 20599 5077 build3/lib/iov_iter.o -- before > 19739 864 0 20603 507b build3/lib/iov_iter.o -- after It is harder to compare because of some of the random name changes. The version of the source I found seems to pass priv2 to functions that don't use it? Since the functions aren't inlined you get the cost of passing the parameters. This seems to affect the common cases. Is that all left over from a version that passed function pointers (with the hope they'd be inlined?). Just directly inlining the simple copies should help. I rather hope the should_fail_usercopy() and instrument_copy_xxx() calls are usually either absent or, at most, nops. This all seems to have a lot fewer options than last time I looked. Is it worth optimising the KVEC case with a single buffer? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)