Message ID | 20230328153535.126223-1-tom.zanussi@linux.intel.com (mailing list archive) |
---|---|
Headers | show |
Series | crypto: Add Intel Analytics Accelerator (IAA) crypto compression driver | expand |
Hi Hillf, On Wed, 2023-03-29 at 15:51 +0800, Hillf Danton wrote: > On 28 Mar 2023 10:35:30 -0500 Tom Zanussi > <tom.zanussi@linux.intel.com> > > +/* > > + * Given a cpu, find the closest IAA instance. The idea is to try > > to > > + * choose the most appropriate IAA instance for a caller and > > spread > > + * available workqueues around to clients. > > + */ > > +static inline int cpu_to_iaa(int cpu) > > +{ > > + int node, n_cpus = 0, test_cpu, iaa = 0; > > + int nr_iaa_per_node, nr_cores_per_iaa; > > + const struct cpumask *node_cpus; > > + > > + if (!nr_nodes) > > + return 0; > > + > > + nr_iaa_per_node = nr_iaa / nr_nodes; > > + if (!nr_iaa_per_node) > > + return 0; > > + > > + nr_cores_per_iaa = nr_cpus_per_node / nr_iaa_per_node; > > + > > + for_each_online_node(node) { > > + node_cpus = cpumask_of_node(node); > > + if (!cpumask_test_cpu(cpu, node_cpus)) > > + continue; > > cpu_to_node(cpu) works for you. Yes, thanks for pointing that out. > > + > > + for_each_cpu(test_cpu, node_cpus) { > > + if ((n_cpus % nr_cpus_per_node) == 0) > > + iaa = node * nr_iaa_per_node; > > + > > + if (test_cpu == cpu) > > + return iaa; > > Given nr_iaa_per_node, why round robin-ing every iaa in the node not > work? True, we should be able to simplify this, will do for the next version. Thanks, Tom > > + > > + n_cpus++; > > + > > + if ((n_cpus % cpus_per_iaa) == 0) > > + iaa++; > > + } > > + } > > + > > + return -1; > > +}