Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1479530 > unrolled thread

[RFC/PATCH] posix-timers: make them configurable

Started byNicolas Pitre <nico@fluxnic.net>
First post2016-09-08 23:30 +0200
Last post2016-09-14 12:00 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RFC/PATCH] posix-timers: make them configurable Nicolas Pitre <nico@fluxnic.net> - 2016-09-08 23:30 +0200
    Re: [RFC/PATCH] posix-timers: make them configurable Thomas Gleixner <tglx@linutronix.de> - 2016-09-09 15:50 +0200
      Re: [RFC/PATCH] posix-timers: make them configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-09-13 23:00 +0200
        Re: [RFC/PATCH] posix-timers: make them configurable Thomas Gleixner <tglx@linutronix.de> - 2016-09-14 12:00 +0200

#1479530 — [RFC/PATCH] posix-timers: make them configurable

FromNicolas Pitre <nico@fluxnic.net>
Date2016-09-08 23:30 +0200
Subject[RFC/PATCH] posix-timers: make them configurable
Message-ID<sfeTM-2z8-25@gated-at.bofh.it>
Small embedded systems typically don't need them.  This removes about
16KB from the kernel binary size on ARM when configured out.  
Corresponding syscalls are routed to a stub logging the attempt to
use those syscalls which should be enough of a clue if they were 
disabled without proper consideration.

Signed-off-by: Nicolas Pitre <nico@linaro.org>

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index ee3de3421f..00e6098e9a 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -6,7 +6,7 @@ menu "PTP clock support"
 
 config PTP_1588_CLOCK
 	tristate "PTP clock support"
-	depends on NET
+	depends on NET && POSIX_TIMERS
 	select PPS
 	select NET_PTP_CLASSIFY
 	help
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index 62824f2fe4..b055aa1b6b 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -195,3 +195,13 @@ config HIGH_RES_TIMERS
 
 endmenu
 endif
+
+config POSIX_TIMERS
+	bool "Posix Clocks & timers" if EMBEDDED
+	default y
+	help
+	  This includes native support for POSIX timers into the kernel.
+	  Small embedded systems may have no use for them and therefore they
+	  can be configured out to reduce the size of the kernel image.
+	  If unsure say y.
+
diff --git a/kernel/time/Makefile b/kernel/time/Makefile
index 49eca0beed..fc26c308f5 100644
--- a/kernel/time/Makefile
+++ b/kernel/time/Makefile
@@ -1,6 +1,12 @@
-obj-y += time.o timer.o hrtimer.o itimer.o posix-timers.o posix-cpu-timers.o
+obj-y += time.o timer.o hrtimer.o itimer.o
 obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o
-obj-y += timeconv.o timecounter.o posix-clock.o alarmtimer.o
+obj-y += timeconv.o timecounter.o alarmtimer.o
+
+ifeq ($(CONFIG_POSIX_TIMERS),y)
+ obj-y += posix-timers.o posix-cpu-timers.o posix-clock.o
+else
+ obj-y += posix-stubs.o
+endif
 
 obj-$(CONFIG_GENERIC_CLOCKEVENTS)		+= clockevents.o tick-common.o
 ifeq ($(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST),y)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
