Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS

From: William Lee Irwin III
Date: Sun Aug 01 2004 - 07:42:07 EST


On Sun, Aug 01, 2004 at 03:22:56AM -0400, Zwane Mwaikambo wrote:
> NR_CPUS was 3, the test case may as well be passing first_cpu or next_cpu
> a value of 0 for the map. The "bug" in the i386 find_next_bit really
> looks like a feature if you look at the code.

Hmm. I'm actually somewhat puzzled by this also. Shouldn't things only
check for inequalities between the results of these and NR_CPUS? i.e.
things like:
if (any_online_cpu(cpus) >= NR_CPUS)
and
for (cpu = first_cpu(cpus); cpu < NR_CPUS; cpu = next_cpu(cpus))
etc.?

Maybe the few callers that are sensitive to the precise return value
should use min_t(int, NR_CPUS, ...) instead of all callers taking the
branch on behalf of those few.


-- wli
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/