linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: NeilBrown <neilb@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Minchan Kim <minchan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Android Kernel Team <kernel-team@android.com>,
	Robert Love <rlove@google.com>, Mel Gorman <mel@csn.ul.ie>,
	Hugh Dickins <hughd@google.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Rik van Riel <riel@redhat.com>,
	Dmitry Adamushko <dmitry.adamushko@gmail.com>,
	Dave Chinner <david@fromorbit.com>,
	Andrea Righi <andrea@betterlinux.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Mike Hommey <mh@glandium.org>, Taras Glek <tglek@mozilla.com>,
	Dhaval Giani <dgiani@mozilla.com>, Jan Kara <jack@suse.cz>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	Michel Lespinasse <walken@google.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 5/8] vrange: Add new vrange(2) system call
Date: Wed, 12 Jun 2013 11:47:12 -0700	[thread overview]
Message-ID: <51B8C230.6000902@linaro.org> (raw)
In-Reply-To: <20130612164848.10b93db2@notabene.brown>

On 06/11/2013 11:48 PM, NeilBrown wrote:
> On Tue, 11 Jun 2013 21:22:48 -0700 John Stultz <john.stultz@linaro.org> wrote:
>
>> From: Minchan Kim <minchan@kernel.org>
>>
>> This patch adds new system call sys_vrange.
>>
>> NAME
>> 	vrange - Mark or unmark range of memory as volatile
>>
>> SYNOPSIS
>> 	int vrange(unsigned_long start, size_t length, int mode,
>> 			 int *purged);
>>
> ...
>> 	purged: Pointer to an integer which will return 1 if
>> 	mode == VRANGE_NONVOLATILE and any page in the affected range
>> 	was purged. If purged returns zero during a mode ==
>> 	VRANGE_NONVOLATILE call, it means all of the pages in the range
>> 	are intact.
> This seems a bit ambiguous.
> It is clear that the pointed-to location will be set to '1' if any part of
> the range was purged, but it is not clear what will happen if it wasn't
> purged.
> The mention of 'returns zero' seems to suggest that it might set the location
> to '0' in that case, but that isn't obvious to me.  The code appear to always
> set it - that should be explicit.
>
> Also, should the location be a fixed number of bytes to reduce possible
> issues with N-bit userspace on M-bit kernels?
>
> May I suggest:
>
>          purge:  If not NULL, a pointer to a 32bit location which will be set
>          to 1 if mode == VRANGE_NONVOLATILE and any page in the affected range
>          was purged, and will be set to 0 in all other cases (including
>          if mode == VRANGE_VOLATILE).
>
>
> I don't think any further explanation is needed.

I'll use this! Thanks for the suggestion!


>> +	if (purged) {
>> +		/* Test pointer is valid before making any changes */
>> +		if (put_user(p, purged))
>> +			return -EFAULT;
>> +	}
>> +
>> +	ret = do_vrange(mm, start, end - 1, mode, &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.
>> +			 */
>> +			BUG();
>> +		}
>> +	}
> I agree that would be bad, but I don't think a BUG() is called for.  Maybe a
> WARN, and certainly a "return -EFAULT;"

Yea, this was a late change before I sent out the patches. In reviewing 
the documentation I realized we still could return an error and the 
purge data was lost. Thus I added the earlier test to make sure the 
pointer is valid before we take any action.

The BUG() was mostly for my own testing, and I'll change it in the 
future, although I want to sort out exactly in what cases the second 
put_user() could fail if the first succeeded.

Thanks as always for the great feedback!
-john





--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-06-12 18:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12  4:22 [PATCH 0/8] Volatile Ranges (v8?) John Stultz
2013-06-12  4:22 ` [PATCH 1/8] vrange: Add basic data structure and functions John Stultz
2013-06-12  4:22 ` [PATCH 2/8] vrange: Add vrange support for file address_spaces John Stultz
2013-06-12  4:22 ` [PATCH 3/8] vrange: Add vrange support to mm_structs John Stultz
2013-06-12  4:22 ` [PATCH 4/8] vrange: Clear volatility on new mmaps John Stultz
2013-06-13  6:28   ` Minchan Kim
2013-06-13 23:43     ` John Stultz
2013-06-14  0:21       ` Minchan Kim
2013-06-12  4:22 ` [PATCH 5/8] vrange: Add new vrange(2) system call John Stultz
2013-06-12  6:48   ` NeilBrown
2013-06-12 18:47     ` John Stultz [this message]
2013-06-20 21:05   ` Dhaval Giani
2013-06-12  4:22 ` [PATCH 6/8] vrange: Add GFP_NO_VRANGE allocation flag John Stultz
2013-06-12  4:22 ` [PATCH 7/8] vrange: Add method to purge volatile ranges John Stultz
2013-06-17  7:13   ` Minchan Kim
2013-06-17  7:24     ` Minchan Kim
2013-06-19  4:34   ` Minchan Kim
2013-10-01 14:00     ` Krzysztof Kozlowski
2013-10-02  1:32       ` Minchan Kim
2013-06-12  4:22 ` [PATCH 8/8] vrange: Send SIGBUS when user try to access purged page John Stultz
2013-06-19  4:36   ` Minchan Kim
2013-06-17 16:24 ` [PATCH 0/8] Volatile Ranges (v8?) Dhaval Giani
2013-06-18  4:11   ` Minchan Kim
2013-06-18 16:59     ` Dhaval Giani
2013-06-19  4:41       ` Minchan Kim
2013-06-19 18:36         ` Dhaval Giani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51B8C230.6000902@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrea@betterlinux.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=david@fromorbit.com \
    --cc=dgiani@mozilla.com \
    --cc=dmitry.adamushko@gmail.com \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=kernel-team@android.com \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=mh@glandium.org \
    --cc=minchan@kernel.org \
    --cc=neilb@suse.de \
    --cc=riel@redhat.com \
    --cc=rlove@google.com \
    --cc=tglek@mozilla.com \
    --cc=walken@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).