* [PATCH] scsi/fcoe: simplify fcoe_select_cpu() @ 2025-06-04 23:42 Yury Norov 2025-06-05 0:13 ` Bart Van Assche 0 siblings, 1 reply; 4+ messages in thread From: Yury Norov @ 2025-06-04 23:42 UTC (permalink / raw) To: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel Cc: Yury Norov cpumask_next() followed by cpumask_first() opencodes cpumask_next_wrap(). Fix it. Signed-off-by: Yury Norov <yury.norov@gmail.com> --- drivers/scsi/fcoe/fcoe.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index b911fdb387f3..07eddafe52ff 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1312,10 +1312,7 @@ static inline unsigned int fcoe_select_cpu(void) { static unsigned int selected_cpu; - selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); - if (selected_cpu >= nr_cpu_ids) - selected_cpu = cpumask_first(cpu_online_mask); - + selected_cpu = cpumask_next_wrap(selected_cpu, cpu_online_mask); return selected_cpu; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi/fcoe: simplify fcoe_select_cpu() 2025-06-04 23:42 [PATCH] scsi/fcoe: simplify fcoe_select_cpu() Yury Norov @ 2025-06-05 0:13 ` Bart Van Assche 2025-06-05 0:35 ` Yury Norov 0 siblings, 1 reply; 4+ messages in thread From: Bart Van Assche @ 2025-06-05 0:13 UTC (permalink / raw) To: Yury Norov, Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel On 6/5/25 7:42 AM, Yury Norov wrote: > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c > index b911fdb387f3..07eddafe52ff 100644 > --- a/drivers/scsi/fcoe/fcoe.c > +++ b/drivers/scsi/fcoe/fcoe.c > @@ -1312,10 +1312,7 @@ static inline unsigned int fcoe_select_cpu(void) > { > static unsigned int selected_cpu; > > - selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); > - if (selected_cpu >= nr_cpu_ids) > - selected_cpu = cpumask_first(cpu_online_mask); > - > + selected_cpu = cpumask_next_wrap(selected_cpu, cpu_online_mask); > return selected_cpu; > } Why does this algorithm occur in the FCoE driver? Isn't WORK_CPU_UNBOUND good enough for this driver? And if it isn't good enough, shouldn't this kind of functionality be integrated in kernel/workqueue.c rather than having the above algorithm in a kernel driver? Thanks, Bart. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi/fcoe: simplify fcoe_select_cpu() 2025-06-05 0:13 ` Bart Van Assche @ 2025-06-05 0:35 ` Yury Norov 2025-06-05 6:01 ` Hannes Reinecke 0 siblings, 1 reply; 4+ messages in thread From: Yury Norov @ 2025-06-05 0:35 UTC (permalink / raw) To: Bart Van Assche Cc: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel, Tejun Heo, Lai Jiangshan + Tejun, Lai On Thu, Jun 05, 2025 at 08:13:53AM +0800, Bart Van Assche wrote: > On 6/5/25 7:42 AM, Yury Norov wrote: > > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c > > index b911fdb387f3..07eddafe52ff 100644 > > --- a/drivers/scsi/fcoe/fcoe.c > > +++ b/drivers/scsi/fcoe/fcoe.c > > @@ -1312,10 +1312,7 @@ static inline unsigned int fcoe_select_cpu(void) > > { > > static unsigned int selected_cpu; > > - selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); > > - if (selected_cpu >= nr_cpu_ids) > > - selected_cpu = cpumask_first(cpu_online_mask); > > - > > + selected_cpu = cpumask_next_wrap(selected_cpu, cpu_online_mask); > > return selected_cpu; > > } > > Why does this algorithm occur in the FCoE driver? Isn't > WORK_CPU_UNBOUND good enough for this driver? And if it isn't > good enough, shouldn't this kind of functionality be integrated in > kernel/workqueue.c rather than having the above algorithm in a > kernel driver? (I'm obviously not an expert in this driver, and just wanted to cleanup the cpumask API usage.) It looks like the intention is to distribute the workload among CPUs sequentially. If you move this function out of the driver, someone else may call the function, and sequential distribution may get broken. If sequential distribution doesn't matter here, and the real intention is just to distribute workload more or less evenly, we already have cpumask_any_distribute() for this. Thanks, Yury ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi/fcoe: simplify fcoe_select_cpu() 2025-06-05 0:35 ` Yury Norov @ 2025-06-05 6:01 ` Hannes Reinecke 0 siblings, 0 replies; 4+ messages in thread From: Hannes Reinecke @ 2025-06-05 6:01 UTC (permalink / raw) To: Yury Norov, Bart Van Assche Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel, Tejun Heo, Lai Jiangshan On 6/5/25 02:35, Yury Norov wrote: > + Tejun, Lai > > On Thu, Jun 05, 2025 at 08:13:53AM +0800, Bart Van Assche wrote: >> On 6/5/25 7:42 AM, Yury Norov wrote: >>> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c >>> index b911fdb387f3..07eddafe52ff 100644 >>> --- a/drivers/scsi/fcoe/fcoe.c >>> +++ b/drivers/scsi/fcoe/fcoe.c >>> @@ -1312,10 +1312,7 @@ static inline unsigned int fcoe_select_cpu(void) >>> { >>> static unsigned int selected_cpu; >>> - selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); >>> - if (selected_cpu >= nr_cpu_ids) >>> - selected_cpu = cpumask_first(cpu_online_mask); >>> - >>> + selected_cpu = cpumask_next_wrap(selected_cpu, cpu_online_mask); >>> return selected_cpu; >>> } >> >> Why does this algorithm occur in the FCoE driver? Isn't >> WORK_CPU_UNBOUND good enough for this driver? And if it isn't >> good enough, shouldn't this kind of functionality be integrated in >> kernel/workqueue.c rather than having the above algorithm in a >> kernel driver? > > (I'm obviously not an expert in this driver, and just wanted to cleanup > the cpumask API usage.) > > It looks like the intention is to distribute the workload among CPUs > sequentially. If you move this function out of the driver, someone > else may call the function, and sequential distribution may get > broken. > > If sequential distribution doesn't matter here, and the real > intention is just to distribute workload more or less evenly, > we already have cpumask_any_distribute() for this. > This function is used to distribute incoming skbs onto a work cpu. And it's actually quite pointless, as the skb already has a field (skb->sk->sk_incoming_cpu) which tells you exactly on which CPU this skb was received, so we should use that here. I'll send a patch. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-05 6:01 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-04 23:42 [PATCH] scsi/fcoe: simplify fcoe_select_cpu() Yury Norov 2025-06-05 0:13 ` Bart Van Assche 2025-06-05 0:35 ` Yury Norov 2025-06-05 6:01 ` Hannes Reinecke
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.