Skip to contentSkip to conversation

possible power of two cleanup?

KJ Jaco Kroon 1 participant 1 message Apr 16, 2007 Kernel janitors

lore
Share & tools
lore

Jaco Kroon

author
#0 lore raw

Hi guys,

Just stumbled upon this in include/linux/blockgroup_lock.h

It looks like it essentially does a round up to the nearest power of two of NR_CPUS * 4? Is this a potential cleanup? Prevent breakage when we start having more than 64 CPUs in a machine?

/*
* We want a power-of-two. Is there a better way than this? */

#if NR_CPUS >= 32
#define NR_BG_LOCKS 128
#elif NR_CPUS >= 16
#define NR_BG_LOCKS 64
#elif NR_CPUS >= 8
#define NR_BG_LOCKS 32
#elif NR_CPUS >= 4
#define NR_BG_LOCKS 16
#elif NR_CPUS >= 2
#define NR_BG_LOCKS 8
#else
#define NR_BG_LOCKS 4
#endif

Jaco
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors