)]}'
{
  "commit": "0ae6b8ce200da00a78f33c055fdc4fe3225d22ec",
  "tree": "90daaec447f3b74f329c453bdc264f7178840906",
  "parents": [
    "04a80a34c22f4db245f553d8696d1318d1c00ece"
  ],
  "author": {
    "name": "Steven Rostedt",
    "email": "rostedt@goodmis.org",
    "time": "Wed Apr 09 11:15:50 2025 -0400"
  },
  "committer": {
    "name": "Steven Rostedt (Google)",
    "email": "rostedt@goodmis.org",
    "time": "Fri Apr 11 16:02:08 2025 -0400"
  },
  "message": "ftrace: Fix accounting of subop hashes\n\nThe function graph infrastructure uses ftrace to hook to functions. It has\na single ftrace_ops to manage all the users of function graph. Each\nindividual user (tracing, bpf, fprobes, etc) has its own ftrace_ops to\ntrack the functions it will have its callback called from. These\nftrace_ops are \"subops\" to the main ftrace_ops of the function graph\ninfrastructure.\n\nEach ftrace_ops has a filter_hash and a notrace_hash that is defined as:\n\n  Only trace functions that are in the filter_hash but not in the\n  notrace_hash.\n\nIf the filter_hash is empty, it means to trace all functions.\nIf the notrace_hash is empty, it means do not disable any function.\n\nThe function graph main ftrace_ops needs to be a superset containing all\nthe functions to be traced by all the subops it has. The algorithm to\nperform this merge was incorrect.\n\nWhen the first subops was added to the main ops, it simply made the main\nops a copy of the subops (same filter_hash and notrace_hash).\n\nWhen a second ops was added, it joined the new subops filter_hash with the\nmain ops filter_hash as a union of the two sets. The intersect between the\nnew subops notrace_hash and the main ops notrace_hash was created as the\nnew notrace_hash of the main ops.\n\nThe issue here is that it would then start tracing functions than no\nsubops were tracing. For example if you had two subops that had:\n\nsubops 1:\n\n  filter_hash \u003d \u0027*sched*\u0027 # trace all functions with \"sched\" in it\n  notrace_hash \u003d \u0027*time*\u0027 # except do not trace functions with \"time\"\n\nsubops 2:\n\n  filter_hash \u003d \u0027*lock*\u0027 # trace all functions with \"lock\" in it\n  notrace_hash \u003d \u0027*clock*\u0027 # except do not trace functions with \"clock\"\n\nThe intersect of \u0027*time*\u0027 functions with \u0027*clock*\u0027 functions could be the\nempty set. That means the main ops will be tracing all functions with\n\u0027*time*\u0027 and all \"*clock*\" in it!\n\nInstead, modify the algorithm to be a bit simpler and correct.\n\nFirst, when adding a new subops, even if it\u0027s the first one, do not add\nthe notrace_hash if the filter_hash is not empty. Instead, just add the\nfunctions that are in the filter_hash of the subops but not in the\nnotrace_hash of the subops into the main ops filter_hash. There\u0027s no\nreason to add anything to the main ops notrace_hash.\n\nThe notrace_hash of the main ops should only be non empty iff all subops\nfilter_hashes are empty (meaning to trace all functions) and all subops\nnotrace_hashes include the same functions.\n\nThat is, the main ops notrace_hash is empty if any subops filter_hash is\nnon empty.\n\nThe main ops notrace_hash only has content in it if all subops\nfilter_hashes are empty, and the content are only functions that intersect\nall the subops notrace_hashes. If any subops notrace_hash is empty, then\nso is the main ops notrace_hash.\n\nCc: Masami Hiramatsu \u003cmhiramat@kernel.org\u003e\nCc: Mark Rutland \u003cmark.rutland@arm.com\u003e\nCc: Mathieu Desnoyers \u003cmathieu.desnoyers@efficios.com\u003e\nCc: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nCc: Shuah Khan \u003cskhan@linuxfoundation.org\u003e\nCc: Andy Chiu \u003candybnac@gmail.com\u003e\nLink: https://lore.kernel.org/20250409152720.216356767@goodmis.org\nSigned-off-by: Steven Rostedt (Google) \u003crostedt@goodmis.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8939eeebb02e28e7835a4b18853b050f34992440",
      "old_mode": 33188,
      "old_path": "kernel/trace/ftrace.c",
      "new_id": "a8a02868b43588c3c2581b5387c1707fe1321737",
      "new_mode": 33188,
      "new_path": "kernel/trace/ftrace.c"
    }
  ]
}
