Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jul 17, 2024
  2. Jul 10, 2024
  3. Jul 05, 2024
  4. Jun 14, 2024
  5. Jun 11, 2024
  6. May 22, 2024
    • Steven Rostedt (Google)'s avatar
      tracing/treewide: Remove second parameter of __assign_str() · 2c92ca84
      Steven Rostedt (Google) authored
      With the rework of how the __string() handles dynamic strings where it
      saves off the source string in field in the helper structure[1], the
      assignment of that value to the trace event field is stored in the helper
      value and does not need to be passed in again.
      
      This means that with:
      
        __string(field, mystring)
      
      Which use to be assigned with __assign_str(field, mystring), no longer
      needs the second parameter and it is unused. With this, __assign_str()
      will now only get a single parameter.
      
      There's over 700 users of __assign_str() and because coccinelle does not
      handle the TRACE_EVENT() macro I ended up using the following sed script:
      
        git grep -l __assign_str | while read a ; do
            sed -e 's/\(__assign_str([^,]*[^ ,]\) *,[^;]*/\1)/' $a > /tmp/test-file;
            mv /tmp/test-file $a;
        done
      
      I then searched for __assign_str() that did not end with ';' as those
      were multi line assignments that the sed script above would fail to catch.
      
      Note, the...
      2c92ca84
  7. May 21, 2024
  8. May 13, 2024
  9. May 09, 2024
    • Masahiro Yamada's avatar
      kbuild: use $(src) instead of $(srctree)/$(src) for source directory · b1992c37
      Masahiro Yamada authored
      Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
      checked-in source files. It is merely a convention without any functional
      difference. In fact, $(obj) and $(src) are exactly the same, as defined
      in scripts/Makefile.build:
      
          src := $(obj)
      
      When the kernel is built in a separate output directory, $(src) does
      not accurately reflect the source directory location. While Kbuild
      resolves this discrepancy by specifying VPATH=$(srctree) to search for
      source files, it does not cover all cases. For example, when adding a
      header search path for local headers, -I$(srctree)/$(src) is typically
      passed to the compiler.
      
      This introduces inconsistency between upstream and downstream Makefiles
      because $(src) is used instead of $(srctree)/$(src) for the latter.
      
      To address this inconsistency, this commit changes the semantics of
      $(src) so that it always points to the directory in the source tree.
      
      Going forward, the variables used ...
      b1992c37
  10. May 08, 2024
  11. May 04, 2024
  12. Apr 29, 2024
  13. Apr 16, 2024
  14. Mar 18, 2024
  15. Mar 08, 2024
  16. Mar 05, 2024
  17. Feb 29, 2024
    • Kees Cook's avatar
      bpf: Replace bpf_lpm_trie_key 0-length array with flexible array · 896880ff
      Kees Cook authored
      
      Replace deprecated 0-length array in struct bpf_lpm_trie_key with
      flexible array. Found with GCC 13:
      
      ../kernel/bpf/lpm_trie.c:207:51: warning: array subscript i is outside array bounds of 'const __u8[0]' {aka 'const unsigned char[]'} [-Warray-bounds=]
        207 |                                        *(__be16 *)&key->data[i]);
            |                                                   ^~~~~~~~~~~~~
      ../include/uapi/linux/swab.h:102:54: note: in definition of macro '__swab16'
        102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
            |                                                      ^
      ../include/linux/byteorder/generic.h:97:21: note: in expansion of macro '__be16_to_cpu'
         97 | #define be16_to_cpu __be16_to_cpu
            |                     ^~~~~~~~~~~~~
      ../kernel/bpf/lpm_trie.c:206:28: note: in expansion of macro 'be16_to_cpu'
        206 |                 u16 diff = be16_to_cpu(*(__be16 *)&node->data[i]
      ^
            |                            ^~~~~~~~~~~
      In file included from ../include/linux/bpf.h:7:
      ../include/uapi/linux/bpf.h:82:17: note: while referencing 'data'
         82 |         __u8    data[0];        /* Arbitrary size */
            |                 ^~~~
      
      And found at run-time under CONFIG_FORTIFY_SOURCE:
      
        UBSAN: array-index-out-of-bounds in kernel/bpf/lpm_trie.c:218:49
        index 0 is out of range for type '__u8 [*]'
      
      Changing struct bpf_lpm_trie_key is difficult since has been used by
      userspace. For example, in Cilium:
      
      	struct egress_gw_policy_key {
      	        struct bpf_lpm_trie_key lpm_key;
      	        __u32 saddr;
      	        __u32 daddr;
      	};
      
      While direct references to the "data" member haven't been found, there
      are static initializers what include the final member. For example,
      the "{}" here:
      
              struct egress_gw_policy_key in_key = {
                      .lpm_key = { 32 + 24, {} },
                      .saddr   = CLIENT_IP,
                      .daddr   = EXTERNAL_SVC_IP & 0Xffffff,
              };
      
      To avoid the build time and run time warnings seen with a 0-sized
      trailing array for struct bpf_lpm_trie_key, introduce a new struct
      that correctly uses a flexible array for the trailing bytes,
      struct bpf_lpm_trie_key_u8. As part of this, include the "header"
      portion (which is just the "prefixlen" member), so it can be used
      by anything building a bpf_lpr_trie_key that has trailing members that
      aren't a u8 flexible array (like the self-test[1]), which is named
      struct bpf_lpm_trie_key_hdr.
      
      Unfortunately, C++ refuses to parse the __struct_group() helper, so
      it is not possible to define struct bpf_lpm_trie_key_hdr directly in
      struct bpf_lpm_trie_key_u8, so we must open-code the union directly.
      
      Adjust the kernel code to use struct bpf_lpm_trie_key_u8 through-out,
      and for the selftest to use struct bpf_lpm_trie_key_hdr. Add a comment
      to the UAPI header directing folks to the two new options.
      
      Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Closes: https://paste.debian.net/hidden/ca500597/
      Link: https://lore.kernel.org/all/202206281009.4332AA33@keescook/ [1]
      Link: https://lore.kernel.org/bpf/20240222155612.it.533-kees@kernel.org
      896880ff
  18. Feb 12, 2024
  19. Feb 09, 2024
    • Linus Torvalds's avatar
      work around gcc bugs with 'asm goto' with outputs · 4356e9f8
      Linus Torvalds authored
      We've had issues with gcc and 'asm goto' before, and we created a
      'asm_volatile_goto()' macro for that in the past: see commits
      3f0116c3 ("compiler/gcc4: Add quirk for 'asm goto' miscompilation
      bug") and a9f18034 ("compiler/gcc4: Make quirk for
      asm_volatile_goto() unconditional").
      
      Then, much later, we ended up removing the workaround in commit
      43c249ea ("compiler-gcc.h: remove ancient workaround for gcc PR
      58670") because we no longer supported building the kernel with the
      affected gcc versions, but we left the macro uses around.
      
      Now, Sean Christopherson reports a new version of a very similar
      problem, which is fixed by re-applying that ancient workaround.  But the
      problem in question is limited to only the 'asm goto with outputs'
      cases, so instead of re-introducing the old workaround as-is, let's
      rename and limit the workaround to just that much less common case.
      
      It looks like there are at least two separate issues that all hit in
      this area...
      4356e9f8
  20. Jan 24, 2024
  21. Jan 17, 2024
  22. Dec 20, 2023
  23. Dec 18, 2023
    • Steven Rostedt (Google)'s avatar
      tracing: Allow creating instances with specified system events · d2356997
      Steven Rostedt (Google) authored
      A trace instance may only need to enable specific events. As the eventfs
      directory of an instance currently creates all events which adds overhead,
      allow internal instances to be created with just the events in systems
      that they care about. This currently only deals with systems and not
      individual events, but this should bring down the overhead of creating
      instances for specific use cases quite bit.
      
      The trace_array_get_by_name() now has another parameter "systems". This
      parameter is a const string pointer of a comma/space separated list of
      event systems that should be created by the trace_array. (Note if the
      trace_array already exists, this parameter is ignored).
      
      The list of systems is saved and if a module is loaded, its events will
      not be added unless the system for those events also match the systems
      string.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20231213093701.03fddec0@gandalf.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel....
      d2356997
  24. Dec 13, 2023
  25. Dec 10, 2023
    • Dmitry Rokosov's avatar
      samples/cgroup: introduce memcg memory.events listener · becf6529
      Dmitry Rokosov authored
      This is a simple listener for memory events that handles counter changes
      in runtime.  It can be set up for a specific memory cgroup v2.
      
      The output example:
      =====
      $ /tmp/memcg_event_listener test
      Initialized MEMCG events with counters:
      MEMCG events:
      	low: 0
      	high: 0
      	max: 0
      	oom: 0
      	oom_kill: 0
      	oom_group_kill: 0
      Started monitoring memory events from '/sys/fs/cgroup/test/memory.events'...
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 1 MEMCG oom_kill event, change counter 0 => 1
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 1 MEMCG oom_kill event, change counter 1 => 2
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 1 MEMCG oom_kill event, change counter 2 => 3
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 1 MEMCG oom_kill event, change counter 3 => 4
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 2 MEMCG max events, change counter 0 => 2
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 8 MEMCG max events, change counter 2 => 10
      *** 1 MEMCG oom event, change counter 0 => 1
      Received event in /sys/fs/cgroup/test/memory.events:
      *** 1 MEMCG oom_kill event, change counter 4 => 5
      ^CExiting memcg event listener...
      =====
      
      Link: https://lkml.kernel.org/r/20231123071945.25811-3-ddrokosov@salutedevices.com
      
      
      Signed-off-by: default avatarDmitry Rokosov <ddrokosov@salutedevices.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Shakeel Butt <shakeelb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      becf6529
    • Dmitry Rokosov's avatar
      samples: introduce new samples subdir for cgroup · 60433a9d
      Dmitry Rokosov authored
      Patch series "samples: introduce cgroup events listeners", v3.
      
      To begin with, this patch series relocates the cgroup example code to the
      samples/cgroup directory, which is the appropriate location for such code
      snippets.
      
      Furthermore, a new memcg events listener is introduced.  This listener is
      a simple yet effective tool for monitoring memory events and managing
      counter changes during runtime.
      
      Additionally, as per Andrew Morton's suggestion, a helpful reminder
      comment is included in the memcontrol implementation.  This comment serves
      to ensure that the samples code is updated whenever new events are added.
      
      
      This patch (of 3):
      
      Move the cgroup_event_listener for cgroup v1 to the samples directory. 
      This suggestion was proposed by Andrew Morton during the discussion [1].
      
      Link: https://lore.kernel.org/all/20231106140934.3f5d4960141562fe8da53906@linux-foundation.org/ [1]
      Link: https://lkml.kernel.org/r/20231123071945.25811-1-ddrokosov@salutedevices.com
      Link: https://lkml.kernel.org/r/20231123071945.25811-2-ddrokosov@salutedevices.com
      
      
      Signed-off-by: default avatarDmitry Rokosov <ddrokosov@salutedevices.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Shakeel Butt <shakeelb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      60433a9d
  26. Nov 30, 2023
  27. Nov 28, 2023
  28. Nov 23, 2023
  29. Oct 26, 2023
  30. Oct 24, 2023