linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "夷则(Caspar)" <jinli.zjl@alibaba-inc.com>
To: mgorman@techsingularity.net, Andrew Morton <akpm@linux-foundation.org>
Cc: green@linuxhacker.ru, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	"杨勇(智彻)" <zhiche.yy@alibaba-inc.com>,
	十刀 <shidao.ytt@alibaba-inc.com>
Subject: Re: [PATCH] mm/fadvise: discard partial pages iff endbyte is also eof
Date: Wed, 03 Jan 2018 14:53:43 +0800	[thread overview]
Message-ID: <8DAEE48B-AD5D-4702-AB4B-7102DD837071@alibaba-inc.com> (raw)
In-Reply-To: <1514002568-120457-1-git-send-email-shidao.ytt@alibaba-inc.com>



> 在 2017年12月23日,12:16,十刀 <shidao.ytt@alibaba-inc.com> 写道:
> 
> From: "shidao.ytt" <shidao.ytt@alibaba-inc.com>
> 
> in commit 441c228f817f7 ("mm: fadvise: document the
> fadvise(FADV_DONTNEED) behaviour for partial pages") Mel Gorman
> explained why partial pages should be preserved instead of discarded
> when using fadvise(FADV_DONTNEED), however the actual codes to calcuate
> end_index was unexpectedly wrong, the code behavior didn't match to the
> statement in comments; Luckily in another commit 18aba41cbf
> ("mm/fadvise.c: do not discard partial pages with POSIX_FADV_DONTNEED")
> Oleg Drokin fixed this behavior
> 
> Here I come up with a new idea that actually we can still discard the
> last parital page iff the page-unaligned endbyte is also the end of
> file, since no one else will use the rest of the page and it should be
> safe enough to discard.

+akpm...

Hi Mel, Andrew:

Would you please take a look at this patch, to see if this proposal
is reasonable enough, thanks in advance!

Thanks,
Caspar

> 
> Signed-off-by: shidao.ytt <shidao.ytt@alibaba-inc.com>
> Signed-off-by: Caspar Zhang <jinli.zjl@alibaba-inc.com>
> ---
> mm/fadvise.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/fadvise.c b/mm/fadvise.c
> index ec70d6e..f74b21e 100644
> --- a/mm/fadvise.c
> +++ b/mm/fadvise.c
> @@ -127,7 +127,8 @@
> 		 */
> 		start_index = (offset+(PAGE_SIZE-1)) >> PAGE_SHIFT;
> 		end_index = (endbyte >> PAGE_SHIFT);
> -		if ((endbyte & ~PAGE_MASK) != ~PAGE_MASK) {
> +		if ((endbyte & ~PAGE_MASK) != ~PAGE_MASK &&
> +				endbyte != inode->i_size - 1) {
> 			/* First page is tricky as 0 - 1 = -1, but pgoff_t
> 			 * is unsigned, so the end_index >= start_index
> 			 * check below would be true and we'll discard the whole
> -- 
> 1.8.3.1

--
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:[~2018-01-03  6:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-23  4:16 十刀
2018-01-03  6:53 ` 夷则(Caspar) [this message]
2018-01-03 10:48   ` Mel Gorman
2018-01-04  0:17     ` Andrew Morton
2018-01-04  8:17       ` 夷则(Caspar)
2018-01-04 22:54         ` Andrew Morton
2018-01-04 10:05       ` Mel Gorman
2018-01-04  6:13     ` 夷则(Caspar)
2018-01-04  7:44       ` 夷则(Caspar)
2018-01-04 11:34       ` Mel Gorman
2018-01-04 11:38         ` 夷则(Caspar)
2018-01-05  6:10 ` [PATCH v2] mm/fadvise: discard partial page if endbyte is also EOF 夷则(Caspar)

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=8DAEE48B-AD5D-4702-AB4B-7102DD837071@alibaba-inc.com \
    --to=jinli.zjl@alibaba-inc.com \
    --cc=akpm@linux-foundation.org \
    --cc=green@linuxhacker.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=shidao.ytt@alibaba-inc.com \
    --cc=zhiche.yy@alibaba-inc.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