1. 24 May, 2023 3 commits
    • Andrii Nakryiko's avatar
      Merge branch 'libbpf: capability for resizing datasec maps' · fcf1fa29
      Andrii Nakryiko authored
      JP Kobryn says:
      
      ====================
      Due to the way the datasec maps like bss, data, rodata are memory
      mapped, they cannot be resized with bpf_map__set_value_size() like
      non-datasec maps can. This series offers a way to allow the resizing of
      datasec maps, by having the mapped regions resized as needed and also
      adjusting associated BTF info if possible.
      
      The thought behind this is to allow for use cases where a given datasec
      needs to scale to for example the number of CPU's present. A bpf program
      can have a global array in a data section with an initial length and
      before loading the bpf program, the array length could be extended to
      match the CPU count. The selftests included in this series perform this
      scaling to an arbitrary value to demonstrate how it can work.
      ====================
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      fcf1fa29
    • JP Kobryn's avatar
      libbpf: Selftests for resizing datasec maps · 08b08956
      JP Kobryn authored
      This patch adds test coverage for resizing datasec maps. The first two
      subtests resize the bss and custom data sections. In both cases, an
      initial array (of length one) has its element set to one. After resizing
      the rest of the array is filled with ones as well. A BPF program is then
      run to sum the respective arrays and back on the userspace side the sum
      is checked to be equal to the number of elements.
      The third subtest attempts to perform resizing under conditions that
      will result in either the resize failing or the BTF info being cleared.
      Signed-off-by: default avatarJP Kobryn <inwardvessel@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/bpf/20230524004537.18614-3-inwardvessel@gmail.com
      08b08956
    • JP Kobryn's avatar
      libbpf: Add capability for resizing datasec maps · 9d0a2331
      JP Kobryn authored
      This patch updates bpf_map__set_value_size() so that if the given map is
      memory mapped, it will attempt to resize the mapped region. Initial
      contents of the mapped region are preserved. BTF is not required, but
      after the mapping is resized an attempt is made to adjust the associated
      BTF information if the following criteria is met:
       - BTF info is present
       - the map is a datasec
       - the final variable in the datasec is an array
      
      ... the resulting BTF info will be updated so that the final array
      variable is associated with a new BTF array type sized to cover the
      requested size.
      
      Note that the initial resizing of the memory mapped region can succeed
      while the subsequent BTF adjustment can fail. In this case, BTF info is
      dropped from the map by clearing the key and value type.
      Signed-off-by: default avatarJP Kobryn <inwardvessel@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/bpf/20230524004537.18614-2-inwardvessel@gmail.com
      9d0a2331
  2. 23 May, 2023 7 commits
  3. 20 May, 2023 10 commits
  4. 19 May, 2023 3 commits
  5. 17 May, 2023 17 commits