Re: [PATCHv3 03/24] mm: avoid PG_locked on tail pages

Kirill A. Shutemov
2015-03-03T13:36:12Z

On Tue, Mar 03, 2015 at 06:51:11PM +0530, Aneesh Kumar K.V wrote:
> Rik van Riel <riel@redhat.com> writes:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 02/12/2015 02:55 PM, Rik van Riel wrote:
> >> On 02/12/2015 11:18 AM, Kirill A. Shutemov wrote:
> >
> >>> @@ -490,6 +493,7 @@ extern int
> >>> wait_on_page_bit_killable_timeout(struct page *page,
> >>
> >>> static inline int wait_on_page_locked_killable(struct page *page)
> >>> { + page = compound_head(page); if (PageLocked(page)) return
> >>> wait_on_page_bit_killable(page, PG_locked); return 0; @@ -510,6
> >>> +514,7 @@ static inline void wake_up_page(struct page *page, int
> >>> bit) */ static inline void wait_on_page_locked(struct page *page)
> >>> { + page = compound_head(page); if (PageLocked(page))
> >>> wait_on_page_bit(page, PG_locked); }
> >>
> >> These are all atomic operations.
> >>
> >> This may be a stupid question with the answer lurking somewhere in
> >> the other patches, but how do you ensure you operate on the right
> >> page lock during a THP collapse or split?
> >
> > Kirill answered that question on IRC.
> >
> > The VM takes a refcount on a page before attempting to take a page
> > lock, which prevents the THP code from doing anything with the
> > page. In other words, while we have a refcount on the page, we
> > will dereference the same page lock.
>
> Can we explain this more ? Don't we allow a thp split to happen even if
> we have page refcount ?.

The patchset changes this. Have you read the cover letter?

--
Kirill A. Shutemov