1. 15 Aug, 2023 5 commits
    • Joel Granados's avatar
      sysctl: Add a size arg to __register_sysctl_table · bff97cf1
      Joel Granados authored
      We make these changes in order to prepare __register_sysctl_table and
      its callers for when we remove the sentinel element (empty element at
      the end of ctl_table arrays). We don't actually remove any sentinels in
      this commit, but we *do* make sure to use ARRAY_SIZE so the table_size
      is available when the removal occurs.
      
      We add a table_size argument to __register_sysctl_table and adjust
      callers, all of which pass ctl_table pointers and need an explicit call
      to ARRAY_SIZE. We implement a size calculation in register_net_sysctl in
      order to forward the size of the array pointer received from the network
      register calls.
      
      The new table_size argument does not yet have any effect in the
      init_header call which is still dependent on the sentinel's presence.
      table_size *does* however drive the `kzalloc` allocation in
      __register_sysctl_table with no adverse effects as the allocated memory
      is either one element greater than the calculated ctl_table array (for
      the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size
      of the calculated ctl_table array (for the call from sysctl_net.c and
      register_sysctl). This approach will allows us to "just" remove the
      sentinel without further changes to __register_sysctl_table as
      table_size will represent the exact size for all the callers at that
      point.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      bff97cf1
    • Joel Granados's avatar
      sysctl: Add size argument to init_header · b1f01e2b
      Joel Granados authored
      In this commit, we add a table_size argument to the init_header function
      in order to initialize the ctl_table_size variable in ctl_table_header.
      Even though the size is not yet used, it is now initialized within the
      sysctl subsys. We need this commit for when we start adding the
      table_size arguments to the sysctl functions (e.g. register_sysctl,
      __register_sysctl_table and __register_sysctl_init).
      
      Note that in __register_sysctl_table we temporarily use a calculated
      size until we add the size argument to that function in subsequent
      commits.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      b1f01e2b
    • Joel Granados's avatar
      sysctl: Add ctl_table_size to ctl_table_header · 1e887723
      Joel Granados authored
      The new ctl_table_size element will hold the size of the ctl_table
      arrays contained in the ctl_table_header. This value should eventually
      be passed by the callers to the sysctl register infrastructure. And
      while this commit introduces the variable, it does not set nor use it
      because that requires case by case considerations for each caller.
      
      It provides two important things: (1) A place to put the
      result of the ctl_table array calculation when it gets introduced for
      each caller. And (2) the size that will be used as the additional
      stopping criteria in the list_for_each_table_entry macro (to be added
      when all the callers are migrated)
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      1e887723
    • Joel Granados's avatar
      sysctl: Use ctl_table_header in list_for_each_table_entry · 18d4b42e
      Joel Granados authored
      We replace the ctl_table with the ctl_table_header pointer in
      list_for_each_table_entry which is the macro responsible for traversing
      the ctl_table arrays. This is a preparation commit that will make it
      easier to add the ctl_table array size (that will be added to
      ctl_table_header in subsequent commits) to the already existing loop
      logic based on empty ctl_table elements (so called sentinels).
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      18d4b42e
    • Joel Granados's avatar
      sysctl: Prefer ctl_table_header in proc_sysctl · cc9f7ee0
      Joel Granados authored
      This is a preparation commit that replaces ctl_table with
      ctl_table_header as the pointer that is passed around in proc_sysctl.c.
      This will become necessary in subsequent commits when the size of the
      ctl_table array can no longer be calculated by searching for an empty
      sentinel (last empty ctl_table element) but will be carried along inside
      the ctl_table_header struct.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      cc9f7ee0
  2. 09 Jul, 2023 10 commits
  3. 08 Jul, 2023 25 commits