From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id A5D0C47D1 for ; Tue, 6 Dec 2016 21:31:41 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 06 Dec 2016 12:31:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="199740897" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by fmsmga004.fm.intel.com with ESMTP; 06 Dec 2016 12:31:37 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.43]) by IRSMSX106.ger.corp.intel.com ([169.254.8.112]) with mapi id 14.03.0248.002; Tue, 6 Dec 2016 20:31:36 +0000 From: "Ananyev, Konstantin" To: Adrien Mazarguil CC: Thomas Monjalon , "dev@dpdk.org" , Rahul Lakkireddy , Stephen Hurd , Jan Medala , Jakub Palider , John Daley , Alejandro Lucero , Harish Patil , Rasesh Mody , Jerin Jacob , Yuanhan Liu , Yong Wang , "Kulasek, TomaszX" , "olivier.matz@6wind.com" Thread-Topic: [dpdk-dev] [PATCH v12 0/6] add Tx preparation Thread-Index: AQHSRbBDKacvBhx2eUCvrHI7LRX1L6DuQp0AgALr7oCAACwIoIABX2MAgAEdxrCABa5agIAAE4SwgAAgtICAAQGb8IAASr2AgABONVA= Date: Tue, 6 Dec 2016 20:31:35 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583F0E4C13@irsmsx105.ger.corp.intel.com> References: <1479922585-8640-1-git-send-email-tomaszx.kulasek@intel.com> <8317180.L80Qf11uiu@xps13> <20161130074003.GD10340@6wind.com> <2601191342CEEE43887BDE71AB9772583F0E20C8@irsmsx105.ger.corp.intel.com> <20161201071518.GG10340@6wind.com> <2601191342CEEE43887BDE71AB9772583F0E2A9A@irsmsx105.ger.corp.intel.com> <20161205150327.GP10340@6wind.com> <2601191342CEEE43887BDE71AB9772583F0E43B5@irsmsx105.ger.corp.intel.com> <20161205181021.GT10340@6wind.com> <2601191342CEEE43887BDE71AB9772583F0E45D6@irsmsx105.ger.corp.intel.com> <20161206135951.GY10340@6wind.com> In-Reply-To: <20161206135951.GY10340@6wind.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v12 0/6] add Tx preparation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 20:31:42 -0000 > Hi Konstantin, >=20 > On Tue, Dec 06, 2016 at 10:56:26AM +0000, Ananyev, Konstantin wrote: > > > > Hi Adrien, > > > > > > > > On Mon, Dec 05, 2016 at 04:43:52PM +0000, Ananyev, Konstantin wrote: > > > [...] > > > > > On Fri, Dec 02, 2016 at 01:00:55AM +0000, Ananyev, Konstantin wro= te: > > > > > [...] > > > > > > > On Wed, Nov 30, 2016 at 10:54:50AM +0000, Ananyev, Konstantin= wrote: > > > > > > > [...] > > > > > > > > Do you have anything particular in mind here? > > > > > > > > > > > > > > Nothing in particular, so for the sake of the argument, let's= suppose that I > > > > > > > would like to add a field to expose some limitation that only= applies to my > > > > > > > PMD during TX but looks generic enough to make sense, e.g. ma= ximum packet > > > > > > > size when VLAN tagging is requested. > > > > > > > > > > > > Hmm, I didn't hear about such limitations so far, but if it is = real case - > > > > > > sure, feel free to submit the patch. > > > > > > > > > > I won't, that was hypothetical. > > > > > > > > Then why we discussing it? :) > > > > > > Just to make a point, which is that new limitations may appear anytim= e and > > > tx_prepare() can now be used to check for them. First patch of the se= ries > > > does it: > > > > > > + uint16_t nb_seg_max; /**< Max number of segments per whole p= acket. */ > > > + uint16_t nb_mtu_seg_max; /**< Max number of segments per one MTU= */ > > > > > > And states that: > > > > > > + * For each packet to send, the rte_eth_tx_prepare() function perfo= rms > > > + * the following operations: > > > + * > > > + * - Check if packet meets devices requirements for tx offloads. > > > + * > > > + * - Check limitations about number of segments. > > > + * > > > + * - Check additional requirements when debug is enabled. > > > + * > > > + * - Update and/or reset required checksums when tx offload is set = for packet. > > > > I think I already explained in my previous email why I think that > > nb_seg_max and nb_mtu_seg_max are not redundant because of tx_prepare()= . > > From my point they are complement to tx_prepare(): > > Even if people do use tx_prepare() they still should take this informat= ion into account. > > As an example ixgbe can't TX packets with then 40 segments. > > tx_prepare() for ixgbe will flag that issue, but it can't make a decisi= on on user behalf > > what to do in that case: drop the packet, try to coalesce it into the p= acket with less > > number of segments, split the packet into several smaller, etc. > > That's up to user to make such decision, and to make it, user might nee= d this information. >=20 > Yet tx_prepare() has already the ability to update mbuf contents, issue i= s > what will this function do in the future, where will it stop? It is defin= ed > in a way that each PMD does what it wants to make mbufs edible for > tx_burst(), because of this applications will just always call it to be o= n > the safe side. >=20 > > > It's like making this function mandatory IMO. > > > > That's probably where confusion starts: I don't think that > > tx_prepare() should be mandatory for the user to call. > > Yes, it should be a recommended way. > > But the user still should have the ability to by-pass it, > > if he believes there is no need for it, or he prefers to implement > > the same functionality on his own. > > As an example, if the user knows that he is going to send a group > > of one-segment packets that don't require any tx offloads, he can safel= y skip > > tx_prepare() for them. >=20 > I understand your point, and agree with the example you provide. Many > applications do not know what's inside mbufs though, except perhaps that > they contain TCP and may want to perform TSO because of that. Those will > have to call tx_prepare() to be future-proof. >=20 > > > > > > > PMDs are free to set that field to some > > > > > > > special value (say, 0) if they do not care. > > > > > > > > > > > > > > Since that field exists however, conscious applications shoul= d check its > > > > > > > value for each packet that needs to be transmitted. This extr= a code causes a > > > > > > > slowdown just by sitting in the data path. Since it is not th= e only field in > > > > > > > that structure, the performance impact can be significant. > > > > Conscious user will probably use this information at the stage of pack= et formation. > > He probably has to do this sort of things for large packets anyway: > > Check what is the underlying mtu, to decide does he need to split the p= acket, > > or enable tso for it, etc. >=20 > There are already too many things to check,=20 There always been, that patch exposes them, before that upper layer probabl= y had to use some hard-coded defines. > applications probably won't mind > a little help from PMDs. If we keep adding fields to this structure, we'l= l > have to provide some sort of PMD-specific function that checks what is > relevant. Why PMD specific? These fields are generic enough and could be used by upper layer to consult when packet is formed. >=20 > Furthermore, assuming most packets are fine and do not require any extra > processing, what is rejected by tx_burst() could enter some unlikely() pa= th > that attempts to rectify and re-send them. That would at least optimize t= he > common scenario. It is up to the upper layer to decide what to do with ill-formed packets: drop/log/try to cure/etc. Obviously different applications would have different logic and make differ= ent decisions here. If you'd like to introduce a new function (in rte_net or whatever) that wou= ld be smart and generic enough to cure ill-formed packets - you are more than welcome to t= ry. Though discussion of such fallback function is far of scope of that patch, = I believe. >=20 > > > > > > > Even though this code is inside applications, it remains unfa= ir to PMDs for > > > > > > > which these tests are irrelevant. This problem is identified = and addressed > > > > > > > by tx_prepare(). > > > > > > > > > > > > I suppose the question is why do we need: > > > > > > uint16_t nb_seg_max; > > > > > > uint16_t nb_mtu_seg_max; > > > > > > as we now have tx_prepare(), right? > > > > > > > > > > > > For two reasons: > > > > > > 1. Some people might feel that tx_prepare() is not good (smart/= fast) enough > > > > > > for them and would prefer to do necessary preparations for TX o= ffloads themselves. > > > > > > > > > > > > 2. Even if people do use tx_prepare() they still should take th= is information into accout. > > > > > > As an example ixgbe can't TX packets with then 40 segments. > > > > > > Obviously ixbge_tx_prep() performs that check and returns an er= ror. > > > > > > > > > > Problem is that tx_prepare() also provides safeties which are not= part of > > > > > tx_burst(), such as not going over nb_mtu_seg_max. Because of thi= s and the > > > > > fact struct rte_eth_desc_lim can grow new fields anytime, applica= tion > > > > > developers will be tempted to just call tx_prepare() and focus on= more > > > > > useful things. > > > > > > > > NP with that, that was an intention beyond introducing it. > > > > > > > > > Put another way, from a user's point of view, tx_prepare() is an = opaque > > > > > function that greatly increases tx_burst()'s ability to send mbuf= s as > > > > > requested, with extra error checking on top; applications not wri= tten to run > > > > > on a specific PMD/device (all of them ideally) will thus call tx_= prepare() > > > > > at some point. > > > > > > > > > > > But it wouldn't try to merge/reallocate mbufs for you. > > > > > > User still has to do it himself, or just prevent creating such = long chains somehow. > > > > > > > > > > Yes, that's another debate. PMDs could still implement a software= fallback > > > > > for unlikely slow events like these. The number of PMDs is not go= ing to > > > > > decrease, each device having its own set of weird limitations in = specific > > > > > cases, PMDs should do their best to process mbufs even if that me= ans slowly > > > > > due to the lack of preparation. > > > > > > > > > > tx_prepare() has its uses but should really be optional, in the s= ense that > > > > > if that function is not called, tx_burst() should deal with it so= mehow. > > > > > > > > As I said before, I don't think it is a good idea to put everything= in tx_burst(). > > > > If PMD driver prefer things that way, yes tx_burst() can deal with = each and > > > > possible offload requirement itself, but it shouldn't be mandatory. > > > > > > In effect, having to call tx_prepare() otherwise makes this step mand= atory > > > anyway. Looks like we are not going to agree here. > > > > > > > > > > Thanks to tx_prepare(), these checks are moved back into PMDs= where they > > > > > > > belong. PMDs that do not need them do not have to provide sup= port for > > > > > > > tx_prepare() and do not suffer any performance impact as resu= lt; > > > > > > > applications only have to make sure tx_prepare() is always ca= lled at some > > > > > > > point before tx_burst(). > > > > > > > > > > > > > > Once you reach this stage, you've effectively made tx_prepare= () mandatory > > > > > > > before tx_burst(). If some bug occurs, then perhaps you forgo= t to call > > > > > > > tx_prepare(), you just need to add it. The total cost for doi= ng TX is > > > > > > > therefore tx_prepare() + tx_burst(). > > > > > > > > > > > > > > I'm perhaps a bit pessimistic mind you, but I do not think tx= _prepare() will > > > > > > > remain optional for long. Sure, PMDs that do not implement it= do not care, > > > > > > > I'm focusing on applications, for which the performance impac= t of calling > > > > > > > tx_prepare() followed by tx_burst() is higher than a single t= x_burst() > > > > > > > performing all the necessary preparation at once. > > > > > > > > > > > > > > [...] > > > > > > > > > Following the same logic, why can't such a thing be made = part of the TX > > > > > > > > > burst function as well (through a direct call to rte_phdr= _cksum_fix() > > > > > > > > > whenever necessary). From an application standpoint, what= are the advantages > > > > > > > > > of having to: > > > > > > > > > > > > > > > > > > if (tx_prep()) // iterate and update mbufs as needed > > > > > > > > > tx_burst(); // iterate and send > > > > > > > > > > > > > > > > > > Compared to: > > > > > > > > > > > > > > > > > > tx_burst(); // iterate, update as needed and send > > > > > > > > > > > > > > > > I think that was discussed extensively quite a lot previous= ly here: > > > > > > > > As Thomas already replied - main motivation is to allow use= r > > > > > > > > to execute them on different stages of packet TX pipeline, > > > > > > > > and probably on different cores. > > > > > > > > I think that provides better flexibility to the user to whe= n/where > > > > > > > > do these preparations and hopefully would lead to better pe= rformance. > > > > > > > > > > > > > > And I agree, I think this use case is valid but does not warr= ant such a high > > > > > > > penalty when your application does not need that much flexibi= lity. Simple > > > > > > > (yet conscious) applications need the highest performance. Co= mplex ones as > > > > > > > you described already suffer quite a bit from IPCs and won't = mind a couple > > > > > > > of extra CPU cycles right? > > > > > > > > > > > > It would mean an extra cache-miss for every packet, so I think = performance hit > > > > > > would be quite significant. > > > > > > > > > > A performance hit has to occur somewhere regardless, because some= thing has > > > > > to be done in order to send packets that need it. Whether this co= st is in > > > > > application code or in a PMD function, it remains part of TX. > > > > > > > > Depending on the place the final cost would differ quite a lot. > > > > If you call tx_prepare() somewhere close to the place where you fil= l the packet header > > > > contents, then most likely the data that tx_prepare() has to access= will be already in the cache. > > > > So the performance penalty will be minimal. > > > > If you'll try to access the same data later (at tx_burst), then the= possibility that it would still > > > > be in cache is much less. > > > > If you calling tx_burst() from other core then data would for sure = be out of cache, > > > > and even worse can still be in another core cache. > > > > > > Well sure, that's why I also think tx_prepare() has its uses, only th= at > > > since tx_prepare() is optional, tx_burst() should provide the same > > > functionality when tx_prepare() is not called. > > > > As I understand, to implement what you are proposing (TX_PREPARED mbuf-= >ol_flag) > > it will be required: > > > > a) Modify all existing applications that do similar to tx_prepare() stu= ff on their own, > > otherwise they'll would hit performance penalty. > > b) Modify at least all Intel PMDs and might be some others too (vmxnet3= ?). > > > > Step b) probably wouldn't cause any significant performance impact stra= ightway, > > but it's for sure wouldn't make things faster, and would increase tx_bu= rst() code > > complexity quite a lot. > > From other side, I can't see any real benefit that we will have in retu= rn. > > So I still opposed to that idea. >=20 > Applications gain the ability to perform tx_burst() with offloads without > having to prepare anything.=20 What means 'without preparing anything'? This is just not possible I think. One way or another application would have to to decide what exactly it likes to TX and what HW offloads it likes to use for it. So at least, it still needs to fill relevant mbuf fields: pkt_len, data_len, nb_segs, ol_flags, tx_offload, etc. >Currently these applications either cannot use > offloads at all or need to perform PMD-specific voodoo first. That's why tx_prepare() is introduced. > The generic > alternative to this scenario being tx_prepare(), PMDs have to make this s= tep > as cheap as possible. >=20 > Yes that would slow down existing applications, people may find it > acceptable since we're modifying the TX API here. >=20 > > > > > > About the 'simple' case when tx_prep() and tx_burst() are calle= d on the same core, > > > > > > Why do you believe that: > > > > > > tx_prep(); tx_burst(); would be much slower than tx_burst() {tx= _prep(), ...}? > > > > > > > > > > I mean instead of two function calls with their own loops: > > > > > > > > > > tx_prepare() { foreach (pkt) { check(); extra_check(); ... } } > > > > > > > > > > tx_burst() { foreach (pkt) { check(); stuff(); ... } } > > > > > > > > > > You end up with one: > > > > > > > > > > tx_burst() { foreach (pkt) { check(); extra_check(); stuff(); ..= . } } > > > > > > > > > > Which usually is more efficient. > > > > > > > > I really doubt that. > > > > If it would be that, what is the point to process packet in bulks? > > > > Usually dividing processing into different stages and at each stage= processing > > > > multiple packet at once helps to improve performance. > > > > At least for IA. > > > > Look for example how we had to change l3fwd to improve its performa= nce. > > > > > > Depends quite a bit on usage pattern. It is less efficient for applic= ations > > > that do not modify mbuf contents because of the additional function c= all and > > > inner loop. > > > > If the application doesn't modify mbuf contents that it can simply skip= calling tx_prepare(). >=20 > What if that same application wants to enable some offload as well? Hmm, wasn't that your use-case when no offloads (modifications) are require= d just 3 lines above? >=20 > > > Note that I'm only pushing for the ability to conveniently address bo= th > > > cases with maximum performance. > > > > > > > > > tx_prep() itself is quite expensive, let say for Intel HW it in= cludes: > > > > > > - read mbuf fileds (2 cache-lines), > > > > > > - read packet header (1/2 cache-lines) > > > > > > - calculate pseudo-header csum > > > > > > - update packet header > > > > > > Comparing to that price of extra function call seems neglectabl= e > > > > > > (if we TX packets in bursts of course). > > > > > > > > > > We agree its performance is a critical issue then, sharing half t= he read > > > > > steps with tx_burst() would make sense to me. > > > > > > > > I didn't understand that sentence. > > > > > > I meant this step can be shared (in addition to loop etc): > > > > > > - read mbuf fileds (2 cache-lines), > > > > Ah ok, you still believe that mixing tx_burst and tx_prepare code toget= her > > would give us noticeable performance benefit. > > As I said above, I don't think it would, but you are welcome to try and > > prove me wrong. >=20 > Depends on what you call noticeable. I guess we can at least agree having > two separate functions and loops cause more instructions to be generated = and > executed. >=20 > Now for the number of spent CPU cycles, depends of course whether mbufs a= re > still hot into the cache or not, and as I told you in my opinion we'll > usually see applications calling tx_prepare() just before tx_burst() to > benefit from offloads. Honestly, Adrien we are going in cycles here. Just to be clear: Current patch introduces tx_prepare() without affecting in any way: 1) existing applications 2) exiting PMD code (tx_burst) Meanwhile I still believe it is useful and provide a big step forward in te= rms of generalizing usage of HW TX offloads. What you propose requires modifications for both existing applications and = existing PMD code (full-featured tx_burst() for at least all Intel PMDs and vmxnet3 has to be= significantly modified). You believe that with these modifications that new tx_burst() implementatio= n would be noticeably faster than just current: tx_prepare(); tx_burst(); I personally doubt that it really would (at least on modern IA). But as I said, you are more than welcome to prove me wrong here. Let say, provide a patch for ixgbe (or i40e) full-featured tx_burst() imple= mentation, so that it would combine both tx_prepare() and tx_burst() functionalities i= nto one function. Then we can run some performance tests with current and yours patches and c= ompare results. =20 Without that, I don't see any point to discuss your proposition any further= . I just won't agree for such big change in existing PMDs without some solid = justification beyond it. >=20 > > > > > > > Yes they will, therefore we need a method that satisfies both= cases. > > > > > > > > > > > > > > As a possible solution, a special mbuf flag could be added to= each mbuf > > > > > > > having gone through tx_prepare(). That way, tx_burst() could = skip some > > > > > > > checks and things it would otherwise have done. > > > > > > > > > > > > That's an interesting idea, but it has one drawback: > > > > > > As I understand, it means that from now on if user doing prepar= ations on his own, > > > > > > he had to setup this flag, otherwise tx_burst() would do extra = unnecessary work. > > > > > > So any existing applications that using TX offloads and do prep= aration by themselves > > > > > > would have to be modified to avoid performance loss. > > > > > > > > > > In my opinion, users should not do preparation on their own. > > > > > > > > People already do it now. > > > > > > But we do not want them to anymore thanks to this new API, for reason= s > > > described in the motivation section of the cover letter, right? > > > > We probably wouldn't recommend that, but if people would like to use th= eir own stuff, > > or shortcuts - I don't want to stop them here. > > > > > > > > > > If we provide a > > > > > generic method, it has to be fast enough to replace theirs. Perha= ps not as > > > > > fast since it would work with all PMDs (usual trade-off), but acc= eptably so. > > > > > > > > > > > > Another possibility, telling the PMD first that you always in= tend to use > > > > > > > tx_prepare() and getting a simpler/faster tx_burst() callback= as a result. > > > > > > > > > > > > That what we have right now (at least for Intel HW): > > > > > > it is a user responsibility to do the necessary preparations/ch= ecks before calling tx_burst(). > > > > > > With tx_prepare() we just remove from user the headache to impl= ement tx_prepare() on his own. > > > > > > Now he can use a 'proper' PMD provided function. > > > > > > > > > > > > My vote still would be for that model. > > > > > > > > > > OK, then in a nutshell: > > > > > > > > > > 1. Users are not expected to perform preparation/checks themselve= s anymore, > > > > > if they do, it's their problem. > > > > > > > > I think we need to be backward compatible here. > > > > If the existing app doing what tx_prepare() supposed to do, it shou= ld keep working. > > > > > > It should work, only if they keep doing it as well as call tx_burst() > > > directly, they will likely get lower performance. > > > > > > > > 2. If configured through an API to be defined, tx_burst() can be = split in > > > > > two and applications must call tx_prepare() at some point befo= re > > > > > tx_burst(). > > > > > > > > > > 3. Otherwise tx_burst() should perform the necessary preparation = and checks > > > > > on its own by default (when tx_prepare() is not expected). > > > > > > > > As I said before, I don't think it should be mandatory for tx_burst= () to do what tx_prepare() does. > > > > If some particular implementation of tx_burst() prefers to do thing= s that way - that's fine. > > > > But it shouldn't be required to. > > > > > > You're right, however applications might find it convenient. I think = most > > > will end up with something like the following: > > > > > > if (tx_prepare(pkts)) > > > tx_burst(pkts)); > > > > Looking at existing DPDK apps - most of them do use some sort of TX buf= ferization. > > So, even in a simplistic app it would probably be: > > > > tx_prepare(pkts); > > tx_buffer(pkts); >=20 > We're down to my word against yours here I guess, to leave the choice to > application developers, we'd need to provide tx_prepare() and a simpler > tx_burst() as well as the ability to call tx_burst() directly and still g= et > offloads. >>From what I've seen, most DPDK libs/apps do buffer data packets for TX in o= ne or another way: mtcp, warp17, seastar. Not to mention sample apps. But ok, as said above, if you can prove that tx_burst() you are proposing i= s really much faster then tx_prepare(); tx_burst();=20 I'll be happy to reconsider. >=20 > > > > > 4. We probably still need some mbuf flag to mark mbufs that canno= t be > > > > > modified, the refcount could also serve as a hint. > > > > > > > > If mbuf can't be modified, you probably just wouldn't call the func= tion that supposed to do that, > > > > tx_prepare() in that case. > > > > > > I think it would be easier to document what offload flags may cause t= he > > > tx_burst() function to modify mbuf contents, so applications have the > > > ability to set or strip these flags on a mbuf basis. That way there i= s no > > > need to call tx_prepare() without knowing exactly what it's going to = do. > > > > Not sure I understand what exactly do you propose in the last paragraph= ? >=20 > That for each TX offload flag, we document whether preparation might caus= e a > mbuf to be written to during the tx_prepare()/tx_burst() phase. One of th= e > reasons for tx_prepare() being: >=20 > 4) Fields in packet may require different initialization (like e.g. will > require pseudo-header checksum precalculation, sometimes in a > different way depending on packet type, and so on). Now application > needs to care about it. >=20 > If we determine what offloads may cause mbuf contents to change (all of t= hem > perhaps?), then applications can easily strip those flags from outgoing > "const" mbufs. Then it becomes acceptable for tx_burst() to modify mbuf > contents as per user request, which removes one reason to rely on > tx_prepare() for these. Hmm, I didn't get you here. If let say I don't need TX TCP cksum offload, why would I set this flag ins= ide mbuf at first place? If I do expect PMD to do TX TCP cksum offload for me, then I have to set t= hat flag, otherwise how PMD would know that I did require that offload? Konstantin