Skip to content

Commit aee1bf1

Browse files
committed
scsi: lpfc: rework lpfc_next_{online,present}_cpu()
lpfc_next_online_cpu() opencodes cpumask_next_and_wrap() by using a for-loop. Use it and make the lpfc_next_online_cpu() a plain one-liner. While there, rework lpfc_next_present_cpu() similarly. Notice that cpumask_next() followed by cpumask_first() in the worst case of an empty mask may traverse the mask twice. Cpumask_next_wrap() takes care of that correctly. Reviewed-by: Justin Tee <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent 6fef7ed commit aee1bf1

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,35 +1715,22 @@ lpfc_phba_elsring(struct lpfc_hba *phba)
17151715
* Note: If no valid cpu found, then nr_cpu_ids is returned.
17161716
*
17171717
**/
1718-
static inline unsigned int
1718+
static __always_inline unsigned int
17191719
lpfc_next_online_cpu(const struct cpumask *mask, unsigned int start)
17201720
{
1721-
unsigned int cpu_it;
1722-
1723-
for_each_cpu_wrap(cpu_it, mask, start) {
1724-
if (cpu_online(cpu_it))
1725-
break;
1726-
}
1727-
1728-
return cpu_it;
1721+
return cpumask_next_and_wrap(start, mask, cpu_online_mask);
17291722
}
1723+
17301724
/**
17311725
* lpfc_next_present_cpu - Finds next present CPU after n
17321726
* @n: the cpu prior to search
17331727
*
17341728
* Note: If no next present cpu, then fallback to first present cpu.
17351729
*
17361730
**/
1737-
static inline unsigned int lpfc_next_present_cpu(int n)
1731+
static __always_inline unsigned int lpfc_next_present_cpu(int n)
17381732
{
1739-
unsigned int cpu;
1740-
1741-
cpu = cpumask_next(n, cpu_present_mask);
1742-
1743-
if (cpu >= nr_cpu_ids)
1744-
cpu = cpumask_first(cpu_present_mask);
1745-
1746-
return cpu;
1733+
return cpumask_next_wrap(n, cpu_present_mask);
17471734
}
17481735

17491736
/**

0 commit comments

Comments
 (0)