Re: [PATCH] arch/tile: updates to hardwall code from community feedback.

From: Chris Metcalf
Date: Sun Jul 04 2010 - 07:54:24 EST


On 7/3/2010 11:57 PM, Paul Mundt wrote:
> On Fri, Jul 02, 2010 at 11:45:18AM -0400, Chris Metcalf wrote:
>
>> #define for_each_hardwall_task_safe(pos, n, head) \
>> - hardwall_for_each_entry_safe(pos, n, head, thread.hardwall_list)
>> + list_for_each_entry_safe(pos, n, head, thread.hardwall_list)
>>
>>
> If you've killed off the rest of the wrappers due to them not really
> having to do anything special, you could do the same for this one, too.
>

Good point, thanks. Done.

>> static struct hardwall_info *hardwall_create(
>> - size_t size, const unsigned long __user *bits)
>> + size_t size, const unsigned char __user *bits)
>> {
>> [...]
>>
>>
> Does it even make any sense to accept > sizeof(struct cpumask) ? Your
> case below obviously handles this by making sure the rest of the bits are
> zeroed, but that still seems a bit excessive. If anything, the
> sizeof(struct cpumask) should be your worst case (or just rejected out of
> hand), and you could use cpumask_size() for everything else.
>

Yes, it does make sense; see get_nodes() in mm/mempolicy.c for a similar
API philosophy. The idea is that you don't want to tie userspace code
to the particular NR_CPUS that you happened to build your kernel with.
So you let userspace use any reasonable value for its bitmask, and as
long as it's passing zeroes for the >NR_CPUS positions, that's OK.

cpumask_parse_user() won't help here, since we're not parsing an ASCII
string input. The main flow is just a copy_from_user() for the bits in
the mask, then an optional memset() if the user specified fewer than
NR_CPUS cpus, or a scan to check for set bits if the user specified more
than NR_CPUS cpus.

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com

--
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/