new file mode 100644
index 0000000000..879f37f6f3
--- /dev/null
+++ b/kernel/time/posix-stubs.c
@@ -0,0 +1,82 @@
+/*
+ * Dummy stubs used when CONFIG_POSIX_TIMERS=n
+ *
+ * Created by:  Nicolas Pitre, July 2016
+ * Copyright:   (C) 2016 Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/linkage.h>
+#include <linux/kernel.h>
+#include <linux/random.h>
+#include <linux/errno.h>
+#include <linux/posix-timers.h>
+
+asmlinkage long sys_ni_posix_timers(void)
+{
+	pr_err_once("process %d (%s) attempted a POSIX timer syscall "
+		    "while CONFIG_POSIX_TIMERS is not set\n",
+		    current->pid, current->comm);
+	return -ENOSYS;
+}
+
+#define SYS_NI(name)  SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers)
+
+SYS_NI(timer_create);
+SYS_NI(timer_gettime);
+SYS_NI(timer_getoverrun);
+SYS_NI(timer_settime);
+SYS_NI(timer_delete);
+SYS_NI(clock_settime);
+SYS_NI(clock_gettime);
+SYS_NI(clock_adjtime);
+SYS_NI(clock_getres);
+SYS_NI(clock_nanosleep);
+
+void do_schedule_next_timer(struct siginfo *info)
+{
+}
+
+void exit_itimers(struct signal_struct *sig)
+{
+}
+
+void posix_timers_register_clock(const clockid_t clock_id,
+				 struct k_clock *new_clock)
+{
+}
+
+int posix_timer_event(struct k_itimer *timr, int si_private)
+{
+	return 0;
+}
+
+void run_posix_cpu_timers(struct task_struct *tsk)
+{
+}
+
+void posix_cpu_timers_exit(struct task_struct *tsk)
+{
+	add_device_randomness((const void*) &tsk->se.sum_exec_runtime,
+			      sizeof(unsigned long long));
+}
+
+void posix_cpu_timers_exit_group(struct task_struct *tsk)
+{
+}
+
+void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
+			   cputime_t *newval, cputime_t *oldval)
+{
+}
+
+void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
+{
+}
+
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
+{
+}

[toc] | [next] | [standalone]


#1480009

FromThomas Gleixner <tglx@linutronix.de>
Date2016-09-09 15:50 +0200
Message-ID<sfulP-3ra-21@gated-at.bofh.it>
In reply to#1479530
On Thu, 8 Sep 2016, Nicolas Pitre wrote:
> Small embedded systems typically don't need them.  This removes about
> 16KB from the kernel binary size on ARM when configured out.  
> Corresponding syscalls are routed to a stub logging the attempt to
> use those syscalls which should be enough of a clue if they were 
> disabled without proper consideration.
> 
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
> 
> diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
> index ee3de3421f..00e6098e9a 100644
> --- a/drivers/ptp/Kconfig
> +++ b/drivers/ptp/Kconfig
> @@ -6,7 +6,7 @@ menu "PTP clock support"
>  
>  config PTP_1588_CLOCK
>  	tristate "PTP clock support"
> -	depends on NET
> +	depends on NET && POSIX_TIMERS
>  	select PPS
>  	select NET_PTP_CLASSIFY
>  	help

You forgot CONFIG_TIMERFD ....

> +void do_schedule_next_timer(struct siginfo *info)
> +{
> +}

 ....

> +void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
> +{
> +}

You should make them static inlines in the headers so they get compiled out
completely.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1482776

FromNicolas Pitre <nicolas.pitre@linaro.org>
Date2016-09-13 23:00 +0200
Message-ID<sh2Ya-6XB-25@gated-at.bofh.it>
In reply to#1480009
On Fri, 9 Sep 2016, Thomas Gleixner wrote:

> On Thu, 8 Sep 2016, Nicolas Pitre wrote:
> > Small embedded systems typically don't need them.  This removes about
> > 16KB from the kernel binary size on ARM when configured out.  
> > Corresponding syscalls are routed to a stub logging the attempt to
> > use those syscalls which should be enough of a clue if they were 
> > disabled without proper consideration.
> > 
> > Signed-off-by: Nicolas Pitre <nico@linaro.org>
> > 
> > diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
> > index ee3de3421f..00e6098e9a 100644
> > --- a/drivers/ptp/Kconfig
> > +++ b/drivers/ptp/Kconfig
> > @@ -6,7 +6,7 @@ menu "PTP clock support"
> >  
> >  config PTP_1588_CLOCK
> >  	tristate "PTP clock support"
> > -	depends on NET
> > +	depends on NET && POSIX_TIMERS
> >  	select PPS
> >  	select NET_PTP_CLASSIFY
> >  	help
> 
> You forgot CONFIG_TIMERFD ....

Unless I'm mistaken, I don't see anything in timerfd.c that depends on 
the (removed) POSIX timer code.  What am I missing?


Nicolas

[toc] | [prev] | [next] | [standalone]


#1483142

FromThomas Gleixner <tglx@linutronix.de>
Date2016-09-14 12:00 +0200
Message-ID<shf90-7Hk-31@gated-at.bofh.it>
In reply to#1482776
On Tue, 13 Sep 2016, Nicolas Pitre wrote:
> On Fri, 9 Sep 2016, Thomas Gleixner wrote:
> > You forgot CONFIG_TIMERFD ....
> 
> Unless I'm mistaken, I don't see anything in timerfd.c that depends on 
> the (removed) POSIX timer code.  What am I missing?

Sorry, my memory tricked me. timerfd merily uses the posix timer clock ids
but nothing from posix-timer.c. alarmtimer is a different story.

Thanks,

	tglx

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web