Re: [PATCH 1/5] vrange: Add vrange syscall and handle splitting/merging and marking vmas

From: John Stultz
Date: Sun Mar 23 2014 - 16:34:34 EST


On Sun, Mar 23, 2014 at 5:20 AM, Jan Kara <jack@xxxxxxx> wrote:
> On Fri 21-03-14 14:17:31, John Stultz wrote:
>> RETURN VALUE
>> On success vrange returns the number of bytes marked or unmarked.
>> Similar to write(), it may return fewer bytes then specified
>> if it ran into a problem.
>>
>> When using VRANGE_NON_VOLATILE, if the return value is smaller
>> then the specified length, then the value specified by the purged
> ^^^ than

Ah, thanks!

> Also I'm not sure why *purged is set only if the return value is smaller
> than the specified legth. Won't the interface be more logical if we set
> *purged to appropriate value in all cases?

So yea, we do set purged to the appropriate value in all cases. The
confusion here is I'm trying to clarify that in the case that the
return value is smaller then the requested length, the value of the
purge variable will be set to the purge state of only the pages
successfully marked non-volatile. In other words, the purge value will
provide no information about the requested pages beyond the returned
byte count. I'm clearly making a bit of a mess with the wording there
(and here probably as well ;). Any suggestions for a more clear
phrasing would be appreciated.


>> + ret = do_vrange(mm, start, end, mode, flags, &p);
>> +
>> + if (purged) {
>> + if (put_user(p, purged)) {
>> + /*
>> + * This would be bad, since we've modified volatilty
>> + * and the change in purged state would be lost.
>> + */
>> + WARN_ONCE(1, "vrange: purge state possibly lost\n");
> I think this can happen when the application has several threads and
> vrange() in one thread races with munmap() in another thread. So
> WARN_ONCE() doesn't look appropriate (kernel shouldn't spew warnings about
> application programming bugs)... I'd just return -EFAULT. I know
> information will be lost but userspace is doing something utterly stupid.

Ok.. I guess that sounds reasonable.

Thanks for the review! Very much appreciate it!
-john
--
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/