+ swsusp-read-speedup.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     swsusp: read speedup

has been added to the -mm tree.  Its filename is

     swsusp-read-speedup.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: swsusp: read speedup
From: Andrew Morton <akpm@xxxxxxxx>

Implement async reads for swsusp resuming.

Crufty old PIII testbox:
	15.7 MB/s -> 20.3 MB/s

Sony Vaio:
	14.6 MB/s -> 33.3 MB/s

I didn't implement the post-resume bio_set_pages_dirty().  I don't really
understand why resume needs to run set_page_dirty() against these pages.

It might be a worry that this code modifies PG_Uptodate, PG_Error and
PG_Locked against the image pages.  Can this possibly affect the resumed-into
kernel?  Hopefully not, if we're atomically restoring its mem_map?

Cc: Pavel Machek <pavel@xxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/swap.h    |    1 
 kernel/power/power.h    |    1 
 kernel/power/snapshot.c |   11 ++-
 kernel/power/swap.c     |  109 +++++++++++++++++++++++++-------------
 mm/page_io.c            |    2 
 5 files changed, 83 insertions(+), 41 deletions(-)

diff -puN kernel/power/swap.c~swsusp-read-speedup kernel/power/swap.c
--- a/kernel/power/swap.c~swsusp-read-speedup
+++ a/kernel/power/swap.c
@@ -22,6 +22,7 @@
 #include <linux/device.h>
 #include <linux/buffer_head.h>
 #include <linux/bio.h>
