Re: Another (ESP?) scsi blk-mq problem on sparc64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/24/2014 09:22 AM, Paul E. McKenney wrote:
On Mon, Nov 24, 2014 at 08:35:46AM -0700, Jens Axboe wrote:
On 11/24/2014 01:21 AM, Christoph Hellwig wrote:
On Fri, Nov 21, 2014 at 02:56:00PM -0500, David Miller wrote:
I would suggest looking into the possibility that we allocate the memory
using the count of valid cpus, rather than the largest cpu number.

That's a common error that runs into problems with discontiguous
cpu numbering like Sparc sometimes has.

Yes, that does look like the case.  Do you have a good trick on how
to allocate a map for the highest possible cpu number without first
iterating the cpu map?  I couldn't find something that looks like a
highest_possible_cpu() helper.

Honestly I think that num_posible_cpus() should return the max of
number of CPUs (weigt), and the highest numbered CPU. It's a pain in
the butt to handle this otherwise.

Hear, hear!!!  That would make my life easier, and would make this sort
of problem much less likely to occur!

How about this one?

--
Jens Axboe

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 0a9a6da21e74..db21f68aaef0 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -83,7 +83,13 @@ extern const struct cpumask *const cpu_active_mask;
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(cpu_online_mask)
-#define num_possible_cpus()	cpumask_weight(cpu_possible_mask)
+/*
+ * For platforms with discontig CPU numbering, the weight of the possible
+ * bitmask may be less than the highest numbered CPU. Return the max of
+ * the two, to prevent accidentical bugs.
+ */
+#define num_possible_cpus()	\
+	max_t(unsigned int, cpumask_weight(cpu_possible_mask), nr_cpu_ids)
 #define num_present_cpus()	cpumask_weight(cpu_present_mask)
 #define num_active_cpus()	cpumask_weight(cpu_active_mask)
 #define cpu_online(cpu)		cpumask_test_cpu((cpu), cpu_online_mask)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux