mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@osdl.org>
Cc: Pavel Machek <pavel@suse.cz>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm 1/3] mm: add a new function (needed for swap suspend)
Date: Tue, 27 Dec 2005 17:52:46 +0100	[thread overview]
Message-ID: <200512271752.47003.rjw@sisk.pl> (raw)
In-Reply-To: <200512271747.43374.rjw@sisk.pl>

This patch adds the function get_swap_page_of_type() allowing us to
specify an index in swap_info[] and select a swap_info_struct
structure to be used for allocating a swap page.

This function (or another one of similar functionality) will be necessary for
implementing the image-writing part of swsusp in the user space.  It can also
be used for simplifying the current in-kernel implementation of the
image-writing part of swsusp.


Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

 include/linux/swap.h |    1 +
 mm/swapfile.c        |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

Index: linux-2.6.15-rc5-mm3/mm/swapfile.c
===================================================================
--- linux-2.6.15-rc5-mm3.orig/mm/swapfile.c	2005-12-15 12:01:39.000000000 +0100
+++ linux-2.6.15-rc5-mm3/mm/swapfile.c	2005-12-15 19:00:45.000000000 +0100
@@ -211,6 +211,26 @@
 	return (swp_entry_t) {0};
 }
 
+swp_entry_t get_swap_page_of_type(int type)
+{
+	struct swap_info_struct *si;
+	pgoff_t offset;
+
+	spin_lock(&swap_lock);
+	si = swap_info + type;
+	if (si->flags & SWP_WRITEOK) {
+		nr_swap_pages--;
+		offset = scan_swap_map(si);
+		if (offset) {
+			spin_unlock(&swap_lock);
+			return swp_entry(type, offset);
+		}
+		nr_swap_pages++;
+	}
+	spin_unlock(&swap_lock);
+	return (swp_entry_t) {0};
+}
+
 static struct swap_info_struct * swap_info_get(swp_entry_t entry)
 {
 	struct swap_info_struct * p;
Index: linux-2.6.15-rc5-mm3/include/linux/swap.h
===================================================================
--- linux-2.6.15-rc5-mm3.orig/include/linux/swap.h	2005-12-15 12:03:26.000000000 +0100
+++ linux-2.6.15-rc5-mm3/include/linux/swap.h	2005-12-15 19:00:46.000000000 +0100
@@ -216,6 +216,7 @@
 extern struct swap_info_struct swap_info[];
 extern void si_swapinfo(struct sysinfo *);
 extern swp_entry_t get_swap_page(void);
+extern swp_entry_t get_swap_page_of_type(int type);
 extern int swap_duplicate(swp_entry_t);
 extern int valid_swaphandles(swp_entry_t, unsigned long *);
 extern void swap_free(swp_entry_t);


  reply	other threads:[~2005-12-27 17:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
2005-12-27 16:52 ` Rafael J. Wysocki [this message]
2006-01-04  7:31   ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Andrew Morton
2005-12-27 16:57 ` [PATCH -mm 2/3] swsusp: improve handling of swap partitions Rafael J. Wysocki
2005-12-27 17:07 ` [PATCH -mm 3/3] swsusp: save image header first Rafael J. Wysocki
2005-12-27 17:27 ` [PATCH -mm 0/3] swsusp: swap handling improvements Pavel Machek

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=200512271752.47003.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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

all inboxes | Powered by JetHome®