[dpdk-dev] [PATCH v3 2/2] mbuf: implement generic format for sched field

Olivier Matz olivier.matz at 6wind.com
Thu Dec 20 09:32:51 CET 2018


Hi Cristian,

On Fri, Dec 14, 2018 at 10:52:18PM +0000, Dumitrescu, Cristian wrote:
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > @@ -34,6 +34,7 @@
> >  #include <stdint.h>
> >  #include <rte_compat.h>
> >  #include <rte_common.h>
> > +#include <rte_color.h>
> >  #include <rte_config.h>
> >  #include <rte_mempool.h>
> >  #include <rte_memory.h>
> > @@ -575,13 +576,24 @@ struct rte_mbuf {
> >  				 */
> >  			} fdir;	/**< Filter identifier if FDIR enabled */
> >  			struct {
> > -				uint32_t lo;
> > -				uint32_t hi;
> > +				uint32_t queue_id;   /**< Queue ID. */
> > +				uint8_t traffic_class;
> > +				/**< Traffic class ID. Traffic class 0
> > +				 * is the highest priority traffic class.
> > +				 */
> > +				uint8_t color;
> > +				/**< Color. @see enum rte_color.*/
> > +				uint16_t reserved;   /**< Reserved. */
> > +			} sched;          /**< Hierarchical scheduler */
> 
> New idea: let's make this an explicit struct rte_mbuf_sched that we instantiate here: struct rte_mbuf_sched sched;

Sorry, I don't really agree here. I think having it inside the mbuf
struct helps to estimate the size of the union here, and it would be
less consistent with other fields.


[...]

> > +/**
> > + * Get the values of mbuf sched queue_id, traffic_class and color.
> > + * @param m
> > + *   Mbuf to read
> > + * @param queue_id
> > + *  Returns the queue id
> > + * @param traffic_class
> > + *  Returns the traffic class id
> > + * @param color
> > + *  Returns the colour id
> > + */
> > +static inline void
> > +rte_mbuf_sched_get(const struct rte_mbuf *m, uint32_t *queue_id,
> > +			uint8_t *traffic_class,
> > +			enum rte_color *color)
> > +{
> > +	*queue_id = m->hash.sched.queue_id;
> > +	*traffic_class = m->hash.sched.traffic_class;
> > +	*color = (enum rte_color)m->hash.sched.color;
> 
> For performance reasons, let's ask the compiler to read all sched fields in a single operation as opposed to 3:
> 
> struct rte_mbuf_sched sched = m->hash.sched;
> *queue_id = sched.queue_id;
> *traffic_class = sched.traffic_class;
> *color = (enum rte_colo)sched.color;

Are you sure it would me more efficient?


Thanks,
Olivier


More information about the dev mailing list