1. 14 Jan, 2022 1 commit
  2. 07 Jan, 2022 1 commit
    • David Vernet's avatar
      livepatch: Avoid CPU hogging with cond_resched · f5bdb34b
      David Vernet authored
      When initializing a 'struct klp_object' in klp_init_object_loaded(), and
      performing relocations in klp_resolve_symbols(), klp_find_object_symbol()
      is invoked to look up the address of a symbol in an already-loaded module
      (or vmlinux). This, in turn, calls kallsyms_on_each_symbol() or
      module_kallsyms_on_each_symbol() to find the address of the symbol that is
      being patched.
      
      It turns out that symbol lookups often take up the most CPU time when
      enabling and disabling a patch, and may hog the CPU and cause other tasks
      on that CPU's runqueue to starve -- even in paths where interrupts are
      enabled.  For example, under certain workloads, enabling a KLP patch with
      many objects or functions may cause ksoftirqd to be starved, and thus for
      interrupts to be backlogged and delayed. This may end up causing TCP
      retransmits on the host where the KLP patch is being applied, and in
      general, may cause any interrupts serviced by softirqd to be delayed while
      the patch is being applied.
      
      So as to ensure that kallsyms_on_each_symbol() does not end up hogging the
      CPU, this patch adds a call to cond_resched() in kallsyms_on_each_symbol()
      and module_kallsyms_on_each_symbol(), which are invoked when doing a symbol
      lookup in vmlinux and a module respectively.  Without this patch, if a
      live-patch is applied on a 36-core Intel host with heavy TCP traffic, a
      ~10x spike is observed in TCP retransmits while the patch is being applied.
      Additionally, collecting sched events with perf indicates that ksoftirqd is
      awakened ~1.3 seconds before it's eventually scheduled.  With the patch, no
      increase in TCP retransmit events is observed, and ksoftirqd is scheduled
      shortly after it's awakened.
      Signed-off-by: default avatarDavid Vernet <void@manifault.com>
      Acked-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Acked-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20211229215646.830451-1-void@manifault.com
      f5bdb34b
  3. 04 Jan, 2022 2 commits
  4. 23 Dec, 2021 1 commit
    • David Vernet's avatar
      Documentation: livepatch: Add livepatch API page · e368cd72
      David Vernet authored
      The livepatch subsystem has several exported functions and objects with
      kerneldoc comments. Though the livepatch documentation contains handwritten
      descriptions of all of these exported functions, they are currently not
      pulled into the docs build using the kernel-doc directive.
      
      In order to allow readers of the documentation to see the full kerneldoc
      comments in the generated documentation files, this change adds a new
      Documentation/livepatch/api.rst page which contains kernel-doc directives
      to link the kerneldoc comments directly in the documentation.  With this,
      all of the hand-written descriptions of the APIs now cross-reference the
      kerneldoc comments on the new Livepatching APIs page, and running
      ./scripts/find-unused-docs.sh on kernel/livepatch no longer shows any files
      as missing documentation.
      
      Note that all of the handwritten API descriptions were left alone with the
      exception of Documentation/livepatch/system-state.rst, which was updated to
      allow the cross-referencing to work correctly. The file now follows the
      cross-referencing formatting guidance specified in
      Documentation/doc-guide/kernel-doc.rst. Furthermore, some comments around
      klp_shadow_free_all() were updated to say <_, id> rather than <*, id> to
      match the rest of the file, and to prevent the docs build from emitting an
      "Inline emphasis start-string without end string" error.
      Signed-off-by: default avatarDavid Vernet <void@manifault.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Acked-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20211221145743.4098360-1-void@manifault.com
      e368cd72
  5. 03 Sep, 2021 35 commits