• David Vernet's avatar
    bpf: Remove bpf_cpumask_kptr_get() kfunc · 1b403ce7
    David Vernet authored
    Now that struct bpf_cpumask is RCU safe, there's no need for this kfunc.
    Rather than doing the following:
    
    private(MASK) static struct bpf_cpumask __kptr *global;
    
    int BPF_PROG(prog, s32 cpu, ...)
    {
    	struct bpf_cpumask *cpumask;
    
    	bpf_rcu_read_lock();
    	cpumask = bpf_cpumask_kptr_get(&global);
    	if (!cpumask) {
    		bpf_rcu_read_unlock();
    		return -1;
    	}
    	bpf_cpumask_setall(cpumask);
    	...
    	bpf_cpumask_release(cpumask);
    	bpf_rcu_read_unlock();
    }
    
    Programs can instead simply do (assume same global cpumask):
    
    int BPF_PROG(prog, ...)
    {
    	struct bpf_cpumask *cpumask;
    
    	bpf_rcu_read_lock();
    	cpumask = global;
    	if (!cpumask) {
    		bpf_rcu_read_unlock();
    		return -1;
    	}
    	bpf_cpumask_setall(cpumask);
    	...
    	bpf_rcu_read_unlock();
    }
    
    In other words, no extra atomic acquire / release, and less boilerplate
    code.
    
    This patch removes both the kfunc, as well as its selftests and
    documentation.
    Signed-off-by: default avatarDavid Vernet <void@manifault.com>
    Link: https://lore.kernel.org/r/20230316054028.88924-5-void@manifault.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    1b403ce7
cpumask_success.c 7.74 KB