diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-07-25 20:26:04 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-07-25 20:26:04 +0200 |
commit | 77e56d50bed29c1554d37e9d99ac81b7ef1ead6f (patch) | |
tree | c63cf9a96ded8843fd5e5b0a45b9caf958d68b8f /debian/patches | |
parent | a611425f5f3643e3c3fa0a051ebc08f6cdcc5182 (diff) |
add patch series
Diffstat (limited to 'debian/patches')
3 files changed, 221 insertions, 0 deletions
diff --git a/debian/patches/clock_boottime0001-include-provide-time-value-substraction.patch b/debian/patches/clock_boottime0001-include-provide-time-value-substraction.patch new file mode 100644 index 0000000..f65ae27 --- /dev/null +++ b/debian/patches/clock_boottime0001-include-provide-time-value-substraction.patch @@ -0,0 +1,70 @@ +From bb23879791cf015f17cb50b6443bac44b1cfbc72 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sat, 25 Jul 2015 20:04:27 +0200 +Subject: [PATCH gnumach 1/2] include: provide time-value substraction + +* include/mach/time_value.h (time_value_assert): New macro to assert +that the given value is well-formed. +(time_value_add_usec): Use the new macro. +(time_value_sub_usec): New macro. +(time_value_add): Use `time_value_add_usec'. +(time_value_sub_usec): New macro. +--- + include/mach/time_value.h | 31 ++++++++++++++++++++++++------- + 1 file changed, 24 insertions(+), 7 deletions(-) + +diff --git a/include/mach/time_value.h b/include/mach/time_value.h +index 2a2f091..61be581 100644 +--- a/include/mach/time_value.h ++++ b/include/mach/time_value.h +@@ -45,23 +45,40 @@ typedef struct time_value time_value_t; + */ + #define TIME_MICROS_MAX (1000000) + ++#define time_value_assert(val) \ ++ assert(0 <= (val)->microseconds && (val)->microseconds < TIME_MICROS_MAX); ++ + #define time_value_add_usec(val, micros) { \ ++ time_value_assert(val); \ + if (((val)->microseconds += (micros)) \ + >= TIME_MICROS_MAX) { \ + (val)->microseconds -= TIME_MICROS_MAX; \ + (val)->seconds++; \ + } \ ++ time_value_assert(val); \ + } + +-#define time_value_add(result, addend) { \ +- (result)->microseconds += (addend)->microseconds; \ +- (result)->seconds += (addend)->seconds; \ +- if ((result)->microseconds >= TIME_MICROS_MAX) { \ +- (result)->microseconds -= TIME_MICROS_MAX; \ +- (result)->seconds++; \ +- } \ ++#define time_value_sub_usec(val, micros) { \ ++ time_value_assert(val); \ ++ if (((val)->microseconds -= (micros)) < 0) { \ ++ (val)->microseconds += TIME_MICROS_MAX; \ ++ (val)->seconds--; \ ++ } \ ++ time_value_assert(val); \ + } + ++#define time_value_add(result, addend) { \ ++ time_value_assert(addend); \ ++ (result)->seconds += (addend)->seconds; \ ++ time_value_add_usec(result, (addend)->microseconds); \ ++ } ++ ++#define time_value_sub(result, subtrahend) { \ ++ time_value_assert(subtrahend); \ ++ (result)->seconds -= (subtrahend)->seconds; \ ++ time_value_sub_usec(result, (subtrahend)->microseconds); \ ++ } ++ + /* + * Time value available through the mapped-time interface. + * Read this mapped value with +-- +2.1.4 + diff --git a/debian/patches/clock_boottime0002-kern-add-boot-time-clock-use-it-for-time-stamps.patch b/debian/patches/clock_boottime0002-kern-add-boot-time-clock-use-it-for-time-stamps.patch new file mode 100644 index 0000000..bc84825 --- /dev/null +++ b/debian/patches/clock_boottime0002-kern-add-boot-time-clock-use-it-for-time-stamps.patch @@ -0,0 +1,149 @@ +From 3db15a3f80f193826e144b1944727a65c13340fe Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sat, 25 Jul 2015 18:23:10 +0200 +Subject: [PATCH gnumach 2/2] kern: add boot-time clock, use it for time stamps + +The kernel keeps track of task and thread creation times by saving a +time stamp. Previously, the real-time clock was used for this. When +the real-time clock is changed, however, the reference frame for the +time stamps is lost. This surfaced in Hurd systems reporting +spuriously long uptimes. + +Fix this by creating a boot-time clock and use it as reference frame +for the time stamps. + +* kern/mach_clock.c (clock_boottime_offset): Create clock by keeping +track of the offset from the real-time. +(clock_boottime_update): New function. +(record_time_stamp): Use the boot-time clock for time stamps. +(read_time_stamp): New function to convert it back to real-time. +(host_set_time): Call `clock_boottime_update'. +* kern/mach_clock.h (record_time_stamp): Amend comment. +(read_time_stamp): New declaration. +* kern/task.c (task_info): Use `read_time_stamp'. +* kern/thread.c (thread_info): Likewise. +--- + kern/mach_clock.c | 36 +++++++++++++++++++++++++++++++++++- + kern/mach_clock.h | 11 ++++++++++- + kern/task.c | 3 ++- + kern/thread.c | 3 ++- + 4 files changed, 49 insertions(+), 4 deletions(-) + +diff --git a/kern/mach_clock.c b/kern/mach_clock.c +index b627b89..655adf4 100644 +--- a/kern/mach_clock.c ++++ b/kern/mach_clock.c +@@ -367,9 +367,30 @@ void init_timeout(void) + + elapsed_ticks = 0; + } ++ ++/* ++ * We record timestamps using the boot-time clock. We keep track of ++ * the boot-time clock by storing the difference to the real-time ++ * clock. ++ */ ++struct time_value clock_boottime_offset; ++ ++/* ++ * Update the offset of the boot-time clock from the real-time clock. ++ * This function must be called when the real-time clock is updated. ++ * This function must be called at SPLHIGH. ++ */ ++void ++clock_boottime_update(struct time_value *new_time) ++{ ++ struct time_value delta = time; ++ time_value_sub(&delta, new_time); ++ time_value_add(&clock_boottime_offset, &delta); ++} + + /* +- * Record a timestamp in STAMP. ++ * Record a timestamp in STAMP. Records values in the boot-time clock ++ * frame. + */ + void + record_time_stamp (time_value_t *stamp) +@@ -378,6 +399,18 @@ record_time_stamp (time_value_t *stamp) + stamp->seconds = mtime->seconds; + stamp->microseconds = mtime->microseconds; + } while (stamp->seconds != mtime->check_seconds); ++ time_value_add(stamp, &clock_boottime_offset); ++} ++ ++/* ++ * Read a timestamp in STAMP into RESULT. Returns values in the ++ * real-time clock frame. ++ */ ++void ++read_time_stamp (time_value_t *stamp, time_value_t *result) ++{ ++ *result = *stamp; ++ time_value_sub(result, &clock_boottime_offset); + } + + +@@ -423,6 +456,7 @@ host_set_time(host, new_time) + #endif /* NCPUS > 1 */ + + s = splhigh(); ++ clock_boottime_update(&new_time); + time = new_time; + update_mapped_time(&time); + resettodr(); +diff --git a/kern/mach_clock.h b/kern/mach_clock.h +index 89fd335..1af0cda 100644 +--- a/kern/mach_clock.h ++++ b/kern/mach_clock.h +@@ -86,9 +86,18 @@ extern boolean_t reset_timeout(timer_elt_t telt); + + extern void init_timeout (void); + +-/* Read the current time into STAMP. */ ++/* ++ * Record a timestamp in STAMP. Records values in the boot-time clock ++ * frame. ++ */ + extern void record_time_stamp (time_value_t *stamp); + ++/* ++ * Read a timestamp in STAMP into RESULT. Returns values in the ++ * real-time clock frame. ++ */ ++extern void read_time_stamp (time_value_t *stamp, time_value_t *result); ++ + extern kern_return_t host_get_time( + host_t host, + time_value_t *current_time); +diff --git a/kern/task.c b/kern/task.c +index b384347..9a3d848 100644 +--- a/kern/task.c ++++ b/kern/task.c +@@ -783,7 +783,8 @@ kern_return_t task_info( + = task->total_system_time.seconds; + basic_info->system_time.microseconds + = task->total_system_time.microseconds; +- basic_info->creation_time = task->creation_time; ++ read_time_stamp(&task->creation_time, ++ &basic_info->creation_time); + task_unlock(task); + + if (*task_info_count > TASK_BASIC_INFO_COUNT) +diff --git a/kern/thread.c b/kern/thread.c +index 1f47553..865a1cc 100644 +--- a/kern/thread.c ++++ b/kern/thread.c +@@ -1503,7 +1503,8 @@ kern_return_t thread_info( + &basic_info->system_time); + basic_info->base_priority = thread->priority; + basic_info->cur_priority = thread->sched_pri; +- basic_info->creation_time = thread->creation_time; ++ read_time_stamp(&thread->creation_time, ++ &basic_info->creation_time); + + /* + * To calculate cpu_usage, first correct for timer rate, +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 029e46a..3577323 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -13,3 +13,5 @@ sysenter0001-yyy-sysenter-prototype.patch vm-cache-policy0001-VM-cache-policy-change.patch vm-cache-policy0002-vm-keep-track-of-clean-pages.patch vm-cache-policy0003-vm-evict-clean-pages-first.patch +clock_boottime0001-include-provide-time-value-substraction.patch +clock_boottime0002-kern-add-boot-time-clock-use-it-for-time-stamps.patch |