um: Switch clocksource to hrtimers
Subsystems (2)
PATCH v4 1/1 um: Switch clocksource to hrtimers
Background: UML is using an obsolete itimer call for all timers and "polls" for kernel space timer firing in its userspace portion resulting in a long list of bugs and incorrect behaviour(s). It also uses ITIMER_VIRTUAL for its timer which results in the timer being dependent on it running and the cpu load.
This patch fixes this by moving to posix high resolution timers firing off CLOCK_MONOTONIC and relaying the timer correctly to the UML userspace.
FIXES: broken userspace timers - effecive ~40Hz instead of what they should be. Note - this modifies skas behavior by no longer setting an itimer per clone(). Timer events are relayed instead.
IMPROVES: overall responsiveness of the userspace
--- arch/um/Makefile | 2 +- arch/um/include/shared/os.h | 18 ++- arch/um/include/shared/skas/stub-data.h | 7 +- arch/um/include/shared/timer-internal.h | 13 ++ arch/um/kernel/process.c | 8 +- arch/um/kernel/skas/clone.c | 6 +- arch/um/kernel/skas/mmu.c | 3 + arch/um/kernel/time.c | 73 ++++++---- arch/um/os-Linux/internal.h | 1 - arch/um/os-Linux/main.c | 7 +- arch/um/os-Linux/process.c | 6 + arch/um/os-Linux/signal.c | 41 +++--- arch/um/os-Linux/skas/process.c | 45 ++---- arch/um/os-Linux/time.c | 246 ++++++++++++++++---------------- 14 files changed, 252 insertions(+), 224 deletions(-) create mode 100644 arch/um/include/shared/timer-internal.h delete mode 100644 arch/um/os-Linux/internal.h
arch/um/Makefile +1 -1
@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT) # The wrappers will select whether using "malloc" or the kernel allocator. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) +LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt # Used by link-vmlinux.sh which has special support for um link export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
arch/um/include/shared/os.h +13 -5
@@ -1,4 +1,6 @@/* +* Copyright (C) 2015 Anton Ivanov (aivanov@{brocade.com,kot-begemot.co.uk}) +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */
@@ -183,6 +185,7 @@ extern int create_mem_file(unsigned long long len);/* process.c */ extern unsigned long os_process_pc (int pid);extern int os_process_parent (int pid); +extern void os_alarm_process (int pid);extern void os_stop_process (int pid);extern void os_kill_process (int pid,int reap_child);extern void os_kill_ptraced_process (int pid,int reap_child);
@@ -217,7 +220,7 @@ extern int set_umid(char *name);extern char *get_umid (void );/* signal.c */ -extern void timer_init (void ); +extern void timer_set_signal_handler (void );extern void set_sigstack (void *sig_stack,int size);extern void remove_sigstack (void );extern void set_handler (int sig);
@@ -227,6 +230,7 @@ extern void unblock_signals(void);extern int get_signals (void );extern int set_signals (int enable);extern int os_is_signal_stack (void ); +extern void deliver_alarm (void );/* util.c */ extern void stack_protections (unsigned long address);
@@ -238,12 +242,16 @@ extern void um_early_printk(const char *s, unsigned int n);extern void os_fix_helper_signals (void );/* time.c */ -extern void idle_sleep (unsigned long long nsecs); -extern int set_interval (void ); -extern int timer_one_shot (int ticks); -extern long long disable_timer (void ); +extern void os_idle_sleep (unsigned long long nsecs); +extern int os_timer_create (void * timer); +extern int os_timer_set_interval (void * timer,void * its); +extern int os_timer_one_shot (int ticks); +extern long long os_timer_disable (void ); +extern long os_timer_remain (void * timer);extern void uml_idle_timer (void ); +extern long long os_persistent_clock_emulation (void );extern long long os_nsecs (void ); +extern long long os_vnsecs (void );/* skas/mem.c */ extern long run_syscall_stub(struct mm_id * mm_idp,
arch/um/include/shared/skas/stub-data.h +4 -3
@@ -1,4 +1,6 @@/* + +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2005 Jeff Dike ([email protected]) * Licensed under the GPL */
@@ -6,12 +8,11 @@#ifndef __STUB_DATA_H#define __STUB_DATA_H -#include <sys/time.h> +#include <time.h> struct stub_data { -long offset; +unsigned long offset;int fd; -struct itimerval timer;long err; };
arch/um/include/shared/timer-internal.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright (C) 2012 - 2014 Cisco Systems +* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) +* Licensed under the GPL +*/ + +#ifndef __TIMER_INTERNAL_H__ +#define __TIMER_INTERNAL_H__ + +#define TIMER_MULTIPLIER 256 +#define TIMER_MIN_DELTA 500 + +#endif
arch/um/kernel/process.c +4 -4
@@ -1,4 +1,6 @@/* +* Copyright (C) 2015 Anton Ivanov (aivanov@{brocade.com,kot-begemot.co.uk}) +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Copyright 2003 PathScale, Inc. * Licensed under the GPL
@@ -27,6 +29,7 @@#include <kern_util.h> #include <os.h> #include <skas.h> +#include <timer-internal.h> /* * This is a per-cpu array. A processor only modifies its entry and it only
@@ -203,11 +206,8 @@ void initial_thread_cb(void (*proc)(void *), void *arg)void arch_cpu_idle (void ) { -unsigned long long nsecs; - cpu_tasks[current_thread_info ()->cpu].pid =os_getpid (); - nsecs =disable_timer (); -idle_sleep (nsecs); +os_idle_sleep (UM_NSEC_PER_SEC );local_irq_enable (); }
arch/um/kernel/skas/clone.c +1 -5
@@ -1,4 +1,5 @@/* +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */
@@ -35,11 +36,6 @@ stub_clone_handler(void)if (err) goto out; - err =stub_syscall3 (__NR_setitimer,ITIMER_VIRTUAL , - (long ) &data->timer,0 ); -if (err) - goto out; -remap_stack (data->fd, data->offset); goto done;
arch/um/kernel/skas/mmu.c +3 -0
@@ -1,4 +1,5 @@/* +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */
@@ -61,10 +62,12 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)if (current->mm !=NULL && current->mm != &init_mm) from_mm = ¤t->mm->context; +block_signals ();if (from_mm) to_mm->id.u.pid =copy_context_skas0 (stack, from_mm->id.u.pid);else to_mm->id.u.pid =start_userspace (stack); +unblock_signals ();if (to_mm->id.u.pid <0 ) { ret = to_mm->id.u.pid;
arch/um/kernel/time.c +48 -25
150 lines not on this page · raw message
arch/um/os-Linux/internal.h deleted +0 -1
@@ -1 +0,0 @@ -void alarm_handler (int sig,struct siginfo *unused_si,mcontext_t *mc);
arch/um/os-Linux/main.c +4 -3
@@ -1,4 +1,5 @@/* +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */
@@ -163,13 +164,13 @@ int __init main(int argc, char **argv, char **envp)/* * This signal stuff used to be in the reboot case. However, -* sometimes a SIGVTALRM can come in when we're halting (reproducably +* sometimes a timer signal can come in when we're halting (reproducably * when writing out gcov information, presumably because that takes * some time) and cause a segfault. */ -/* stop timers and set SIGVTALRM to be ignored */ -disable_timer (); +/* stop timers and set timer signal to be ignored */ +os_timer_disable ();/* disable SIGIO for the fds and set SIGIO to be ignored */ err =deactivate_all_fds ();
arch/um/os-Linux/process.c +6 -0
@@ -1,4 +1,5 @@/* +* Copyright (C) 2015 Thomas Meyer ([email protected]) * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */
@@ -89,6 +90,11 @@ int os_process_parent(int pid)return parent; } +void os_alarm_process (int pid) +{ +kill (pid,SIGALRM ); +} +void os_stop_process (int pid) {kill (pid,SIGSTOP );
arch/um/os-Linux/signal.c +22 -19
118 lines not on this page · raw message
arch/um/os-Linux/skas/process.c +10 -35
104 lines not on this page · raw message
arch/um/os-Linux/time.c +123 -123
304 lines not on this page · raw message
Signature · 8 lines
2.1.4 ------------------------------------------------------------------------------ _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Richard Weinberger
maintainerAm 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 23 lines
arch/um/os-Linux/time.c +8
-11-void idle_sleep (unsigned long long nsecs) +/** +* os_idle_sleep() - sleep for a given time of nsecs +* @nsecs: nanoseconds to sleep +*/ +void os_idle_sleep (unsigned long long nsecs) {struct timespec ts; -/* -* nsecs can come in as zero, in which case, this starts a -* busy loop. To prevent this, reset nsecs to the tick -* interval if it is zero. -*/ -if (nsecs ==0 ) - nsecs =UM_NSEC_PER_SEC /UM_HZ ; +if (nsecs <=0 ) { +return ; + } - nsecs =sleep_time (nsecs); - ts = ((struct timespec ) { .tv_sec = nsecs /UM_NSEC_PER_SEC , - .tv_nsec = nsecs %UM_NSEC_PER_SEC });
arch/um/os-Linux/time.c line 185
Quoted 10 lines
arch/um/os-Linux/time.c +6
-2+ ts = ((struct timespec ) { + .tv_sec = nsecs /UM_NSEC_PER_SEC , + .tv_nsec = nsecs %UM_NSEC_PER_SEC + }); -if (nanosleep (&ts, &ts) ==0 ) +if (clock_nanosleep (CLOCK_MONOTONIC ,0 , &ts,NULL )) {deliver_alarm (); -after_sleep_interval (&ts); + }
Hmm, now this function sleeps at most nsecs. If it is interrupted the alarm is delivered.
Why only upon interruption and not also if clock_nanosleep() completes?
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 29 lines · Richard Weinberger
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 28 lines
arch/um/os-Linux/time.c +12
-11-void idle_sleep (unsigned long long nsecs) +/** +* os_idle_sleep() - sleep for a given time of nsecs +* @nsecs: nanoseconds to sleep +*/ +void os_idle_sleep (unsigned long long nsecs) {struct timespec ts; -/* -* nsecs can come in as zero, in which case, this starts a -* busy loop. To prevent this, reset nsecs to the tick -* interval if it is zero. -*/ -if (nsecs ==0 ) - nsecs =UM_NSEC_PER_SEC /UM_HZ ; +if (nsecs <=0 ) { +return ; + } - nsecs =sleep_time (nsecs); - ts = ((struct timespec ) { .tv_sec = nsecs /UM_NSEC_PER_SEC , - .tv_nsec = nsecs %UM_NSEC_PER_SEC }); + ts = ((struct timespec ) { + .tv_sec = nsecs /UM_NSEC_PER_SEC , + .tv_nsec = nsecs %UM_NSEC_PER_SEC + });
Quoted 9 lines
arch/um/os-Linux/time.c line 185
Quoted 5 lines
arch/um/os-Linux/time.c +2
-2-if (nanosleep (&ts, &ts) ==0 ) +if (clock_nanosleep (CLOCK_MONOTONIC ,0 , &ts,NULL )) {deliver_alarm (); -after_sleep_interval (&ts); + }Hmm, now this function sleeps at most nsecs. If it is interrupted the alarm is delivered.
Why only upon interruption and not also ifclock_nanosleep()completes?
It is invoked differently.
We changed process.c too.
The old behaviour used to be to disable the timer, read timer remaining and program a nanosleep with that. This resulted in the timer actually firing in idle despite UML using the virtual clock for timers.
With timer moving to MONOTONIC we could do the same, but we do not need to. Instead of disabling the timer we can leave it running and program a nanosleep which is long enough in most cases for the timer to fire. This is what the matching change in process.c does. Together, this results in saving at least 2 syscalls per each idle invocation.
A.
Quoted 10 lines
Thanks,
//richard------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 47 lines · Anton Ivanov
Quoted 29 lines · Richard Weinberger
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 28 lines
arch/um/os-Linux/time.c +12
-11-void idle_sleep (unsigned long long nsecs) +/** +* os_idle_sleep() - sleep for a given time of nsecs +* @nsecs: nanoseconds to sleep +*/ +void os_idle_sleep (unsigned long long nsecs) {struct timespec ts; -/* -* nsecs can come in as zero, in which case, this starts a -* busy loop. To prevent this, reset nsecs to the tick -* interval if it is zero. -*/ -if (nsecs ==0 ) - nsecs =UM_NSEC_PER_SEC /UM_HZ ; +if (nsecs <=0 ) { +return ; + } - nsecs =sleep_time (nsecs); - ts = ((struct timespec ) { .tv_sec = nsecs /UM_NSEC_PER_SEC , - .tv_nsec = nsecs %UM_NSEC_PER_SEC }); + ts = ((struct timespec ) { + .tv_sec = nsecs /UM_NSEC_PER_SEC , + .tv_nsec = nsecs %UM_NSEC_PER_SEC + });Quoted 9 lines
arch/um/os-Linux/time.c line 185
Quoted 5 lines
arch/um/os-Linux/time.c +2
-2-if (nanosleep (&ts, &ts) ==0 ) +if (clock_nanosleep (CLOCK_MONOTONIC ,0 , &ts,NULL )) {deliver_alarm (); -after_sleep_interval (&ts); + }Hmm, now this function sleeps at most nsecs. If it is interrupted the alarm is delivered.
Why only upon interruption and not also ifclock_nanosleep()completes?It is invoked differently.
We changed
process.ctoo.The old behaviour used to be to disable the timer, read timer remaining and program a nanosleep with that. This resulted in the timer actually firing in idle despite UML using the virtual clock for timers.
Quoted 5 lines
With timer moving to MONOTONIC we could do the same, but we do not need to. Instead of disabling the timer we can leave it running and program a nanosleep which is long enough in most cases for the timer to fire. This is what the matching change in
process.cdoes. Together, this results in saving at least 2 syscalls per each idle invocation.
Re-reading this, I did not answer the question fully, apologies.
clock_nanosleep here is usually programmed with a fixed value in process.c which is of no relation to the time when the next timer interrupt should be delivered. So there is no need to re-deliver an interrupt at the end of a nanosleep as the end of the nanosleep is of no significance as far as the timer subsystem is concerned.
IMHO, the IRQ only needs to be relayed when the nanosleep is interrupted.
That differs to the old behaviour which programmed the nanosleep with the remainder of the time till the next interrupt thus making it necessary to relay once the nanosleep expires and restart the nanosleep if it was interrupted by IO.
A.
Quoted 13 lines
A.
Quoted 9 lines
Thanks,
//richard------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 6 lines
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Am 03.11.2015 8:11 vorm. schrieb Anton Ivanov <[email protected]>:
Quoted 57 lines · Anton Ivanov
Quoted 47 lines · Richard Weinberger
Quoted 30 lines
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 29 lines
arch/um/os-Linux/time.c +5
-1-void idle_sleep (unsigned long long nsecs) +/** +* os_idle_sleep() - sleep for a given time of nsecs +* @nsecs: nanoseconds to sleep +*/ +void os_idle_sleep (unsigned long long nsecs){
struct timespec ts;
- /*
- * nsecs can come in as zero, in which case, this starts a
- * busy loop. To prevent this, reset nsecs to the tick
- * interval if it is zero.
- */
- if (nsecs == 0)
- nsecs =UM_NSEC_PER_SEC/UM_HZ;
+ if (nsecs <= 0) {
+ return;
+ }
- nsecs =sleep_time(nsecs);
- ts = ((struct timespec) { .tv_sec = nsecs /UM_NSEC_PER_SEC,
- .tv_nsec = nsecs %UM_NSEC_PER_SEC});
+ ts = ((struct timespec) {
+ .tv_sec = nsecs /UM_NSEC_PER_SEC,
+ .tv_nsec = nsecs %UM_NSEC_PER_SEC
+ });
- if (nanosleep(&ts, &ts)== 0)Quoted 8 lines
Quoted 4 lines
+ if (
clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL)) {deliver_alarm();
-after_sleep_interval(&ts);
+ }Hmm, now this function sleeps at most nsecs. If it is interrupted the alarm is delivered.
Why only upon interruption and not also ifclock_nanosleep()completes?It is invoked differently.
We changed
process.ctoo.The old behaviour used to be to disable the timer, read timer remaining and program a nanosleep with that. This resulted in the timer actually firing in idle despite UML using the virtual clock for timers.
Quoted 5 lines
With timer moving to MONOTONIC we could do the same, but we do not need to. Instead of disabling the timer we can leave it running and program a nanosleep which is long enough in most cases for the timer to fire. This is what the matching change in
process.cdoes. Together, this results in saving at least 2 syscalls per each idle invocation.Re-reading this, I did not answer the question fully, apologies.
Quoted 7 lines
clock_nanosleephere is usually programmed with a fixed value inprocess.cwhich is of no relation to the time when the next timer interrupt should be delivered. So there is no need to re-deliver an interrupt at the end of a nanosleep as the end of the nanosleep is of no significance as far as the timer subsystem is concerned.IMHO, the IRQ only needs to be relayed when the nanosleep is interrupted.
Ah, okay, now I understand the problem. I didn't think about this case!
Nice catch Richard!
Thanks Anton for figuring this out!
With kind regards
Thomas
Quoted 13 lines
That differs to the old behaviour which programmed the nanosleep with the remainder of the time till the next interrupt thus making it necessary to relay once the nanosleep expires and restart the nanosleep if it was interrupted by IO.
A.
Quoted 5 lines
A.
Quoted 2 lines
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 19 lines
Background: UML is using an obsolete itimer call for all timers and "polls" for kernel space timer firing in its userspace portion resulting in a long list of bugs and incorrect behaviour(s). It also uses
ITIMER_VIRTUALfor its timer which results in the timer being dependent on it running and the cpu load.This patch fixes this by moving to posix high resolution timers firing off
CLOCK_MONOTONICand relaying the timer correctly to the UML userspace.Fixes crashes when hosts suspends/resumesFIXES: broken userspace timers - effecive ~40Hz instead of what they should be. Note - this modifies skas behavior by no longer setting an itimer per
clone(). Timer events are relayed instead.
Quoted 8 lines
Fixes kernel network packet scheduling disciplinesFixes tcp behaviour especially under loadFixes various timer related corner casesIMPROVES: overall responsiveness of the userspace
Signed-off-by Thomas Meyer <[email protected]>Signed-off-by Anton Ivanov <[email protected]>
Applied!
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Cool,
Is there a tree I can pull so I can have the next one (the epoll based IRQ controller) incremental?
A.
Quoted 24 lines · Richard Weinberger
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 23 lines
Background: UML is using an obsolete itimer call for all timers and "polls" for kernel space timer firing in its userspace portion resulting in a long list of bugs and incorrect behaviour(s). It also uses
ITIMER_VIRTUALfor its timer which results in the timer being dependent on it running and the cpu load.This patch fixes this by moving to posix high resolution timers firing off
CLOCK_MONOTONICand relaying the timer correctly to the UML userspace.Fixes crashes when hosts suspends/resumesFIXES: broken userspace timers - effecive ~40Hz instead of what they should be. Note - this modifies skas behavior by no longer setting an itimer per
clone(). Timer events are relayed instead.Fixes kernel network packet scheduling disciplinesFixes tcp behaviour especially under loadFixes various timer related corner cases
Quoted 8 lines
Quoted 4 lines
IMPROVES: overall responsiveness of the userspace
Signed-off-by Thomas Meyer <[email protected]>Signed-off-by Anton Ivanov <[email protected]>Applied!
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Richard Weinberger
maintainerHi!
Am 07.11.2015 um 11:29 schrieb Anton Ivanov:
Quoted 3 lines
Cool,
Is there a tree I can pull so I can have the next one (the epoll based IRQ controller) incremental?
Sure, it is in uml's next:
https://git.kernel.org/cgit/linux/kernel/git/rw/uml.git/log/?h=linux-next
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 10 lines · Richard Weinberger
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 8 lines
Background: UML is using an obsolete itimer call for all timers and "polls" for kernel space timer firing in its userspace portion resulting in a long list of bugs and incorrect behaviour(s). It also uses
ITIMER_VIRTUALfor its timer which results in the timer being dependent on it running and the cpu load.
Quoted 8 lines
Quoted 6 lines
This patch fixes this by moving to posix high resolution timers firing off
CLOCK_MONOTONICand relaying the timer correctly to the UML userspace.Signed-off-by Thomas Meyer <[email protected]>Signed-off-by Anton Ivanov <[email protected]>Applied!
Looks like this broke ARCH=um SUBARCH=x86-64 builds on (at least) David Miller's net-next tree. On ubuntu 14.04, gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4, I get:
arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference to timer_create' arch/um/os-Linux/built-in.o: In function os_timer_set_interval':
/android/kernel/android/arch/um/os-Linux/time.c:84: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_remain':
/android/kernel/android/arch/um/os-Linux/time.c:109: undefined reference to timer_gettime' arch/um/os-Linux/built-in.o: In function os_timer_one_shot':
/android/kernel/android/arch/um/os-Linux/time.c:132: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_disable':
/android/kernel/android/arch/um/os-Linux/time.c:145: undefined reference to `timer_settime'
collect2: error: ld returned 1 exit status
The command being run is this:
+ gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt -o .tmp_vmlinux1 -Wl,-T,./arch/um/kernel/vmlinux.lds init/built-in.o -Wl,--start-group usr/built-in.o arch/um/kernel/built-in.o arch/um/drivers/built-in.o arch/um/os-Linux/built-in.o arch/x86/crypto/built-in.o arch/x86/um/built-in.o kernel/built-in.o certs/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o lib/lib.a lib/built-in.o drivers/built-in.o sound/built-in.o firmware/built-in.o net/built-in.o virt/built-in.o -Wl,--end-group -lutil
The following patch results in a working kernel, but I have no idea if it's correct. Thoughts?
arch/um/Makefile +1 -1
@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT) # The wrappers will select whether using "malloc" or the kernel allocator. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt +LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) # Used by link-vmlinux.sh which has special support for um link export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
scripts/link-vmlinux.sh +1 -1
@@ -62,7 +62,7 @@ vmlinux_link() -Wl,--start-group \ ${KBUILD_VMLINUX_MAIN} \ -Wl,--end-group \ - -lutil ${1} + -lutil -lrt ${1} rm -f linux fi }
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 51 lines · Lorenzo Colitti
Quoted 9 lines · Richard Weinberger
Am 02.11.2015 um 17:16 schrieb Anton Ivanov:
Quoted 8 lines
Background: UML is using an obsolete itimer call for all timers and "polls" for kernel space timer firing in its userspace portion resulting in a long list of bugs and incorrect behaviour(s). It also uses
ITIMER_VIRTUALfor its timer which results in the timer being dependent on it running and the cpu load.Quoted 7 lines
Quoted 6 lines
This patch fixes this by moving to posix high resolution timers firing off
CLOCK_MONOTONICand relaying the timer correctly to the UML userspace.Signed-off-by Thomas Meyer <[email protected]>Signed-off-by Anton Ivanov <[email protected]>Applied!
Looks like this broke ARCH=um SUBARCH=x86-64 builds on (at least) David Miller's net-next tree. On ubuntu 14.04, gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4, I get:
arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference totimer_create' arch/um/os-Linux/built-in.o: In functionos_timer_set_interval':
/android/kernel/android/arch/um/os-Linux/time.c:84: undefined reference totimer_settime' arch/um/os-Linux/built-in.o: In functionos_timer_remain':
/android/kernel/android/arch/um/os-Linux/time.c:109: undefined reference totimer_gettime' arch/um/os-Linux/built-in.o: In functionos_timer_one_shot':
/android/kernel/android/arch/um/os-Linux/time.c:132: undefined reference totimer_settime' arch/um/os-Linux/built-in.o: In functionos_timer_disable':
/android/kernel/android/arch/um/os-Linux/time.c:145: undefined reference to `timer_settime'
collect2: error: ld returned 1 exit statusThe command being run is this:
+ gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt -o .tmp_vmlinux1
-Wl,-T,./arch/um/kernel/vmlinux.ldsinit/built-in.o-Wl,--start-groupusr/built-in.oarch/um/kernel/built-in.oarch/um/drivers/built-in.oarch/um/os-Linux/built-in.oarch/x86/crypto/built-in.oarch/x86/um/built-in.okernel/built-in.ocerts/built-in.omm/built-in.ofs/built-in.oipc/built-in.osecurity/built-in.ocrypto/built-in.oblock/built-in.olib/lib.alib/built-in.odrivers/built-in.osound/built-in.ofirmware/built-in.onet/built-in.ovirt/built-in.o-Wl,--end-group -lutil
Quoted 2 lines
The following patch results in a working kernel, but I have no idea if it's correct. Thoughts?
It is.
You need -lrt to link in HR timers. However, the original patch should add that to the library list. I need to understand why it does not in the dm tree.
A.
Quoted 19 lines
arch/um/Makefile +1
-1@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT) # The wrappers will select whether using "malloc" or the kernel allocator. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt +LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) # Used by link-vmlinux.sh which has special support for um link export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)scripts/link-vmlinux.sh +0
-0
scripts/link-vmlinux.sh vmlinux_link() · line 68
Quoted 8 lines
scripts/link-vmlinux.sh +1
-1@@ -62,7 +62,7 @@ vmlinux_link() -Wl,--start-group \ ${KBUILD_VMLINUX_MAIN} \ -Wl,--end-group \ - -lutil ${1} + -lutil -lrt ${1} rm -f linux fi }
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 5 lines · Anton Ivanov
It is.
You need -lrt to link in HR timers. However, the original patch should add that to the library list. I need to understand why it does not in the dm tree.
I noticed that command already does contain "-lrt", just in a different place. It starts off with:
gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt <...>
That command line doesn't work, but if you remove the -lrt and put it at the end of the line, it starts working. Is the order significant? Or is it a bug in GCC's command line parsing?
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Richard Weinberger
maintainerAm 18.11.2015 um 08:10 schrieb Lorenzo Colitti:
Quoted 11 lines
Quoted 5 lines · Anton Ivanov
It is.
You need -lrt to link in HR timers. However, the original patch should add that to the library list. I need to understand why it does not in the dm tree.
I noticed that command already does contain "-lrt", just in a different place. It starts off with:
Quoted 6 lines
gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt <...>
That command line doesn't work, but if you remove the -lrt and put it at the end of the line, it starts working. Is the order significant? Or is it a bug in GCC's command line parsing?
The order matters.
-lrt has to be placed after all object files which need the rt library. Can you double check whether this is the case?
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 8 lines · Richard Weinberger
Quoted 4 lines
That command line doesn't work, but if you remove the -lrt and put it at the end of the line, it starts working. Is the order significant? Or is it a bug in GCC's command line parsing?
The order matters.
-lrt has to be placed after all object files which need the rt library. Can you double check whether this is the case?
No, it's not the case. The error is when linking arch/um/os-Linux/built-in.o:
arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference to `timer_create'
and in the generated command line, -lrt appearsbeforearch/um/os-Linux/built-in.o:
+ gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt -o .tmp_vmlinux1 -Wl,-T,./arch/um/kernel/vmlinux.lds init/built-in.o -Wl,--start-group usr/built-in.o arch/um/kernel/built-in.o arch/um/drivers/built-in.o arch/um/os-Linux/built-in.o arch/x86/crypto/built-in.o arch/x86/um/built-in.o kernel/built-in.o certs/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o lib/lib.a lib/built-in.o drivers/built-in.o sound/built-in.o firmware/built-in.o net/built-in.o virt/built-in.o -Wl,--end-group -lutil
Taking -lrt out of arch/um/Makefile and putting it into link-vmlinux.sh, as per the patch I suggested above, results in -lrt being the last thing on the command line, after -lutil.
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Richard Weinberger
maintainerHi!
Am 18.11.2015 um 14:32 schrieb Lorenzo Colitti:
Quoted 30 lines · Richard Weinberger
Quoted 8 lines
Quoted 4 lines
That command line doesn't work, but if you remove the -lrt and put it at the end of the line, it starts working. Is the order significant? Or is it a bug in GCC's command line parsing?
The order matters.
-lrt has to be placed after all object files which need the rt library. Can you double check whether this is the case?No, it's not the case. The error is when linking
arch/um/os-Linux/built-in.o:
arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference to `timer_create'and in the generated command line, -lrt appears
beforearch/um/os-Linux/built-in.o:+ gcc -Wl,-rpath,/lib64 -m64 -Wl,-rpath,/lib -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -Wl,-m -Wl,elf_x86_64 -lrt -o .tmp_vmlinux1
-Wl,-T,./arch/um/kernel/vmlinux.ldsinit/built-in.o-Wl,--start-groupusr/built-in.oarch/um/kernel/built-in.oarch/um/drivers/built-in.oarch/um/os-Linux/built-in.oarch/x86/crypto/built-in.oarch/x86/um/built-in.okernel/built-in.ocerts/built-in.omm/built-in.ofs/built-in.oipc/built-in.osecurity/built-in.ocrypto/built-in.oblock/built-in.olib/lib.alib/built-in.odrivers/built-in.osound/built-in.ofirmware/built-in.onet/built-in.ovirt/built-in.o-Wl,--end-group -lutil
Quoted 4 lines
Taking -lrt out of
arch/um/Makefileand putting it intolink-vmlinux.sh, as per the patch I suggested above, results in -lrt being the last thing on the command line, after -lutil.
Okay, please send a proper patch. :-)
Thanks,
//richard
------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel