dri-devel Archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Liam Howlett <liam.howlett@oracle.com>
Cc: Alex Sierra <alex.sierra@amd.com>,
	"rcampbell@nvidia.com" <rcampbell@nvidia.com>,
	"Felix.Kuehling@amd.com" <Felix.Kuehling@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"jglisse@redhat.com" <jglisse@redhat.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"hch@lst.de" <hch@lst.de>
Subject: Re: [RFC PATCH v2 1/8] ext4/xfs: add page refcount helper
Date: Tue, 8 Jun 2021 15:33:05 +0100	[thread overview]
Message-ID: <YL9/ob6taZXHow5t@casper.infradead.org> (raw)
In-Reply-To: <20210608002858.gegg6sl2z2dwwstb@revolver>

On Tue, Jun 08, 2021 at 12:29:04AM +0000, Liam Howlett wrote:
> * Alex Sierra <alex.sierra@amd.com> [210607 16:43]:
> > From: Ralph Campbell <rcampbell@nvidia.com>
> > 
> > There are several places where ZONE_DEVICE struct pages assume a reference
> > count == 1 means the page is idle and free. Instead of open coding this,
> > add a helper function to hide this detail.
> > 
> > diff --git a/include/linux/dax.h b/include/linux/dax.h
> > index b52f084aa643..8909a91cd381 100644
> > --- a/include/linux/dax.h
> > +++ b/include/linux/dax.h
> > @@ -243,6 +243,16 @@ static inline bool dax_mapping(struct address_space *mapping)
> >  	return mapping->host && IS_DAX(mapping->host);
> >  }
> >  
> > +static inline bool dax_layout_is_idle_page(struct page *page)
> > +{
> > +	return page_ref_count(page) == 1;
> > +}
> 
> If this races with page_ref_count(page) == 0, then it will return false
> that a page is idle when the page is being freed.  I don't know the code
> well enough to say if this is an issue or not so please let me know.
> 
> For example:
> !dax_layout_is_idle_page() will return true in dax_busy_page() above
> when the count is 0 and return the page.
> 
> Maybe you are sure to have at least one reference when calling this?  It
> might be worth adding a comment.

You're getting confused by the problem that the next patch fixes, which
is that devmap pages were stupidly given an elevated refcount.  devmap
pages are considered "free" when their refcount is 1.  See
put_page(), put_devmap_managed_page() and so on.

  reply	other threads:[~2021-06-08 14:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 20:42 [RFC PATCH v2 0/8] Support DEVICE_GENERIC memory in migrate_vma_* Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 1/8] ext4/xfs: add page refcount helper Alex Sierra
2021-06-08  0:29   ` Liam Howlett
2021-06-08 14:33     ` Matthew Wilcox [this message]
2021-06-09 19:23   ` Matthew Wilcox
2021-06-14 15:26     ` Felix Kuehling
2021-06-07 20:42 ` [RFC PATCH v2 2/8] mm: remove extra ZONE_DEVICE struct page refcount Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 3/8] kernel: resource: lookup_resource as exported symbol Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 4/8] drm/amdkfd: add SPM support for SVM Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 5/8] drm/amdkfd: generic type as sys mem on migration to ram Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 6/8] include/linux/mm.h: helpers to check zone device generic type Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 7/8] mm: add generic type support to migrate_vma helpers Alex Sierra
2021-06-07 20:42 ` [RFC PATCH v2 8/8] mm: call pgmap->ops->page_free for DEVICE_GENERIC pages Alex Sierra
2021-06-08 14:26 ` [RFC PATCH v2 0/8] Support DEVICE_GENERIC memory in migrate_vma_* Matthew Wilcox

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=YL9/ob6taZXHow5t@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=Felix.Kuehling@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.sierra@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@lst.de \
    --cc=jgg@nvidia.com \
    --cc=jglisse@redhat.com \
    --cc=liam.howlett@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=rcampbell@nvidia.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 read-only IMAP folder(s) and NNTP newsgroup(s).