Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp832944pxb; Thu, 17 Feb 2022 16:05:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHoztQGmcnmG22WEyz67AH7w9msFNKKL+nPV5ABVLrCsGhSlmsjE7yPdFnDJmjCrE8f90z X-Received: by 2002:a4a:2714:0:b0:31b:ffc2:cc53 with SMTP id l20-20020a4a2714000000b0031bffc2cc53mr971451oof.13.1645142741715; Thu, 17 Feb 2022 16:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645142741; cv=none; d=google.com; s=arc-20160816; b=HZxFRr6gZ1J+82/9y1EngmiMpIStt6z4ZhIDxovv/D6HnQeEei2gkCVxOYSKvZiqjp syfFmWMISu43ZznJ5pIBCP6ejcq+Au+1w9ATWbeNJs7tYorDv7x0bR1Wk1RhqHaUi6G3 IdIiVLoko8/uRQW7X0He++chCnHeM91FVIO9kPjFuHwYVafRuN75ak+622/8e+Zu1rG2 OuVuQg2DLifB1JkC1pupMl1uPmm7IqSu4KyYC37TIEnlGty+MfK0dhwBzMpM5YOBXW4b elfmC+L5QorxizOKkWTwJcYPSGzGDqAt6DJldWb+m66C6+Fd7xImLWer3IWy9uRBf0VW ulLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=sAE7WZx+Vn5ul5ZCkkPHSwqPjRTIgC2yBDs1UhfpXLU=; b=yG3lYH41spykYAF+hxgxV+ZhDIFnkrwxaGhkJiSzel0mdU1qHIs058toyFY76dPH+A oADrP9enZOE46xcrfhFpJam/aQWRd+us68H+g80R3vEURbq6OzApBaEtpoJHs7R0jUBS owsWFg8BStEO60SuyBzDY22g7HeGv+zS/WknaStzpGjxDnoZ0BRQrTkR6I6GI5sgY798 o+XQzHybLQxC2xP4CNrOSv29csPBT32IR19IldCTbsnEqSVT9QI8C95HZp1X82Hzb2T/ EYAbi1S1qTE77MM0YYiZW7FjLS2VILL8nP/zMfyyPqSsONbMe7xk+feZFub/TsWUMnM8 GrWg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t5si574638oiw.238.2022.02.17.16.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 16:05:41 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 495B1331D6B; Thu, 17 Feb 2022 15:33:09 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242644AbiBQPm0 (ORCPT + 99 others); Thu, 17 Feb 2022 10:42:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242631AbiBQPmX (ORCPT ); Thu, 17 Feb 2022 10:42:23 -0500 Received: from relay5.hostedemail.com (relay5.hostedemail.com [64.99.140.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AADB713F69 for ; Thu, 17 Feb 2022 07:42:08 -0800 (PST) Received: from omf09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1AFCB2042F; Thu, 17 Feb 2022 15:42:07 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA id AF56320032; Thu, 17 Feb 2022 15:42:05 +0000 (UTC) Message-ID: <1f6cabc8b183056546571b391770e1eea8524fd3.camel@perches.com> Subject: Re: [PATCH net v3] net: Force inlining of checksum functions in net/checksum.h From: Joe Perches To: Christophe Leroy , "David S. Miller" , Jakub Kicinski Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, Masahiro Yamada Date: Thu, 17 Feb 2022 07:42:04 -0800 In-Reply-To: <978951d76d8cb84bab347c7623bc163e9a038452.1645100305.git.christophe.leroy@csgroup.eu> References: <978951d76d8cb84bab347c7623bc163e9a038452.1645100305.git.christophe.leroy@csgroup.eu> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: AF56320032 X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SORTED_RECIPS,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Stat-Signature: nz9e5z1u3yz1f5rpbt3m7jkkokhucyw8 X-Rspamd-Server: rspamout02 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19KaPmP/R/KoYWstS8VZiTyOYA8oslrR+Y= X-HE-Tag: 1645112525-592173 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 On Thu, 2022-02-17 at 13:19 +0100, Christophe Leroy wrote: > All functions defined as static inline in net/checksum.h are > meant to be inlined for performance reason. > > But since commit ac7c3e4ff401 ("compiler: enable > CONFIG_OPTIMIZE_INLINING forcibly") the compiler is allowed to > uninline functions when it wants. > > Fair enough in the general case, but for tiny performance critical > checksum helpers that's counter-productive. Thanks. Trivial style notes: > diff --git a/include/net/checksum.h b/include/net/checksum.h [] > @@ -22,7 +22,7 @@ > #include > > #ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER > -static inline > +static __always_inline > __wsum csum_and_copy_from_user (const void __user *src, void *dst, > int len) > { __wsum might be better placed on the previous line. [] > @@ -45,7 +45,7 @@ static __inline__ __wsum csum_and_copy_to_user > #endif > > #ifndef _HAVE_ARCH_CSUM_AND_COPY > -static inline __wsum > +static __always_inline __wsum > csum_partial_copy_nocheck(const void *src, void *dst, int len) To be consistent with the location of the __wsum return value when splitting the function definitions across multiple lines. (like the below) > @@ -88,42 +88,43 @@ static inline __wsum csum_shift(__wsum sum, int offset) > return sum; > } > > -static inline __wsum > +static __always_inline __wsum > csum_block_add(__wsum csum, __wsum csum2, int offset) > { > return csum_add(csum, csum_shift(csum2, offset)); > } > > -static inline __wsum > +static __always_inline __wsum > csum_block_add_ext(__wsum csum, __wsum csum2, int offset, int len) > { > return csum_block_add(csum, csum2, offset); > } > > -static inline __wsum > +static __always_inline __wsum > csum_block_sub(__wsum csum, __wsum csum2, int offset) > { > return csum_block_add(csum, ~csum2, offset); > } > > -static inline __wsum csum_unfold(__sum16 n) > +static __always_inline __wsum csum_unfold(__sum16 n) > { > return (__force __wsum)n; > } > [] > -static inline __wsum csum_partial_ext(const void *buff, int len, __wsum sum) > +static __always_inline > +__wsum csum_partial_ext(const void *buff, int len, __wsum sum) > { > return csum_partial(buff, len, sum); > } And this __wsum could be moved too. > @@ -150,15 +151,15 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, [] > -static inline __wsum remcsum_adjust(void *ptr, __wsum csum, > +static __always_inline __wsum remcsum_adjust(void *ptr, __wsum csum, > int start, int offset) > { > __sum16 *psum = (__sum16 *)(ptr + offset); And this one could be split like the above static __always_inline __wsum remcsum_adjust(void *ptr, __wsum csum, int start, int offset)