From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56A50155C90; Tue, 2 Jul 2024 09:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719913994; cv=none; b=VX70HXenJP+pxVYXsfPBE5IyHoEL0065ySUoXbD2A0wLVyK0aMwNfckEB6gTW9QwtCGUHjnbD7azV2R4x2Bh0eDCPh9lMVK11KGjg+Vo1YND1UDBPEr0UCW6ZId+FyU58eZQ9st5gtVEC49zxluLiLtusiInV7vVbDQocFBmhKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719913994; c=relaxed/simple; bh=05Y0Y8bWhUd/xPS8FWSfPwW7fc1njuZTbn06uYLuB2o=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=O7L9Vab4H8px1ZwjzMq3NItxikDWPacRgB1TYfSC3e/O+g2tLu78CWtuHNY/0ELqc/qcA3uWwmvaC+WmqM2YDiajIYIkY1YTqa8wsLl5M1KLWMpoQ7cqgAMRMukQ9e4go8RDuRprbGlGtJzniGwmoW67eXixn9PfBc3HjmDJz3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ovn.org; spf=pass smtp.mailfrom=ovn.org; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ovn.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ovn.org Received: by mail.gandi.net (Postfix) with ESMTPSA id ECE52C0007; Tue, 2 Jul 2024 09:53:02 +0000 (UTC) Message-ID: <447c0d2a-f7cf-4c34-b5d5-96ca6fffa6b0@ovn.org> Date: Tue, 2 Jul 2024 11:53:01 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: i.maximets@ovn.org, Aaron Conole , netdev@vger.kernel.org, echaudro@redhat.com, dev@openvswitch.org, Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Pravin B Shelar , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v7 05/10] net: openvswitch: add psample action To: Simon Horman , =?UTF-8?Q?Adri=C3=A1n_Moreno?= References: <20240630195740.1469727-1-amorenoz@redhat.com> <20240630195740.1469727-6-amorenoz@redhat.com> <20240702093726.GD598357@kernel.org> Content-Language: en-US From: Ilya Maximets Autocrypt: addr=i.maximets@ovn.org; keydata= xsFNBF77bOMBEADVZQ4iajIECGfH3hpQMQjhIQlyKX4hIB3OccKl5XvB/JqVPJWuZQRuqNQG /B70MP6km95KnWLZ4H1/5YOJK2l7VN7nO+tyF+I+srcKq8Ai6S3vyiP9zPCrZkYvhqChNOCF pNqdWBEmTvLZeVPmfdrjmzCLXVLi5De9HpIZQFg/Ztgj1AZENNQjYjtDdObMHuJQNJ6ubPIW cvOOn4WBr8NsP4a2OuHSTdVyAJwcDhu+WrS/Bj3KlQXIdPv3Zm5x9u/56NmCn1tSkLrEgi0i /nJNeH5QhPdYGtNzPixKgPmCKz54/LDxU61AmBvyRve+U80ukS+5vWk8zvnCGvL0ms7kx5sA tETpbKEV3d7CB3sQEym8B8gl0Ux9KzGp5lbhxxO995KWzZWWokVUcevGBKsAx4a/C0wTVOpP FbQsq6xEpTKBZwlCpxyJi3/PbZQJ95T8Uw6tlJkPmNx8CasiqNy2872gD1nN/WOP8m+cIQNu o6NOiz6VzNcowhEihE8Nkw9V+zfCxC8SzSBuYCiVX6FpgKzY/Tx+v2uO4f/8FoZj2trzXdLk Ba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TtT811SzheAN0PvgT+L1Gsztc Q3BvfofFv3OLF778JyVfpXRHsn9rFqxG/QYWMqJWi+vdPJ5RhDl1QUEFyH7ok/ZY60/85FW3 o9OQwoMf2+pKNG3J+EMuU4g4ZHGzxI0isyww7PpEHx6sxFEvMhsOp7qnjPsQUcnGIIiqKlTj H7i86580VndsKrRK99zJrm4s9Tg/7OFP1SpVvNvSM4TRXSzVF25WVfLgeloN1yHC5Wsqk33X XNtNovqA0TLFjhfyyetBsIOgpGakgBNieC9GnY7tC3AG+BqG5jnVuGqSTO+iM/d+lsoa+w== In-Reply-To: <20240702093726.GD598357@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: i.maximets@ovn.org On 7/2/24 11:37, Simon Horman wrote: > On Tue, Jul 02, 2024 at 03:05:02AM -0400, Adrián Moreno wrote: >> On Mon, Jul 01, 2024 at 02:23:12PM GMT, Aaron Conole wrote: >>> Adrian Moreno writes: > > ... > >>>> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c > > ... > >>>> @@ -1299,6 +1304,39 @@ static int execute_dec_ttl(struct sk_buff *skb, struct sw_flow_key *key) >>>> return 0; >>>> } >>>> >>>> +#if IS_ENABLED(CONFIG_PSAMPLE) >>>> +static void execute_psample(struct datapath *dp, struct sk_buff *skb, >>>> + const struct nlattr *attr) >>>> +{ >>>> + struct psample_group psample_group = {}; >>>> + struct psample_metadata md = {}; >>>> + const struct nlattr *a; >>>> + int rem; >>>> + >>>> + nla_for_each_attr(a, nla_data(attr), nla_len(attr), rem) { >>>> + switch (nla_type(a)) { >>>> + case OVS_PSAMPLE_ATTR_GROUP: >>>> + psample_group.group_num = nla_get_u32(a); >>>> + break; >>>> + >>>> + case OVS_PSAMPLE_ATTR_COOKIE: >>>> + md.user_cookie = nla_data(a); >>>> + md.user_cookie_len = nla_len(a); >>>> + break; >>>> + } >>>> + } >>>> + >>>> + psample_group.net = ovs_dp_get_net(dp); >>>> + md.in_ifindex = OVS_CB(skb)->input_vport->dev->ifindex; >>>> + md.trunc_size = skb->len - OVS_CB(skb)->cutlen; >>>> + >>>> + psample_sample_packet(&psample_group, skb, 0, &md); >>>> +} >>>> +#else >>>> +static inline void execute_psample(struct datapath *dp, struct sk_buff *skb, >>>> + const struct nlattr *attr) {} >>> >>> I noticed that this got flagged in patchwork since it is 'static inline' >>> while being part of a complete translation unit - but I also see some >>> other places where that has been done. I guess it should be just >>> 'static' though. I don't feel very strongly about it. >>> >> >> We had a bit of discussion about this with Ilya. It seems "static >> inline" is a common pattern around the kernel. The coding style >> documentation says: >> "Generally, inline functions are preferable to macros resembling functions." >> >> So I think this "inline" is correct but I might be missing something. > > Hi Adrián, > > TL;DR: Please remove this inline keyword > > For Kernel networking code at least it is strongly preferred not > to use inline in .c files unless there is a demonstrable - usually > performance - reason to do so. Rather, it is preferred to let the > compiler decide when to inline such functions. OTOH, the inline > keyword in .h files is fine. FWIW, the main reason for 'inline' here is not performance, but silencing compiler's potential 'maybe unused' warnings: Function-like macros with unused parameters should be replaced by static inline functions to avoid the issue of unused variables I think, the rule for static inline functions in .c files is at odds with the 'Conditional Compilation' section of coding style. The section does recommend to avoid conditional function declaration in .c files, but I'm not sure it is reasonable to export internal static functions for that reason. In this particular case we can either define a macro, which is discouraged by the coding style: Generally, inline functions are preferable to macros resembling functions. Or create a static inline function, that is against rule of no static inline functions in .c files. Or create a simple static function and mark all the arguments as unused, which kind of compliant to the coding style, but the least pretty. Best regards, Ilya Maximets.