On Mon, Feb 17, 2025 at 12:24:19PM -0500, Yury Norov wrote: > On Mon, Feb 17, 2025 at 02:41:27PM +0100, Andrea Righi wrote: > > On Fri, Feb 14, 2025 at 04:28:57PM -0500, Yury Norov wrote: > > > On Fri, Feb 14, 2025 at 08:40:07PM +0100, Andrea Righi wrote: > > ... > > > > +/** > > > > + * scx_bpf_get_idle_cpumask_node - Get a referenced kptr to the > > > > + * idle-tracking per-CPU cpumask of a target NUMA node. > > > > + * > > > > + * Returns an empty cpumask if idle tracking is not enabled, if @node is > > > > + * not valid, or running on a UP kernel. In this case the actual error will > > > > + * be reported to the BPF scheduler via scx_ops_error(). > > > > + */ > > > > +__bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask_node(int node) > > > > +{ > > > > + node = validate_node(node); > > > > + if (node < 0) > > > > + return cpu_none_mask; > > > > + > > > > +#ifdef CONFIG_SMP > > > > + return idle_cpumask(node)->cpu; > > > > +#else > > > > + return cpu_none_mask; > > > > +#endif > > > > > > Here you need to check for SMP at the beginning. That way you can > > > avoid calling validate_node() if SMP is disabled. > > > > As mentioned in the other email, I'm not sure if we want to skip > > validate_node() in the UP case. > > > > I guess the question is: should we completely ignore the node argument, > > since it doesn't make sense in the UP case, or should we still validate it, > > given that node == 0 is still valid in this scenario? > > Ok, I see. You don't promote the error from validate_node(), but you > print something inside. Right, it calls scx_ops_error() inside, that prints the error and also forces the active BPF scheduler to exit (it's like an exception for the BPF scheduler basically). -Andrea