From 6f7afab062b81ee8822dd2ac84e4f44608fa17be Mon Sep 17 00:00:00 2001 From: austin Date: Fri, 7 Nov 2008 05:01:12 -0500 Subject: sreadahead: Add a patch to set the app to io-idle running status. This patch sets the sreadahead to io-idle stauts when it is running, so that sreadahead will not preempt IO with other apps. --- .../sreadahead/sreadahead-0.02/set_to_idle.patch | 39 ++++++++++++++++++++++ meta-moblin/packages/sreadahead/sreadahead_0.02.bb | 1 + 2 files changed, 40 insertions(+) create mode 100644 meta-moblin/packages/sreadahead/sreadahead-0.02/set_to_idle.patch diff --git a/meta-moblin/packages/sreadahead/sreadahead-0.02/set_to_idle.patch b/meta-moblin/packages/sreadahead/sreadahead-0.02/set_to_idle.patch new file mode 100644 index 000000000..b48659048 --- /dev/null +++ b/meta-moblin/packages/sreadahead/sreadahead-0.02/set_to_idle.patch @@ -0,0 +1,39 @@ +diff -Naurp sreadahead-0.02/readahead.c sreadahead-0.02-nice/readahead.c +--- sreadahead-0.02/readahead.c 2008-11-06 00:57:17.000000000 -0500 ++++ sreadahead-0.02-nice/readahead.c 2008-11-06 02:28:29.000000000 -0500 +@@ -26,7 +26,18 @@ + #include + + #include "readahead.h" ++#include + ++# if defined(__i386__) ++# define __NR_ioprio_set 289 ++# elif defined(__x86_64__) ++# define __NR_ioprio_set 251 ++# else ++# error "Unsupported arch" ++# endif ++ ++#define IOPRIO_WHO_PROCESS 1 ++#define IOPRIO_CLASS_SHIFT 13 + #define MAXR 1024 + static struct readahead files[MAXR]; + static unsigned int total_files = 0; +@@ -68,7 +79,15 @@ void *one_thread(void *ptr) + + int main(int argc, char **argv) + { +- FILE *file = fopen("/etc/readahead.packed", "r"); ++ int iopriority = 7; /* hard code for idle */ ++ int iopriority_class = 3; /* 3 stands for idle */ ++ int pid = 0; ++ FILE *file; ++ ++ if (syscall(__NR_ioprio_set, IOPRIO_WHO_PROCESS, pid, iopriority | iopriority_class << IOPRIO_CLASS_SHIFT) == -1) ++ perror("Can not set priority to idle class"); ++ ++ file = fopen("/etc/readahead.packed", "r"); + if (!file) { + perror("Couldnt open /etc/readahead.packed"); + return -errno; diff --git a/meta-moblin/packages/sreadahead/sreadahead_0.02.bb b/meta-moblin/packages/sreadahead/sreadahead_0.02.bb index 1ca5f1655..b7341010a 100644 --- a/meta-moblin/packages/sreadahead/sreadahead_0.02.bb +++ b/meta-moblin/packages/sreadahead/sreadahead_0.02.bb @@ -9,6 +9,7 @@ inherit update-rc.d SRC_URI = "http://www.moblin.org/sites/all/files/sreadahead-${PV}.tar.gz \ file://sreadahead-0.02-make.patch;patch=1 \ file://readahead_c.patch;patch=1 \ + file://set_to_idle.patch;patch=1 \ file://sreadahead-generate.sh \ file://sreadahead.sh" -- cgit v1.2.3