Re: [RFC] CPUMASK: proposal for replacing cpumask_t

From: Mike Travis
Date: Thu Sep 11 2008 - 11:05:17 EST


Peter Zijlstra wrote:
...
>> So in function prototypes:
>>
>> cpumask_t function(const cpumask_t *A,
>> cpumask_t *B,
>> cpumask_t cpumask_C)
>>
>> becomes:
>>
>> cpumask_val function(cpumask_t A,
>> cpumask_var B,
>> cpumask_t cpumask_C)
>
> I guess we have to stick the const into the typedef otherwise we get a
> const pointer instead of a const array member, right?
>
> In which case I much prefer the following names:
>
> cpumask_data_t - value
>
> const_cpumask_t - pointer to constant value
> cpumask_t - pointer to value

There were some comments previously such that we should "imply" that the
incoming cpumask_t args are const, so the compiler would flag those
who arbitrarily modify it.

>
...
>> alloc_cpumask(&mask);
>
> Don't you have to deal with allocation errors?

In a perfect world, no... ;-)
...
>> static inline void alloc_cpumask(cpumask_t *m)
>> {
>> cpumask_t d = kmalloc(BYTES_PER_CPUMASK, GFP_KERNEL);
>> if (no_cpumask(&d))
>> BUG();
>
> yuckery yuck yuck!
>
>> *m = d;
>> }
>>
>> static inline void alloc_cpumask_nopanic(cpumask_t *m)
>> {
>> cpumask_t d = kmalloc(BYTES_PER_CPUMASK, GFP_KERNEL);
>>
>> *m = d;
>> }
>
> gah - at the very least you got the naming wrong, methinks the one
> panic-ing should have panic in its name - if you really want to persist
> with that variant.

Yeah, I rather rushed through the allocation part (yuck indeed ;-).

There are some other alternatives:

- reserve one or more of these in the task struct
- reserve one or more in a per-cpu area
- setup some kind of allocation pool similar to alloc_bootmem
- ???

Thanks,
Mike
--
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/