All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [patch 2/13] remove pages from the LRU in __free_pages_ok()
Date: Sun, 28 Jul 2002 17:32:56 -0700	[thread overview]
Message-ID: <3D448D38.D156C249@zip.com.au> (raw)
In-Reply-To: Pine.LNX.4.44.0207281649560.9427-100000@home.transmeta.com

Linus Torvalds wrote:
> 
> On Sun, 28 Jul 2002, Andrew Morton wrote:
> >
> > There are some situations where a page's final release is performed by
> > put_page().  Such as in access_process_vm().  This tends to go BUG()
> > because the page is on the LRU.
> 
> This is wrong.
> 
> If that happens, then you should just make access_process_vm() use
> "page_cache_release()". That's what you basically make "__free_pages_ok()"
> do, but since you still have to add the BUG_ON() check to make clear that
> it is illegal to do this from an interrupt context, it's much better to
> just do this check statically.
> 

OK.  This means that put_page() against userspace-mapped pages
is to be avoided.

Did an audit.  What on earth is drivers/scsi/sg.c:sg_rb_correct4mmap()
doing?

Also skb_release_data(), ___pskb_trim() and __pskb_pull_tail().  Can these
ever perform the final release against a page which is on the LRU? In
interrupt context?

tcp_sendmsg() is doing put_page() too.  I _think_ it's OK because
the page is mapped into the calling process and because of the
way in which shrink_cache() looks at page->count.  Not sure.



 fs/binfmt_elf.c |    3 ++-
 fs/smbfs/file.c |    8 ++++----
 kernel/ptrace.c |    3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

--- 2.5.29/fs/binfmt_elf.c~put_page	Sun Jul 28 17:17:23 2002
+++ 2.5.29-akpm/fs/binfmt_elf.c	Sun Jul 28 17:31:33 2002
@@ -33,6 +33,7 @@
 #include <linux/smp_lock.h>
 #include <linux/compiler.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/param.h>
@@ -1249,7 +1250,7 @@ static int elf_core_dump(long signr, str
 					flush_page_to_ram(page);
 					kunmap(page);
 				}
-				put_page(page);
+				page_cache_release(page);
 			}
 		}
 	}
--- 2.5.29/fs/smbfs/file.c~put_page	Sun Jul 28 17:19:08 2002
+++ 2.5.29-akpm/fs/smbfs/file.c	Sun Jul 28 17:19:40 2002
@@ -105,9 +105,9 @@ smb_readpage(struct file *file, struct p
 	int		error;
 	struct dentry  *dentry = file->f_dentry;
 
-	get_page(page);
+	page_cache_get(page);
 	error = smb_readpage_sync(dentry, page);
-	put_page(page);
+	page_cache_release(page);
 	return error;
 }
 
@@ -194,11 +194,11 @@ smb_writepage(struct page *page)
 	if (page->index >= end_index+1 || !offset)
 		return -EIO;
 do_it:
-	get_page(page);
+	page_cache_get(page);
 	err = smb_writepage_sync(inode, page, 0, offset);
 	SetPageUptodate(page);
 	unlock_page(page);
-	put_page(page);
+	page_cache_release(page);
 	return err;
 }
 
--- 2.5.29/kernel/ptrace.c~put_page	Sun Jul 28 17:20:04 2002
+++ 2.5.29-akpm/kernel/ptrace.c	Sun Jul 28 17:26:13 2002
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 
 #include <asm/pgtable.h>
@@ -156,7 +157,7 @@ int access_process_vm(struct task_struct
 			flush_page_to_ram(page);
 		}
 		kunmap(page);
-		put_page(page);
+		page_cache_release(page);
 		len -= bytes;
 		buf += bytes;
 		addr += bytes;

.

  reply	other threads:[~2002-07-29  0:21 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-28  7:32 [patch 2/13] remove pages from the LRU in __free_pages_ok() Andrew Morton
2002-07-28 23:54 ` Linus Torvalds
2002-07-29  0:32   ` Andrew Morton [this message]
2002-07-29  0:37     ` Linus Torvalds
2002-07-29  0:59       ` Andrew Morton
2002-07-29  0:59         ` Rik van Riel
2002-07-29  2:50     ` David S. Miller
2002-07-29  3:51       ` Linus Torvalds
2002-07-29  3:43         ` David S. Miller
2002-07-29  4:21           ` Linus Torvalds
2002-07-29  5:43             ` David S. Miller
2002-07-29  6:16               ` Linus Torvalds
2002-07-29  6:10                 ` David S. Miller
2002-07-29  6:27                   ` Linus Torvalds
2002-07-29  6:59                     ` Andrew Morton
2002-07-30 11:30                     ` Ed Tomlinson
     [not found]                     ` <200208011942.49342.tomlins@cam.org>
     [not found]                       ` <3D49C951.AB7C527E@zip.com.au>
2002-08-03 19:27                         ` [PATCH] slablru for linux-2.5 bk tree Ed Tomlinson
2002-08-03 19:27                           ` Ed Tomlinson
2002-08-03 20:43                           ` Rik van Riel
2002-08-03 20:43                             ` Rik van Riel
2002-08-04  3:17                           ` Andrew Morton
2002-08-04  3:17                             ` Andrew Morton
2002-07-29  8:35                 ` [patch 2/13] remove pages from the LRU in __free_pages_ok() Rik van Riel
2002-07-29  4:25           ` Andrew Morton
2002-07-29  4:28             ` Linus Torvalds
2002-07-29  4:52               ` Andrew Morton
2002-07-29  4:50                 ` Linus Torvalds
2002-07-29  5:15                   ` Andrew Morton
2002-07-29  4:17         ` Andrew Morton
2002-07-29  4:23           ` Linus Torvalds
2002-07-29  5:43           ` David S. Miller
2002-07-29  6:24           ` Paul Mackerras

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=3D448D38.D156C249@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.