On Tue, Dec 10, 2019 at 1:43 AM Martin Lau <kafai@xxxxxx> wrote: > > On Mon, Dec 09, 2019 at 08:56:19AM +0100, Magnus Karlsson wrote: > > Currently, the xsk ring code has two cached producer pointers: > > prod_head and prod_tail. This patch consolidates these two into a > > single one called cached_prod to make the code simpler and easier to > > maintain. This will be in line with the user space part of the the > > code found in libbpf, that only uses a single cached pointer. > > > > The Rx path only uses the two top level functions > > xskq_produce_batch_desc and xskq_produce_flush_desc and they both use > > prod_head and never prod_tail. So just move them over to > > cached_prod. > > > > The Tx XDP_DRV path uses xskq_produce_addr_lazy and > > xskq_produce_flush_addr_n and unnecessarily operates on both prod_tail > > and prod_cons, so move them over to just use cached_prod by skipping > prod_cons or prod_head? Thanks. It should read prod_head. Will fix in a v2. /Magnus > > the intermediate step of updating prod_tail. > > > > The Tx path in XDP_SKB mode uses xskq_reserve_addr and > > xskq_produce_addr. They currently use both cached pointers, but we can > > operate on the global producer pointer in xskq_produce_addr since it > > has to be updated anyway, thus eliminating the use of both cached > > pointers. We can also remove the xskq_nb_free in xskq_produce_addr > > since it is already called in xskq_reserve_addr. No need to do it > > twice. > > > > When there is only one cached producer pointer, we can also simplify > > xskq_nb_free by removing one argument.