All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Rohland <cr@sap.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Patch] shm cleanup
Date: 17 Dec 2000 22:06:14 +0100	[thread overview]
Message-ID: <m34s022251.fsf@linux.local> (raw)
In-Reply-To: <Pine.LNX.4.10.10012170933270.25120-100000@penguin.transmeta.com>
In-Reply-To: <Pine.LNX.4.10.10012170933270.25120-100000@penguin.transmeta.com>

Linus Torvalds <torvalds@transmeta.com> writes:
> The only comment I have is that as far as I can tell, your shm_writepage()
> has a small bug: if "__get_swap_page()" fails, we can't just drop the
> dirty page in question, so instead of returning -ENOMEM we should really
> return a "1" to tell the VM to keep the page dirty.

Right, here comes the (incremental) patch

        Christoph

diff -uNr c/mm/shmem.c c1/mm/shmem.c
--- c/mm/shmem.c	Sun Dec 17 21:31:46 2000
+++ c1/mm/shmem.c	Sun Dec 17 21:35:08 2000
@@ -210,31 +210,33 @@
 {
 	int error;
 	struct shmem_inode_info *info;
-	swp_entry_t *entry;
+	swp_entry_t *entry, swap;
 
 	info = &((struct inode *)page->mapping->host)->u.shmem_i;
 	if (info->locked)
 		return 1;
+	swap = __get_swap_page(2);
+	if (!swap.val)
+		return 1;
+
 	spin_lock(&info->lock);
 	entry = shmem_swp_entry (info, page->index);
 	if (!entry)	/* this had been allocted on page allocation */
 		BUG();
 	error = -EAGAIN;
-	if (entry->val)
-		goto out;
-
-	error = -ENOMEM;
-	*entry = __get_swap_page(2);
-	if (!entry->val)
+	if (entry->val) {
+                __swap_free(swap, 2);
 		goto out;
+        }
 
+        *entry = swap;
 	error = 0;
 	/* Remove the from the page cache */
 	lru_cache_del(page);
 	remove_inode_page(page);
 
 	/* Add it to the swap cache */
-	add_to_swap_cache(page,*entry);
+	add_to_swap_cache(page, swap);
 	page_cache_release(page);
 	SetPageDirty(page);
 	info->swapped++;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

       reply	other threads:[~2000-12-17 21:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.10.10012170933270.25120-100000@penguin.transmeta.com>
2000-12-17 21:06 ` Christoph Rohland [this message]
2000-12-17 21:05 [Patch] shm cleanup Christoph Rohland

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=m34s022251.fsf@linux.local \
    --to=cr@sap.com \
    --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.