1. 21 Dec, 2019 3 commits
    • Magnus Karlsson's avatar
      xsk: Consolidate to one single cached producer pointer · d7012f05
      Magnus Karlsson authored
      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_head, so move them over to just use cached_prod by skipping
      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.
      Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/1576759171-28550-4-git-send-email-magnus.karlsson@intel.com
      d7012f05
    • Magnus Karlsson's avatar
      xsk: Simplify detection of empty and full rings · 11cc2d21
      Magnus Karlsson authored
      In order to set the correct return flags for poll, the xsk code has to
      check if the Rx queue is empty and if the Tx queue is full. This code
      was unnecessarily large and complex as it used the functions that are
      used to update the local state from the global state (xskq_nb_free and
      xskq_nb_avail). Since we are not doing this nor updating any data
      dependent on this state, we can simplify the functions. Another
      benefit from this is that we can also simplify the xskq_nb_free and
      xskq_nb_avail functions in a later commit.
      Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/1576759171-28550-3-git-send-email-magnus.karlsson@intel.com
      11cc2d21
    • Magnus Karlsson's avatar
      xsk: Eliminate the lazy update threshold · 484b1653
      Magnus Karlsson authored
      The lazy update threshold was introduced to keep the producer and
      consumer some distance apart in the completion ring. This was
      important in the beginning of the development of AF_XDP as the ring
      format as that point in time was very sensitive to the producer and
      consumer being on the same cache line. This is not the case
      anymore as the current ring format does not degrade in any noticeable
      way when this happens. Moreover, this threshold makes it impossible
      to run the system with rings that have less than 128 entries.
      
      So let us remove this threshold and just get one entry from the ring
      as in all other functions. This will enable us to remove this function
      in a later commit. Note that xskq_produce_addr_lazy followed by
      xskq_produce_flush_addr_n are still not the same function as
      xskq_produce_addr() as it operates on another cached pointer.
      Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/1576759171-28550-2-git-send-email-magnus.karlsson@intel.com
      484b1653
  2. 20 Dec, 2019 16 commits
  3. 19 Dec, 2019 21 commits