linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Strange condition in invalidate_mapping_pages()
@ 2017-05-18 13:28 Jan Kara
  2017-05-18 15:28 ` Kirill A. Shutemov
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2017-05-18 13:28 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: linux-mm

Hi Kirill,

in commit fc127da085c26 "truncate: handle file thp" you've added the
following to invalidate_mapping_pages():

          /* Middle of THP: skip */
          if (PageTransTail(page)) {
                  unlock_page(page);
                  continue;
          } else if (PageTransHuge(page)) {
                  index += HPAGE_PMD_NR - 1;
                  i += HPAGE_PMD_NR - 1;
                  /* 'end' is in the middle of THP */
                  if (index ==  round_down(end, HPAGE_PMD_NR))
                          continue;
          }

Now how can ever condition "if (index ==  round_down(end,
HPAGE_PMD_NR))" be true? We have just added HPAGE_PMD_NR - 1 to 'index'
so it will not be a multiple of HPAGE_PMD_NR. Presumably you wanted to
check whether the current THP is the one containing 'end' here which would
be something like 'round_down(index, HPAGE_PMD_NR) == round_down(end,
HPAGE_PMD_NR)' but then I still miss why you'd like to avoid invalidating
the partial THP at the end of file... Can you please enlighten me? Thanks!

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Strange condition in invalidate_mapping_pages()
  2017-05-18 13:28 Strange condition in invalidate_mapping_pages() Jan Kara
@ 2017-05-18 15:28 ` Kirill A. Shutemov
  0 siblings, 0 replies; 2+ messages in thread
From: Kirill A. Shutemov @ 2017-05-18 15:28 UTC (permalink / raw)
  To: Jan Kara; +Cc: Kirill A. Shutemov, linux-mm

On Thu, May 18, 2017 at 03:28:18PM +0200, Jan Kara wrote:
> Hi Kirill,
> 
> in commit fc127da085c26 "truncate: handle file thp" you've added the
> following to invalidate_mapping_pages():
> 
>           /* Middle of THP: skip */
>           if (PageTransTail(page)) {
>                   unlock_page(page);
>                   continue;
>           } else if (PageTransHuge(page)) {
>                   index += HPAGE_PMD_NR - 1;
>                   i += HPAGE_PMD_NR - 1;
>                   /* 'end' is in the middle of THP */
>                   if (index ==  round_down(end, HPAGE_PMD_NR))
>                           continue;
>           }
> 
> Now how can ever condition "if (index ==  round_down(end,
> HPAGE_PMD_NR))" be true? We have just added HPAGE_PMD_NR - 1 to 'index'
> so it will not be a multiple of HPAGE_PMD_NR. Presumably you wanted to
> check whether the current THP is the one containing 'end' here which would
> be something like 'round_down(index, HPAGE_PMD_NR) == round_down(end,
> HPAGE_PMD_NR)'.

You're right, it's a bug. 'page->index' instead of 'index' should do the
trick.

Would you like to prepare the patch? (I'm deep in 5-level paging at the
moment.)

> but then I still miss why you'd like to avoid invalidating the partial
> THP at the end of file... Can you please enlighten me? Thanks!

My logic was that the data in the non-invalidated part of the page can be
still useful and it's better to leave it in page cache.

I don't have performance numbers to validate my intuition.

-- 
 Kirill A. Shutemov

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-18 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18 13:28 Strange condition in invalidate_mapping_pages() Jan Kara
2017-05-18 15:28 ` Kirill A. Shutemov

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).