Re: [PATCH bpf-next v3 2/7] bpf: Enable cpumasks to be queried and used as kptrs

From: David Vernet
Date: Wed Jan 25 2023 - 11:13:35 EST


On Wed, Jan 25, 2023 at 08:01:49AM -0800, Alexei Starovoitov wrote:
> On Wed, Jan 25, 2023 at 6:38 AM David Vernet <void@xxxxxxxxxxxxx> wrote:
> > +
> > +void bpf_cpumask_set_cpu(u32 cpu, struct bpf_cpumask *cpumask)
> > +{
> > + if (!cpu_valid(cpu))
> > + return;
> > +
> > + cpumask_set_cpu(cpu, (struct cpumask *)cpumask);
>
> I was considering suggesting to use &cpumask->cpumask here and
> in other cases, but figured it's better to leave it as-is,
> since bpf prog will be doing this cast, so it matches.
> Maybe some build assertion is necessary to make sure it's the first member.
> Probably overkill as well.

IMO a build assertion is a good idea. Serves as documentation and a
sanity check. I'll send it out in a follow-on patch, unless you really
think it's overkill.

>
> Applied.