linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Timur Tabi <timur.tabi@ammasso.com>
Cc: roland@topspin.com, linux-kernel@vger.kernel.org
Subject: Re: Correct way to release get_user_pages()?
Date: Sun, 30 Jan 2005 02:10:17 -0800	[thread overview]
Message-ID: <20050130021017.7ef1c764.akpm@osdl.org> (raw)
In-Reply-To: <41FA7AE2.10209@ammasso.com>

Timur Tabi <timur.tabi@ammasso.com> wrote:
>
>  Roland Dreier wrote:
> 
>  > Reading through the tree, I see that some callers of get_user_pages()
>  > release the pages that they got via put_page(), and some callers use
>  > page_cache_release().  Of course <linux/pagemap.h> has
>  > 
>  > 	#define page_cache_release(page)      put_page(page)
>  > 
>  > so this is really not much of a difference, but I'd like to know which
>  > is considered better style.  Any opinions?

I guess we should only use page_cache_release() if the page is known to be
pagecache.  In the case of get_user_pages() the page could of course be
anonymous in which case put_page is probably more appropriate.  It's all a
bit of a mess and if we ever do end up having PAGE_CACHE_SIZE > PAGE_SIZE,
someone will have some work to do.

I suppose put_page() would be better for now.

>  I've defined this function.  I'm not sure if it really works, but it 
>  looks good.
> 
>  #include <linux/pagemap.h>
> 
>  void put_user_pages(int len, struct page **pages)
>  {
>           int i;
> 
>           for (i=0; i<len; i++) {
>                   if (!PageReserved(pages[i])) {
>                           SetPageDirty(pages[i]);
>                   }
>                   page_cache_release(pages[i]);
>           }
>  }

no...  You should only dirty the page if it was modified, and then use
set_page_dirty() or set_page_dirty_lock().

See dio_bio_complete() for an example.

  reply	other threads:[~2005-01-30 10:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-28  3:02 Correct way to release get_user_pages()? Roland Dreier
2005-01-28 17:48 ` Timur Tabi
2005-01-30 10:10   ` Andrew Morton [this message]
2005-01-31 15:51     ` Timur Tabi
2005-01-31 21:01       ` Andrew Morton

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=20050130021017.7ef1c764.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@topspin.com \
    --cc=timur.tabi@ammasso.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 NNTP newsgroup(s).