Sounds good to me but it does look like the rte_rxmbuf_alloc() could use some comments to make it explicit that rte_pktmbuf_reset() is avoided by design for the reasons that Bruce described. Furthermore, rte_rxmbuf_alloc() is duplicated in almost all the pmd drivers. Will it make sense to promote it to a public API? Just a thought.
Yong On 10/29/14, 2:41 AM, "Thomas Monjalon" <thomas.monjalon at 6wind.com> wrote: >2014-10-29 09:04, Bruce Richardson: >> On Tue, Oct 28, 2014 at 09:57:14PM +0000, Yong Wang wrote: >> > On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen at networkplumber.org> >> > wrote: >> > >> > >> > >On Mon, 13 Oct 2014 18:42:18 +0000 >> > >Yong Wang <yongwang at vmware.com> wrote: >> > > >> > >> Are you referring to the patch as a whole or your comment is about >>the >> > >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am >>not >> > >>sure I get your comments here. This patch simply fixes a bug on >>the rx >> > >>vlan stripping path (where valid vlan_tci stripped is overwritten >> > >>unconditionally later on the rx path in the original vmxnet3 pmd >> > >>driver). All the other pmd drivers are doing the same thing in >>terms of >> > >>translating descriptor status to rte_mbuf flags for vlan stripping. >> > > >> > >I was thinking that there are many fields in a pktmbuf and rather >>than >> > >individually >> > >setting them (like tci). The code should call the common >> > >rte_pktmbuf_reset before setting >> > >the fields. That way when someone adds a field to mbuf they don't >>have >> > >to chasing >> > >through every driver that does it's own initialization. >> > >> > Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks >> > like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, >> > which directly calls __rte_mbuf_raw_alloc >> > () without calling rte_pktmbuf_reset(). How about we change that in a >> > separate patch to all pmd drivers so that we can keep their behavior >> > consistent? >> > >> >> We can look to do that, but we need to beware of performance >>regressions if >> we do so. Certainly the vector implementation of the ixgbe would be >>severely >> impacted performance-wise if such a change were made. However, code >>paths >> which are not as highly tuned, or which do not need to be as highly >>tuned >> could perhaps use the standard function. >> >> The main reason for this regression is that reset will clear all fields >>of >> the mbuf, which would be wasted cycles for a number of the PMDs as they >>will >> later set some of the fields based on values in the receive descriptor. >> >> Basically, on descriptor rearm in a PMD, the only fields that need to >>be >> reset would be those not set by the copy of data from the descriptor. > >This is typically a trade-off situation. >I think that we should prefer the performance. > >-- >Thomas