Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2366028rdb; Thu, 21 Sep 2023 17:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDPkyu3Ujz1uYeL43l9mQiukQYqcmhdGfHCa9LnWDqTcLdscoOsElkrTqBTLgfxb8WLn2M X-Received: by 2002:a17:903:32ca:b0:1c3:8dbe:aecb with SMTP id i10-20020a17090332ca00b001c38dbeaecbmr6905051plr.2.1695341594147; Thu, 21 Sep 2023 17:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695341594; cv=none; d=google.com; s=arc-20160816; b=ZhCaZCqVZhHBQz8dlbnY8vyF6cl7kIbMr0zV2thiGnD/DooWJ+N8DfAiFqOFk7v+fv c5Pe7h4o3zNJwRfimWGoWw0p6sT9L9A2SUm9SHeoVYFHtt5ryn7rhlweRJeKz67Z4U9u f68UBmG08ivAk1nImv0g6XuHQd/xJ7cuK929j0Dm+GX0vrUkJ7S8LWt89i5ho2vdr9WP r4I2ziyjTq+o5WXPMa/um60sDr59CRTfx/wZaSHe642aYcsFFZukhNxl6CRPOK9n+sAq PTmssFXzQB+SHghPU22uyjZwJMqu+WnwXUJB662fQ7TgtPi9REXfm0a7D/vrWv3DZIe+ 25NA== 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=VRqQWs1hMbd+4ty9+ipFOFmzhr6M8fG3fWATprBzjcM=; fh=8XaLnAzXKG9oz2ojnu4kCDLK0ETJWBdbqPEOztRGAGQ=; b=BebBaHaofk86mfdtT+iMec8+XZbEF4R63fNZjppfMK6ZhfwhNCR38UO5Hw2UrvOo9E YhotxRw6lXcAgXy9iwdDF7mjcKhBA5ag65X6acC1rS5gzp61ajroUfY1P4SSC+xWtFv3 qrEKLrNEs39v31Kp3zfgGq/HAAraQ5V9IyhGk2awDdgemlUJGmZxwAUWS6VgKtZDrPOx JQI4TVCbNx0A0iExw/jLHCKSbDlRBhjXRxAdm0OCvZundAZ3NnMJEB6CJIxuhJmWTtDN LpZbw/2pdTd9qQmrrv98MnjKrcaR2C7iKQbq8Xt2WJbNdWg6QoLjiRXomPUT/d7i77Kk Nj3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z17-20020a170903019100b001c577fdc3c9si2863374plg.541.2023.09.21.17.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 17:13:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A2BC882E53F6; Thu, 21 Sep 2023 13:03:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbjIUUDF convert rfc822-to-8bit (ORCPT + 99 others); Thu, 21 Sep 2023 16:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbjIUUCg (ORCPT ); Thu, 21 Sep 2023 16:02:36 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4A85A038 for ; Thu, 21 Sep 2023 10:21:02 -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-78-tT6XIwH6NoO3sNNrU8Sykg-1; Thu, 21 Sep 2023 15:05:00 +0100 X-MC-Unique: tT6XIwH6NoO3sNNrU8Sykg-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 21 Sep 2023 15:05:00 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 21 Sep 2023 15:05:00 +0100 From: David Laight To: 'David Howells' , Jens Axboe CC: Al Viro , Linus Torvalds , Christoph Hellwig , "Christian Brauner" , Matthew Wilcox , "Jeff Layton" , "linux-fsdevel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-mm@kvack.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v5 00/11] iov_iter: Convert the iterator macros into inline funcs Thread-Topic: [PATCH v5 00/11] iov_iter: Convert the iterator macros into inline funcs Thread-Index: AQHZ7BD/kh4zTlIOdEezFNQQd09cYrAlRT1Q Date: Thu, 21 Sep 2023 14:04:59 +0000 Message-ID: <591a70bf016b4317add2d936696abc0f@AcuMS.aculab.com> References: <20230920222231.686275-1-dhowells@redhat.com> In-Reply-To: <20230920222231.686275-1-dhowells@redhat.com> 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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:03:05 -0700 (PDT) From: David Howells > Sent: 20 September 2023 23:22 ... > (8) Move the copy-and-csum code to net/ where it can be in proximity with > the code that uses it. This eliminates the code if CONFIG_NET=n and > allows for the slim possibility of it being inlined. > > (9) Fold memcpy_and_csum() in to its two users. > > (10) Move csum_and_copy_from_iter_full() out of line and merge in > csum_and_copy_from_iter() since the former is the only caller of the > latter. I thought that the real idea behind these was to do the checksum at the same time as the copy to avoid loading the data into the L1 data-cache twice - especially for long buffers. I wonder how often there are multiple iov[] that actually make it better than just check summing the linear buffer? I had a feeling that check summing of udp data was done during copy_to/from_user, but the code can't be the copy-and-csum here for that because it is missing support form odd-length buffers. Intel x86 desktop chips can easily checksum at 8 bytes/clock (But probably not with the current code!). (I've got ~12 bytes/clock using adox and adcx but that loop is entirely horrid and it would need run-time patching. Especially since I think some AMD cpu execute them very slowly.) OTOH 'rep movs[bq]' copy will copy 16 bytes/clock (32 if the destination is 32 byte aligned - it pretty much won't be). So you'd need a csum-and-copy loop that did 16 bytes every three clocks to get the same throughput for long buffers. In principle splitting the 'adc memory' into two instructions is the same number of u-ops - but I'm sure I've tried to do that and failed and the extra memory write can happen in parallel with everything else. So I don't think you'll get 16 bytes in two clocks - but you might get it is three. OTOH for a cpu where memcpy is code loop summing the data in the copy loop is likely to be a gain. But I suspect doing the checksum and copy at the same time got 'all to complicated' to actually implement fully. With most modern ethernet chips checksumming receive pacakets does it really get used enough for the additional complexity? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)