Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1154491rdg; Fri, 11 Aug 2023 11:26:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmH34FFAkFw1Mn6aNhrjK/4FpOEMmas+D03fqZpxuZcHkmGvfs/Bt/CrWQI/FPViADmsfF X-Received: by 2002:a17:906:76d1:b0:99c:afd6:4208 with SMTP id q17-20020a17090676d100b0099cafd64208mr2356372ejn.38.1691778389175; Fri, 11 Aug 2023 11:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691778389; cv=none; d=google.com; s=arc-20160816; b=hDVy2aBQTI8yrQrejY3pKz2Kw78qq401BmmBl+WnpNexu1JeCBm1o1ZQdJgpp4s/aT ibcmdweq2gGUqJJ/VlkixdKS27drX7vzZc1WkLLoPOSqW9gOa5NMNmtgoZrzBF9a+Llq 9OaZhOxYbarnM4mj8olJlDT/2PRmd9Ls1ixLmxjLzJxaHj6k+Cc0t+1H1DTL1NwrcPzt NB7PPdCB7MwbZ67Bg/ACsF99EoiETwVHykjYDbYFAc/MG5eMyfipmxGM65+Mvp4gH6Em vF9lN0ZfYujCqv2BCYS8tVQTyGxzWD06AaDfMMxi05CA+cTKupr7B9brX+e53FVqaaBY DftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=ApvezO5YUmVyU1VImv5XlYF6Qd7hCzC3ZUJaOLuslQs=; fh=xqlA09+4Iu4TdNbmx4wukKlRDbpCTIMdqNWn9zlxJf8=; b=QMShameY/H7sDPEBDc6l4nqn/kWm/kkV6I8SdAePtSuQFmBiWy3aGNXFwPCle8VHSM pxabDCw1G1WZ4LT6apbkgnIEY0Bp6NkVOzXcmfoSD/+ZtB+NFrVl+46KW1LSCIH1oFkL NK9Nf0kVmRTadVn99Wc2OlzMYi93FIuIbDPzDLlL/8yEi45xH+e53fJ1gjOx9mrPE/PP UsXU1H1w78kwAoCRU2hJL+SGShlIu0lDRSEH9/+NL0L148AofKFN+El5CasaDOLoK7Tu DZ0YSmMz0KzJr7GyG9pWGgDH1QhaIyWHPwBWY1XuR5W+tdfB22aqHiODVEMV4BioACtG 5dLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DmjCOaBj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a17090606d000b00993470737basi3650703ejb.986.2023.08.11.11.26.04; Fri, 11 Aug 2023 11:26:29 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DmjCOaBj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236690AbjHKRIZ (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236490AbjHKRII (ORCPT ); Fri, 11 Aug 2023 13:08:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95F2E5B for ; Fri, 11 Aug 2023 10:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691773632; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ApvezO5YUmVyU1VImv5XlYF6Qd7hCzC3ZUJaOLuslQs=; b=DmjCOaBjgpyZCxZ6OFo3cv1IUv+LC2RaZKSMQGfd9XGDQ16P1Pl/X45DeP42c1usIMzLLI nBojJWVUutl6kNhdBM+qIC6aRdVeIgBzVlaaM27VMs0s04KmsyEf2LBu1E02dOtzTXNw/0 n4dz91fDfHEW7yCvKlVbN98xUzteU+g= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-rhh60aFROIWDMm8yoRVjbQ-1; Fri, 11 Aug 2023 13:07:09 -0400 X-MC-Unique: rhh60aFROIWDMm8yoRVjbQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 128FA1C07267; Fri, 11 Aug 2023 17:07:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id A963140C2063; Fri, 11 Aug 2023 17:07:07 +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: References: <3710261.1691764329@warthog.procyon.org.uk> To: Linus Torvalds Cc: dhowells@redhat.com, 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] iov_iter: Convert iterate*() to inline funcs MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3888330.1691773627.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 11 Aug 2023 18:07:07 +0100 Message-ID: <3888331.1691773627@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 Linus Torvalds wrote: > I like this generally, the code generation deprovement worries me a > bit, but from a quick look on a test-branch it didn't really look all > that bad (but the changes are too big to usefully show up as asm > diffs) Hmmm... It seems that using if-if-if rather than switch() gets optimised better in terms of .text space. The attached change makes things a bit smaller (by 69 bytes). David --- diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 8943ac25e202..f61474ec1c89 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -190,22 +190,18 @@ size_t iterate_and_advance(struct iov_iter *iter, si= ze_t len, void *priv, if (unlikely(!len)) return 0; = - switch (iov_iter_type(iter)) { - case ITER_UBUF: + if (likely(iter_is_ubuf(iter))) return iterate_ubuf(iter, len, priv, NULL, ustep); - case ITER_IOVEC: + if (likely(iter_is_iovec(iter))) return iterate_iovec(iter, len, priv, NULL, ustep); - case ITER_KVEC: + if (iov_iter_is_kvec(iter)) return iterate_kvec(iter, len, priv, NULL, step); - case ITER_BVEC: + if (iov_iter_is_bvec(iter)) return iterate_bvec(iter, len, priv, NULL, step); - case ITER_XARRAY: + if (iov_iter_is_xarray(iter)) return iterate_xarray(iter, len, priv, NULL, step); - case ITER_DISCARD: - iter->count -=3D len; - return len; - } - return 0; + iter->count -=3D len; + return len; } = static __always_inline @@ -217,22 +213,18 @@ size_t iterate_and_advance_csum(struct iov_iter *ite= r, size_t len, void *priv, if (unlikely(!len)) return 0; = - switch (iov_iter_type(iter)) { - case ITER_UBUF: + if (likely(iter_is_ubuf(iter))) return iterate_ubuf(iter, len, priv, csum, ustep); - case ITER_IOVEC: + if (likely(iter_is_iovec(iter))) return iterate_iovec(iter, len, priv, csum, ustep); - case ITER_KVEC: + if (iov_iter_is_kvec(iter)) return iterate_kvec(iter, len, priv, csum, step); - case ITER_BVEC: + if (iov_iter_is_bvec(iter)) return iterate_bvec(iter, len, priv, csum, step); - case ITER_XARRAY: + if (iov_iter_is_xarray(iter)) return iterate_xarray(iter, len, priv, csum, step); - case ITER_DISCARD: - iter->count -=3D len; - return len; - } - return 0; + iter->count -=3D len; + return len; } = static size_t copy_to_user_iter(void __user *iter_to, size_t progress,