+#include <linux/blkdev.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/pm.h>
@@ -214,6 +215,9 @@ static int wait_on_bio_chain(struct bio 
 		return 0;
 
 	bio = *bio_chain;
+	if (bio == NULL)
+		return 0;
+	generic_unplug_device(bdev_get_queue(bio->bi_bdev));
 	while (bio) {
 		struct page *page;
 
@@ -349,7 +353,8 @@ int swsusp_write(void)
 	int error;
 
 	if ((error = swsusp_swap_check())) {
-		printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
+		printk(KERN_ERR "swsusp: Cannot find swap device, try "
+				"swapon -a.\n");
 		return error;
 	}
 	memset(&snapshot, 0, sizeof(struct snapshot_handle));
@@ -413,7 +418,8 @@ static struct block_device *resume_bdev;
  *	Then submit it and wait.
  */
 
-static int submit(int rw, pgoff_t page_off, void *page)
+static int submit(int rw, pgoff_t page_off, struct page *page,
+			struct bio **bio_chain)
 {
 	int error = 0;
 	struct bio *bio;
@@ -425,31 +431,41 @@ static int submit(int rw, pgoff_t page_o
 	bio->bi_bdev = resume_bdev;
 	bio->bi_end_io = end_io;
 
-	if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
-		printk("swsusp: ERROR: adding page to bio at %ld\n",page_off);
+	if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
+		printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
 		error = -EFAULT;
 		goto Done;
 	}
 
-	atomic_set(&io_done, 1);
-	submit_bio(rw | (1 << BIO_RW_SYNC), bio);
-	while (atomic_read(&io_done))
-		yield();
-	if (rw == READ)
-		bio_set_pages_dirty(bio);
+	if (bio_chain == NULL) {
+		atomic_set(&io_done, 1);
+		submit_bio(rw | (1 << BIO_RW_SYNC), bio);
+		while (atomic_read(&io_done))
+			yield();
+		if (rw == READ)
+			bio_set_pages_dirty(bio);
+		bio_put(bio);
+	} else {
+		lock_page(page);
+		get_page(page);
+		bio_get(bio);
+		bio->bi_end_io = end_swap_bio_read;
+		bio->bi_private = *bio_chain;
+		*bio_chain = bio;
+		submit_bio(rw, bio);
+	}
  Done:
-	bio_put(bio);
 	return error;
 }
 
-static int bio_read_page(pgoff_t page_off, void *page)
+static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
 {
-	return submit(READ, page_off, page);
+	return submit(READ, page_off, virt_to_page(addr), bio_chain);
 }
 
-static int bio_write_page(pgoff_t page_off, void *page)
+static int bio_write_page(pgoff_t page_off, void *addr)
 {
-	return submit(WRITE, page_off, page);
+	return submit(WRITE, page_off, virt_to_page(addr), NULL);
 }
 
 /**
@@ -474,7 +490,7 @@ static int get_swap_reader(struct swap_m
 	handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
 	if (!handle->cur)
 		return -ENOMEM;
-	error = bio_read_page(swp_offset(start), handle->cur);
+	error = bio_read_page(swp_offset(start), handle->cur, NULL);
 	if (error) {
 		release_swap_reader(handle);
 		return error;
@@ -483,7 +499,8 @@ static int get_swap_reader(struct swap_m
 	return 0;
 }
 
-static int swap_read_page(struct swap_map_handle *handle, void *buf)
+static int swap_read_page(struct swap_map_handle *handle, void *buf,
+				struct bio **bio_chain)
 {
 	unsigned long offset;
 	int error;
@@ -493,16 +510,17 @@ static int swap_read_page(struct swap_ma
 	offset = handle->cur->entries[handle->k];
 	if (!offset)
 		return -EFAULT;
-	error = bio_read_page(offset, buf);
+	error = bio_read_page(offset, buf, bio_chain);
 	if (error)
 		return error;
 	if (++handle->k >= MAP_PAGE_ENTRIES) {
+		error = wait_on_bio_chain(bio_chain);
 		handle->k = 0;
 		offset = handle->cur->next_swap;
 		if (!offset)
 			release_swap_reader(handle);
-		else
-			error = bio_read_page(offset, handle->cur);
+		else if (!error)
+			error = bio_read_page(offset, handle->cur, NULL);
 	}
 	return error;
 }
@@ -515,38 +533,55 @@ static int swap_read_page(struct swap_ma
 
 static int load_image(struct swap_map_handle *handle,
                       struct snapshot_handle *snapshot,
-                      unsigned int nr_pages)
+                      unsigned int nr_to_read)
 {
 	unsigned int m;
-	int ret;
 	int error = 0;
 	struct timeval start;
 	struct timeval stop;
+	struct bio *bio;
+	int err2;
+	unsigned nr_pages;
+	int sync = 0;
+	int async = 0;
 
-	printk("Loading image data pages (%u pages) ...     ", nr_pages);
-	m = nr_pages / 100;
+	printk("Loading image data pages (%u pages) ...     ", nr_to_read);
+	m = nr_to_read / 100;
 	if (!m)
 		m = 1;
 	nr_pages = 0;
+	bio = NULL;
 	do_gettimeofday(&start);
-	do {
-		ret = snapshot_write_next(snapshot, PAGE_SIZE);
-		if (ret > 0) {
-			error = swap_read_page(handle, data_of(*snapshot));
-			if (error)
-				break;
-			if (!(nr_pages % m))
-				printk("\b\b\b\b%3d%%", nr_pages / m);
-			nr_pages++;
+	for ( ; ; ) {
+		error = snapshot_write_next(snapshot, PAGE_SIZE);
+		if (error <= 0)
+			break;
+		error = swap_read_page(handle, data_of(*snapshot), &bio);
+		if (error)
+			break;
+		if (snapshot->sync_read) {
+			error = wait_on_bio_chain(&bio);
+			sync++;
+		} else {
+			async++;
 		}
-	} while (ret > 0);
+		if (error)
+			break;
+		if (!(nr_pages % m))
+			printk("\b\b\b\b%3d%%", nr_pages / m);
+		nr_pages++;
+	}
+	err2 = wait_on_bio_chain(&bio);
 	do_gettimeofday(&stop);
+	if (!error)
+		error = err2;
 	if (!error) {
 		printk("\b\b\b\bdone\n");
 		if (!snapshot_image_loaded(snapshot))
 			error = -ENODATA;
 	}
-	show_speed(&start, &stop, nr_pages, "Read");
+	show_speed(&start, &stop, nr_to_read, "Read");
+	printk("sync=%d async=%d\n", sync, async);
 	return error;
 }
 
@@ -569,7 +604,7 @@ int swsusp_read(void)
 	header = (struct swsusp_info *)data_of(snapshot);
 	error = get_swap_reader(&handle, swsusp_header.image);
 	if (!error)
-		error = swap_read_page(&handle, header);
+		error = swap_read_page(&handle, header, NULL);
 	if (!error)
 		error = load_image(&handle, &snapshot, header->pages - 1);
 	release_swap_reader(&handle);
@@ -595,7 +630,7 @@ int swsusp_check(void)
 	if (!IS_ERR(resume_bdev)) {
 		set_blocksize(resume_bdev, PAGE_SIZE);
 		memset(&swsusp_header, 0, sizeof(swsusp_header));
-		if ((error = bio_read_page(0, &swsusp_header)))
+		if ((error = bio_read_page(0, &swsusp_header, NULL)))
 			return error;
 		if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
 			memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
diff -puN include/linux/swap.h~swsusp-read-speedup include/linux/swap.h
--- a/include/linux/swap.h~swsusp-read-speedup
+++ a/include/linux/swap.h
@@ -215,6 +215,7 @@ extern int swap_readpage(struct file *, 
 extern int swap_writepage(struct page *page, struct writeback_control *wbc);
 extern int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
 				struct bio **bio_chain);
+extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err);
 
 /* linux/mm/swap_state.c */
 extern struct address_space swapper_space;
diff -puN mm/page_io.c~swsusp-read-speedup mm/page_io.c
--- a/mm/page_io.c~swsusp-read-speedup
+++ a/mm/page_io.c
@@ -59,7 +59,7 @@ static int end_swap_bio_write(struct bio
 	return 0;
 }
 
-static int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err)
+int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err)
 {
 	const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
 	struct page *page = bio->bi_io_vec[0].bv_page;
diff -puN kernel/power/snapshot.c~swsusp-read-speedup kernel/power/snapshot.c
--- a/kernel/power/snapshot.c~swsusp-read-speedup
+++ a/kernel/power/snapshot.c
@@ -314,7 +314,7 @@ static unsigned int unsafe_pages;
  *	and we count them using unsafe_pages
  */
 
-static inline void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
+static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
 {
 	void *res;
 
@@ -828,13 +828,16 @@ int snapshot_write_next(struct snapshot_
 	}
 	if (!handle->offset)
 		handle->buffer = buffer;
+	handle->sync_read = 1;
 	if (handle->prev < handle->page) {
 		if (!handle->prev) {
-			error = load_header(handle, (struct swsusp_info *)buffer);
+			error = load_header(handle,
+					(struct swsusp_info *)buffer);
 			if (error)
 				return error;
 		} else if (handle->prev <= nr_meta_pages) {
-			handle->pbe = unpack_orig_addresses(buffer, handle->pbe);
+			handle->pbe = unpack_orig_addresses(buffer,
+							handle->pbe);
 			if (!handle->pbe) {
 				error = prepare_image(handle);
 				if (error)
@@ -842,10 +845,12 @@ int snapshot_write_next(struct snapshot_
 				handle->pbe = pagedir_nosave;
 				handle->last_pbe = NULL;
 				handle->buffer = get_buffer(handle);
+				handle->sync_read = 0;
 			}
 		} else {
 			handle->pbe = handle->pbe->next;
 			handle->buffer = get_buffer(handle);
+			handle->sync_read = 0;
 		}
 		handle->prev = handle->page;
 	}
diff -puN kernel/power/power.h~swsusp-read-speedup kernel/power/power.h
--- a/kernel/power/power.h~swsusp-read-speedup
+++ a/kernel/power/power.h
@@ -58,6 +58,7 @@ struct snapshot_handle {
 	struct pbe	*pbe, *last_pbe;
 	void		*buffer;
 	unsigned int	buf_offset;
+	int		sync_read;
 };
 
 #define data_of(handle)	((handle).buffer + (handle).buf_offset)
_

Patches currently in -mm which might be from akpm@xxxxxxxx are

dont-select-config_hotplug.patch
x86_64-e820c-needs-pgtableh.patch
count_vm_events-fix.patch
add-computone-intelliport-plus-serial-hotplug-support.patch
add-specialix-io8-card-support-hotplug-support.patch
fadvise-remove-dead-comments.patch
vt-remove-vt-specific-declarations-and-definitions-from.patch
tty-remove-include-of-screen_infoh-from-ttyh.patch
md-include-sector-number-in-messages-about-corrected-read-errors.patch
md-oops-workaround.patch
disable-debugging-version-of-write_lock.patch
acpi-initialise-cm_sbs_sem.patch
acpi-asus-s3-resume-fix-fix.patch
sony_apci-resume.patch
maestro3-section-fix.patch
kauditd_thread-warning-fix.patch
add-__must_check-to-device-management-code.patch
v4l-dev2-handle-__must_check.patch
videodev-check-return-values.patch
git-geode-fixup.patch
git-gfs2.patch
git-gfs2-fixup.patch
git-ia64.patch
git-ia64-fixup.patch
git-ieee1394-fixup.patch
git-input.patch
git-klibc.patch
git-hdrcleanup-vs-git-klibc-on-ia64.patch
git-hdrcleanup-vs-git-klibc-on-ia64-2.patch
git-libata-all.patch
sata-is-bust-on-s390.patch
git-netdev-all.patch
e1000-irq-naming-update.patch
8139cp-printk-fix.patch
82596-section-fixes.patch
ac3200-section-fixes.patch
cops-section-fix.patch
cs89x0-section-fix.patch
at1700-section-fix.patch
e2100-section-fix.patch
eepro-section-fix.patch
eexpress-section-fix.patch
es3210-section-fix.patch
eth16i-section-fix.patch
lance-section-fix.patch
lne390-section-fix.patch
ni52-section-fix.patch
ibmtr-section-fix.patch
smctr-section-fix.patch
wd-section-fix.patch
ni65-section-fix.patch
seeq8005-section-fix.patch
winbond-840-section-fix.patch
fealnx-section-fix.patch
sundance-section-fix.patch
drivers-net-ns83820c-add-paramter-to-disable-auto.patch
git-sas.patch
serial-8250-sysrq-deadlock-fix.patch
serial-fix-uart_bug_txen-test.patch
revert-gregkh-pci-pci-test-that-drivers-properly-call-pci_set_master.patch
revert-gregkh-pci-msi-drop-pci_msi_quirk.patch
revert-gregkh-pci-msi-stop-inheriting-bus-flags-and-check-root-chipset-bus-flags-instead.patch
revert-gregkh-pci-msi-factorize-common-msi-detection-code-from-pci_enable_msi-and-msix.patch
revert-gregkh-pci-msi-blacklist-pci-e-chipsets-depending-on-hypertransport-msi-capabality.patch
revert-gregkh-pci-msi-rename-pci_cap_id_ht_irqconf-into-pci_cap_id_ht.patch
revert-gregkh-pci-msi-merge-existing-msi-disabling-quirks.patch
revert-VIA-quirk-fixup-additional-PCI-IDs.patch
revert-PCI-quirk-VIA-IRQ-fixup-should-only-run-for-VIA-southbridges.patch
NCR_D700-section-fix.patch
areca-raid-linux-scsi-driver.patch
git-scsi-target-fixup.patch
usb-storage-uname-in-pr-sc-unneeded-message-fix.patch
pm-usb-hcds-use-pm_event_prethaw-fix.patch
kill-usb-kconfig-warning.patch
rtl8150_disconnect-needs-tasklet_kill.patch
git-supertrak-fixup.patch
bcm43xx-opencoded-locking.patch
mm-x86_64-mm-init-rdtscp-warning-fix.patch
sleazy-fpu-feature-x86_64-support.patch
x86_64-wire-up-oops_enter-oops_exit.patch
adix-tree-rcu-lockless-readside-update-tidy.patch
mm-tracking-shared-dirty-pages-checks.patch
mm-tracking-shared-dirty-pages-wimp.patch
convert-i386-numa-kva-space-to-bootmem-tidy.patch
reduce-max_nr_zones-make-display-of-highmem-counters-conditional-on-config_highmem-tidy.patch
reduce-max_nr_zones-use-enum-to-define-zones-reformat-and-comment-cleanup.patch
acx1xx-wireless-driver.patch
tiacx-pci-build-fix.patch
tiacx-ia64-fix.patch
tiacx-build-fix.patch
binfmt_elf-consistently-use-loff_t.patch
fdpic-move-roundup-into-linux-kernelh-fix.patch
swsusp-warning-fix.patch
swsusp-write-timer.patch
swsusp-write-speedup.patch
swsusp-read-timer.patch
swsusp-read-speedup.patch
swsusp-read-speedup-cleanup.patch
uml-timer-initialization-cleanup-fix.patch
uml-move-_kernc-files-fix.patch
deprecate-smbfs-in-favour-of-cifs.patch
edac-new-opteron-athlon64-memory-controller-driver-tidy.patch
x86-microcode-microcode-driver-cleanup-tidy.patch
x86-microcode-add-sysfs-and-hotplug-support-fix.patch
x86-microcode-add-sysfs-and-hotplug-support-fix-fix.patch
add-address_space_operationsbatch_write-tidy.patch
fix-weird-logic-in-alloc_fdtable.patch
alloc_fdtable-cleanup.patch
reiserfs-on-demand-bitmap-loading.patch
per-task-delay-accounting-taskstats-interface.patch
per-task-delay-accounting-proc-export-of-aggregated-block-i-o-delays.patch
delay-accounting-taskstats-interface-send-tgid-once.patch
per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix.patch
task-watchers-task-watchers.patch
task-watchers-add-support-for-per-task-watchers.patch
swap_prefetch-vs-zoned-counters.patch
ecryptfs-mmap-operations.patch
ecryptfs-alpha-build-fix.patch
ecryptfs-more-elegant-aes-key-size-manipulation.patch
ecryptfs-get_sb_dev-fix.patch
namespaces-add-nsproxy-dont-include-compileh.patch
namespaces-utsname-switch-to-using-uts-namespaces.patch
namespaces-utsname-use-init_utsname-when-appropriate.patch
namespaces-utsname-implement-utsname-namespaces.patch
namespaces-utsname-sysctl-hack.patch
ipc-namespace-core.patch
readahead-sysctl-parameters-fix.patch
make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch
reiser4-hardirq-include-fix.patch
reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch
reiser4-get_sb_dev-fix.patch
reiser4-vs-zoned-allocator.patch
hpt3xx-rework-rate-filtering-tidy.patch
cirrus-logic-framebuffer-i2c-support-fix.patch
genirq-convert-the-i386-architecture-to-irq-chips.patch
genirq-x86_64-irq-reenable-migrating-irqs-to-other-cpus.patch
genirq-msi-simplify-msi-enable-and-disable.patch
genirq-ia64-irq-dynamic-irq-support.patch
genirq-msi-only-build-msi-apicc-on-ia64-fix.patch
genirq-i386-irq-remove-the-msi-assumption-that-irq-==-vector.patch
nr_blockdev_pages-in_interrupt-warning.patch
device-suspend-debug.patch
revert-tty-buffering-comment-out-debug-code.patch
slab-leaks3-default-y.patch
x86-kmap_atomic-debugging.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux