On Thu, Jan 19, 2023 at 09:59:06PM -0800, Alexei Starovoitov wrote: > On Thu, Jan 19, 2023 at 05:58:32PM -0600, David Vernet wrote: > > + > > +For example: > > + > > +.. code-block:: c > > + > > + /** > > + * A trivial example tracepoint program that shows how to > > + * acquire and release a struct bpf_cpumask *. > > + */ > > + SEC("tp_btf/task_newtask") > > + int BPF_PROG(task_acquire_release_example, struct task_struct *task, u64 clone_flags) > > + { > > + struct bpf_cpumask *cpumask, *acquired; > > + > > + cpumask = bpf_cpumask_create(); > > + if (!cpumask) > > + return 1; > > + > > + acquired = bpf_cpumask_acquire(cpumask); > > + bpf_cpumask_release(cpumask); > > + bpf_cpumask_acquire(acquired); > > + > > + return 0; > > + } > > As the first example in the doc it was... alarming :) > I've read it as it says that bpf_cpumask_acquire has to be called on > freshly created cpumask before it can be used. That's fair, I treated this example like a testcase :-) > I've started to doubt by code reading skills of the previous patches :) > A basic example is probably necessary to introduce the concept. > Or this example should have bpf_cpumask_set_cpu right after create and > more alu ops after release with comments to demonstrate the point. Makes sense. I'll update the examples to be more clear and reflect realistic use cases.