linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: David Howells <dhowells@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Matthew Wilcox <willy@infradead.org>,
	Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
	Jeff Layton <jlayton@kernel.org>,
	Logan Gunthorpe <logang@deltatee.com>,
	linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	linux-mm@kvack.org
Subject: Re: [PATCH v8 10/10] mm: Renumber FOLL_PIN and FOLL_GET down
Date: Tue, 24 Jan 2023 10:00:28 -0400	[thread overview]
Message-ID: <Y8/kfPEp1GkZKklc@nvidia.com> (raw)
In-Reply-To: <852914.1674568628@warthog.procyon.org.uk>

On Tue, Jan 24, 2023 at 01:57:08PM +0000, David Howells wrote:
> Jason Gunthorpe <jgg@nvidia.com> wrote:
> 
> > I moved FOLL_PIN to internal.h because it is not supposed to be used
> > outside mm/*
> > 
> > I would prefer to keep it that way.
> 
> I'll need to do something else, then, such as creating a new pair of 'cleanup'
> flags:
> 
> 	[include/linux/mm_types.h]
> 	#define PAGE_CLEANUP_UNPIN	(1U << 0)
> 	#define PAGE_CLEANUP_PUT	(1U << 0)
> 
> 	[mm/gup.h]
> 	void folio_put_unpin(struct folio *folio, unsigned int cleanup_flags)
> 	{
> 		unsigned int gup_flags = 0;
> 
> 		cleanup_flags &= PAGE_CLEANUP_UNPIN | PAGE_CLEANUP_PUT;
> 		if (!cleanup_flags)
> 			return;
> 		gup_flags |= cleanup_flags & PAGE_CLEANUP_UNPIN ? FOLL_PIN : 0;
> 		gup_flags |= cleanup_flags & PAGE_CLEANUP_PUT ? FOLL_GET : 0;
> 		gup_put_folio(folio, 1, flags);
> 	}
> 	EXPORT_SYMBOL_GPL(folio_put_unpin);


I suggest:

if (cleanup_flags & PAGE_CLEANUP_UNPIN)
   gup_put_folio(folio, 1, true);
else if (cleanup_flags & PAGE_CLEANUP_PUT)
   gup_put_folio(folio, 1, false);

or if you are really counting cycles

if (cleanup_flags & PAGE_CLEANUP_NEEDED)
   gup_put_folio(folio, 1, cleanup_flags & PAGE_CLEANUP_UNPIN)

Jason


  reply	other threads:[~2023-01-24 14:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230123173007.325544-1-dhowells@redhat.com>
2023-01-23 17:29 ` [PATCH v8 02/10] iov_iter: Add a function to extract a page list from an iterator David Howells
2023-01-23 18:21   ` Christoph Hellwig
2023-01-24 14:27   ` David Hildenbrand
2023-01-24 14:35   ` David Howells
2023-01-24 14:37     ` David Hildenbrand
2023-01-24 14:45     ` David Howells
2023-01-24 14:52       ` David Hildenbrand
2023-01-23 17:30 ` [PATCH v8 03/10] mm: Provide a helper to drop a pin/ref on a page David Howells
2023-01-23 18:21   ` Christoph Hellwig
2023-01-24  3:03   ` John Hubbard
2023-01-24 14:28   ` David Hildenbrand
2023-01-24 14:41   ` David Howells
2023-01-24 14:52     ` Christoph Hellwig
2023-01-24 14:53       ` David Hildenbrand
2023-01-24 15:04     ` David Howells
2023-01-23 17:30 ` [PATCH v8 10/10] mm: Renumber FOLL_PIN and FOLL_GET down David Howells
2023-01-23 18:25   ` Christoph Hellwig
2023-01-24  3:08   ` John Hubbard
2023-01-24  3:11     ` John Hubbard
2023-01-24 13:13       ` Jason Gunthorpe
2023-01-24 13:18         ` Christoph Hellwig
2023-01-24 13:43           ` Jason Gunthorpe
2023-01-24 13:40       ` David Howells
2023-01-24 13:46       ` David Howells
2023-01-24 13:47         ` Jason Gunthorpe
2023-01-24 13:57         ` David Howells
2023-01-24 14:00           ` Jason Gunthorpe [this message]
2023-01-24 14:02           ` Christoph Hellwig
2023-01-24 14:11           ` David Howells
2023-01-24 14:14             ` Jason Gunthorpe
2023-01-24 14:27             ` David Howells
2023-01-24 14:31               ` Jason Gunthorpe
2023-01-24 14:59               ` David Howells
2023-01-24 15:06                 ` Jason Gunthorpe
2023-01-24 15:12                 ` David Howells
2023-01-24 14:12           ` David Howells
2023-01-24 14:13             ` Christoph Hellwig
2023-01-24 14:25             ` David Howells
2023-01-24  7:05   ` David Howells

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=Y8/kfPEp1GkZKklc@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jhubbard@nvidia.com \
    --cc=jlayton@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=logang@deltatee.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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