Re: [PATCH v7 5/6] kernfs: Use RCU to access kernfs_node::parent.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2/10/25 12:43 AM, Sebastian Andrzej Siewior wrote:
On 2025-02-03 14:50:22 [+0100], To cgroups@xxxxxxxxxxxxxxx wrote:
kernfs_rename_lock is used to obtain stable kernfs_node::{name|parent}
pointer. This is a preparation to access kernfs_node::parent under RCU
and ensure that the pointer remains stable under the RCU lifetime
guarantees.
…

The robot complained that the selftests for bpf broke. As it turns out,
the tests access kernfs_node::{parent|name} and after the rename
::parent is gone so it does not compile.
If there are no objections, I would merge this into 5/6 and repost.
"test_progs -a test_profiler" passes.

diff --git a/tools/testing/selftests/bpf/progs/profiler.inc.h b/tools/testing/selftests/bpf/progs/profiler.inc.h
index 8bd1ebd7d6afd..a4f518ee5f4de 100644
--- a/tools/testing/selftests/bpf/progs/profiler.inc.h
+++ b/tools/testing/selftests/bpf/progs/profiler.inc.h
@@ -223,7 +223,7 @@ static INLINE void* read_full_cgroup_path(struct kernfs_node* cgroup_node,
  		if (bpf_cmp_likely(filepart_length, <=, MAX_PATH)) {
  			payload += filepart_length;
  		}
-		cgroup_node = BPF_CORE_READ(cgroup_node, parent);
+		cgroup_node = BPF_CORE_READ(cgroup_node, __parent);
  	}
  	return payload;
  }
@@ -300,6 +300,7 @@ static INLINE void* populate_cgroup_info(struct cgroup_data_t* cgroup_data,
  	cgroup_data->cgroup_proc_length = 0;
  	cgroup_data->cgroup_full_length = 0;
+ bpf_rcu_read_lock();
  	size_t cgroup_root_length =
  		bpf_probe_read_kernel_str(payload, MAX_PATH,
  					  BPF_CORE_READ(root_kernfs, name));
@@ -323,6 +324,7 @@ static INLINE void* populate_cgroup_info(struct cgroup_data_t* cgroup_data,
  		cgroup_data->cgroup_full_length = payload_end_pos - payload;
  		payload = payload_end_pos;
  	}
+	bpf_rcu_read_unlock();

All programs calling this function populate_cgroup_info() is not sleepable program
so the whole prog is protected by rcu and there is no need for above
bpf_rcu_read_{lock,unlock}().

return (void*)payload;
  }





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux