All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] posix-timers: make them configurable
@ 2016-09-08 21:05 Nicolas Pitre
  2016-09-08 21:19 ` John Stultz
  2016-09-09 13:39 ` Thomas Gleixner
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Pitre @ 2016-09-08 21:05 UTC (permalink / raw)
  To: Thomas Gleixner, John Stultz; +Cc: linux-kernel


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)
+{
+}

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-09-14  9:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 21:05 [RFC/PATCH] posix-timers: make them configurable Nicolas Pitre
2016-09-08 21:19 ` John Stultz
2016-09-08 21:48   ` Josh Triplett
     [not found]   ` <i7B1bN3EzSJWci7B2bJXya@videotron.ca>
2016-09-08 23:56     ` Nicolas Pitre
2016-09-09  0:37       ` Josh Triplett
2016-09-09  7:48   ` Richard Cochran
2016-09-09  8:00     ` Josh Triplett
2016-09-09 13:47       ` Thomas Gleixner
2016-09-09 13:46     ` Thomas Gleixner
2016-09-09 13:39 ` Thomas Gleixner
2016-09-13 20:57   ` Nicolas Pitre
2016-09-14  9:47     ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.