[rfc] boot-time async readahead...

Martin Pitt martin.pitt at ubuntu.com
Thu Feb 12 08:18:32 GMT 2009


Daniel J Blueman [2009-02-12  0:57 +0000]:
> I've produced a complete and tested debdiff at:
> http://quora.org/hive/readahead-list_0.20050517.0220-1ubuntu5.diff.gz

To spare anyone else the fun with discovering the double gzip'ing and
diffing, that's the real debdiff.

Thanks Daniel, will try it out :)

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
diff -u readahead-list-0.20050517.0220/debian/changelog readahead-list-0.20050517.0220/debian/changelog
--- readahead-list-0.20050517.0220/debian/changelog
+++ readahead-list-0.20050517.0220/debian/changelog
@@ -1,3 +1,10 @@
+readahead-list (1:0.20050517.0220-1ubuntu5) intrepid; urgency=low
+
+  * Perform readahead asynchronously, after setting background
+    process and I/O priorities.
+
+ -- Daniel J Blueman <daniel.blueman at gmail.com>  Wed, 12 Feb 2009 23:30:11 +0000
+
 readahead-list (1:0.20050517.0220-1ubuntu4) intrepid; urgency=low
 
   * Regenerate boot.list using an installation of 20081026, excluding
only in patch2:
unchanged:
--- readahead-list-0.20050517.0220.orig/debian/patches/60-scheduling.patch
+++ readahead-list-0.20050517.0220/debian/patches/60-scheduling.patch
@@ -0,0 +1,51 @@
+--- readahead-list-0.20050517.0220/src/readahead-list.c-orig	2009-02-11 23:22:38.865366713 +0000
++++ readahead-list-0.20050517.0220/src/readahead-list.c	2009-02-12 00:28:33.584366942 +0000
+@@ -24,6 +24,7 @@
+ #include <unistd.h>
+ #include <getopt.h>
+ #include <sys/syscall.h>
++#include <sys/syscall.h>
+ #include <sys/ioctl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -172,8 +173,6 @@
+ 	}
+ 
+ 	close(fd);
+-	/* be nice to other processes now */
+-	sched_yield();
+ #undef __FUNCTION__
+ }
+ 
+@@ -362,10 +361,31 @@
+ 	if(flag_version || flag_help) {
+ 		exit(0);
+ 	}
++	
++	// initialisation complete; background to allow boot-scripts to continue
++	pid_t pid = fork();
++	if (pid == -1) {
++		fprintf(stderr, "failed to fork: %d\n", errno);
++		exit(1);
++	} else if (pid) {
++		// parent process exits, child finishes work
++		exit(0);
++	}
++	
++	// ensure we don't compete for resources with boot scripts
++	// but utilise cpu during I/O wait and vice-versa
++	nice(3);
++#ifdef __NR_ioprio_set
++	syscall(__NR_ioprio_set, 1 /* IOPRIO_WHO_PROCESS, */, getpid(), 3 /* IOPRIO_CLASS_IDLE */);
++#else
++	ioprio_set(IOPRIO_WHO_PROCESS, getpid(), IOPRIO_CLASS_IDLE);
++#endif
++
+ 	// now do the work
+ 	for (i=optind; i<argc; i++) {
+ 		process_files(argv[i]);
+ 	}
++	
+ 	if (flag_sort)
+ 		process_sorted_files();
+ 	return 0;


More information about the Ubuntu-motu mailing list