Received: by 10.223.164.202 with SMTP id h10csp3836228wrb; Mon, 20 Nov 2017 05:54:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxUpMDAWnH2PzsJznhSvSxjQ0FoUYQMgfqEij1rl9dp7z0umZpPrZKosVhHsRKNJkvsqr1 X-Received: by 10.84.234.198 with SMTP id i6mr14157394plt.260.1511186045937; Mon, 20 Nov 2017 05:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511186045; cv=none; d=google.com; s=arc-20160816; b=yphRKK2sc0Nl+dPFI01ahz10bsGC5l+CiR5cE6g9JYUvgL47Egj5R5WegqL9tCSIdY EuPf4a9n4FDz7mSV/4PLkYF28vtoMu9cLb3NpSTP23pK+YdrLQgR0E7JpwiltcDMFBBh B14ou+f9kFcbFz9iZ3xMUoQFWIOIJQhrnLi7Sf5uzi+J4nyKa5Gwy3LOm19MwExv6ZG6 JnYvSBOQ5iGScSeihd2vE0ylCr0BR1ja+EK44I83lUGLXWtS94ydaD5sm55+P4kF1J9X 6K0OtU6BO1LCCshua2vWN09zKmBFNjwYH+3ZrscGNTcC854SbHlpNhmXgyw8Ynn3WICW 91UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=uF3izAjXDB8LVJ3t8upcTnIpjXSHbpGHeZAPgp03Iyo=; b=o95ipWPfQrqHege+2ERTU3x6/RSr+xu40/ZJRiHJ4kHZ1mct4Dlg4171gG+vtBohYq Z0jbBRqvnPxLndcrsbilDhPYqDNArPDYNE8imP0T/hgo9xpIunCjCYjiQTGhHOROinVS yh9NKnt20MNkqj5x1BfEOsXHamics1ZErAG2Hfp2PVfCaJq5DC1ZmeGtI/rOQXpYYAaE sTwtefr0I8piZbev7jM7EeVC5K/ll4snWcYkV+Oz0g8+7gzUWisnLxDQ3b9cS0TcczMP 4LyJcgZD4t39fPfyjEi2K4QjI8BNnEUFLneKVvqZfXvvsVqUMLUxenKn0Dx1oxtdv1tS OKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NXgQvVjO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w62si9197375pfb.133.2017.11.20.05.53.56; Mon, 20 Nov 2017 05:54:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NXgQvVjO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751234AbdKTNxA (ORCPT + 66 others); Mon, 20 Nov 2017 08:53:00 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:44650 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbdKTNw6 (ORCPT ); Mon, 20 Nov 2017 08:52:58 -0500 Received: by mail-wm0-f65.google.com with SMTP id r68so19088001wmr.3; Mon, 20 Nov 2017 05:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uF3izAjXDB8LVJ3t8upcTnIpjXSHbpGHeZAPgp03Iyo=; b=NXgQvVjOGaStkmnc8e4lYRP9Zrvw+vi8Z/rBZFxwUAPdAYB4Q3SBjTjfID/NE64pwv HP59uJfGgNiGwM0aCM5+jyjx/pfDOJvndOrgvEfN7g8hxDvD1npolhDzdPHACpjn/cUB VyeS0ilZ1CZY4VrVh1xRpdYUOFOROV38KjEig5sRX0gx6mdbL3o8xia3Ru3Zl6GDO4IS oNTl0ChQw1JwK3wv1jm+pqfuW2u0uXhRi2W/B47ReI9Asq9BpEXmDWCvSDGRj7fNlxsc tChnI2Xbn7UjFByHUQ9ROIlwGeAjLoY3nadOSJpQTXQhAfnbz3NG8gytYe9hXxVyG4IW TqGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uF3izAjXDB8LVJ3t8upcTnIpjXSHbpGHeZAPgp03Iyo=; b=CBZR6L6+3fg+RfwIgHnycJF4QAjZpGLHm382h1RzlkyrbhkFhCtrDr4cKaI3sHJGt9 Fyvc2SKPcVDwHp52wKX/UqnhXwWON5x+i0DPGtTSEDsbsdTShhI3EGfkxnaMZs+wJjR4 ByIu2QmQWXhGhz5e87sBtQxrYV6Gwypa1RXlEGVcpvxAqgsk45eVoX2vduBM5kuhot8S kbM0hiwRCKXWSLroUoTiXnO18hK6d/9LDgHyY+KlFvsJi/eRAljPiGvo3OGhHDGykrvf iWHWGtTVFsGkXnOoffLS9e3/uBsXPbzRqhGhhk6eVpVHyodkgYBM2I5p8tAl4sStg0dd Xb3A== X-Gm-Message-State: AJaThX6Cw5k+QocYZrUUmyATx47wbdu1VQ3jMW1ErwKSUZb6a0V3TV7p y/CBnQbb5uUw9nWk2l31mAbF/CnA9jZ6EyYXIe4= X-Received: by 10.80.166.34 with SMTP id d31mr3882460edc.96.1511185976736; Mon, 20 Nov 2017 05:52:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.148.41 with HTTP; Mon, 20 Nov 2017 05:52:55 -0800 (PST) In-Reply-To: <20171102182950.6129-1-romain.perier@gmail.com> References: <20171102182950.6129-1-romain.perier@gmail.com> From: Romain Perier Date: Mon, 20 Nov 2017 14:52:55 +0100 Message-ID: Subject: Re: [PATCH] time: Make NTP optionnal To: John Stultz , Thomas Gleixner , Stephen Boyd Cc: linux-api@vger.kernel.org, Linux Kernel Mailing List , Romain Perier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, No feedback regarding this patch ? Thanks, Romain 2017-11-02 19:29 GMT+01:00 Romain Perier : > On embedded systems with limited space, synchronizing system clock via > NTP might be not needed. > > This commit introduces a new Kconfig entry. When disabled, it compiles > out the adjtimex and clock_adjtimes system calls. The corresponding NTP > accessors are also disabled from timekeeping.c and their declaration are > replaced by no_op static inline functions in time.h > > The bloat-o-meter output is the following: > > add/remove: 1/35 grow/shrink: 2/9 up/down: 170/-3760 (-3590) > function old new delta > tk_set_wall_to_mono.constprop - 164 +164 > tk_xtime_add.constprop 200 204 +4 > timespec_trunc 60 62 +2 > ntp_notify_cmos_timer 2 - -2 > k_itimer_rcu_free 18 16 -2 > timekeeping_forward_now.constprop 256 252 -4 > time_status 4 - -4 > time_state 4 - -4 > time_maxerror 4 - -4 > time_esterror 4 - -4 > time_constant 4 - -4 > time_adjust 4 - -4 > tick_usec 4 - -4 > tick_nsec 4 - -4 > ntp_init 4 - -4 > posix_clock_realtime_adj 6 - -6 > time_reftime 8 - -8 > time_offset 8 - -8 > time_freq 8 - -8 > tick_length_base 8 - -8 > tick_length 8 - -8 > ntp_tick_adj 8 - -8 > ntp_next_leap_sec 8 - -8 > mask_to_bit_num 8 - -8 > mask_to_allowed_status 8 - -8 > ntp_tick_length 12 - -12 > __setup_ntp_tick_adj_setup 12 - -12 > __setup_str_ntp_tick_adj_setup 14 - -14 > timekeeping_resume 614 598 -16 > timekeeping_inject_offset 352 336 -16 > timekeeping_init 400 384 -16 > do_settimeofday64 342 326 -16 > ntp_tick_adj_setup 28 - -28 > timekeeping_update 236 206 -30 > branch_table 32 - -32 > sys_adjtimex 42 - -42 > sys_clock_adjtime 64 - -64 > ntp_clear 72 - -72 > ntp_get_next_leap 76 - -76 > ntp_validate_timex 78 - -78 > tk_set_wall_to_mono 166 - -166 > ntp_update_frequency 180 - -180 > update_wall_time 1846 1590 -256 > do_adjtimex 272 - -272 > second_overflow 476 - -476 > bcj_apply 1100 224 -876 > __do_adjtimex 888 - -888 > > Signed-off-by: Romain Perier > --- > include/linux/timex.h | 14 +++++++++++--- > init/Kconfig | 9 +++++++++ > kernel/compat.c | 2 ++ > kernel/sys_ni.c | 6 ++++++ > kernel/time/Makefile | 6 +++++- > kernel/time/ntp_internal.h | 29 +++++++++++++++++++++++++++++ > kernel/time/posix-timers.c | 13 ++++++++----- > kernel/time/time.c | 4 ++-- > kernel/time/timekeeping.c | 2 ++ > 9 files changed, 74 insertions(+), 11 deletions(-) > > diff --git a/include/linux/timex.h b/include/linux/timex.h > index 39c25dbebfe8..5906b654821a 100644 > --- a/include/linux/timex.h > +++ b/include/linux/timex.h > @@ -151,12 +151,20 @@ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */ > #define NTP_INTERVAL_FREQ (HZ) > #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) > > +#ifdef CONFIG_NTP > extern int do_adjtimex(struct timex *); > extern void hardpps(const struct timespec64 *, const struct timespec64 *); > - > -int read_current_timer(unsigned long *timer_val); > void ntp_notify_cmos_timer(void); > - > +#else > +static inline int do_adjtimex(struct timex *txc) > +{ > + return TIME_OK; > +} > +static inline void hardpps(const struct timespec64 *phase_ts, > + const struct timespec64 *raw_ts) > +{} > +#endif > +int read_current_timer(unsigned long *timer_val); > /* The clock frequency of the i8253/i8254 PIT */ > #define PIT_TICK_RATE 1193182ul > > diff --git a/init/Kconfig b/init/Kconfig > index 3c1faaa2af4a..d4b0b33f7e91 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -1332,6 +1332,15 @@ config EVENTFD > > If unsure, say Y. > > +config NTP > + bool "Enable NTP support" if EXPERT > + default y > + help > + This enables support for synchronizing system clock with NTP > + and its corresponding syscalls adjtimex and clock_adjtimex. > + > + If unsure, say Y. > + > # syscall, maps, verifier > config BPF_SYSCALL > bool "Enable bpf() system call" > diff --git a/kernel/compat.c b/kernel/compat.c > index 772e038d04d9..12945ae5ae94 100644 > --- a/kernel/compat.c > +++ b/kernel/compat.c > @@ -30,6 +30,7 @@ > > #include > > +#ifdef CONFIG_NTP > int compat_get_timex(struct timex *txc, const struct compat_timex __user *utp) > { > struct compat_timex tx32; > @@ -91,6 +92,7 @@ int compat_put_timex(struct compat_timex __user *utp, const struct timex *txc) > return -EFAULT; > return 0; > } > +#endif > > static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv) > { > diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c > index 8acef8576ce9..f854d24b813c 100644 > --- a/kernel/sys_ni.c > +++ b/kernel/sys_ni.c > @@ -258,3 +258,9 @@ cond_syscall(sys_membarrier); > cond_syscall(sys_pkey_mprotect); > cond_syscall(sys_pkey_alloc); > cond_syscall(sys_pkey_free); > +#ifndef CONFIG_NTP > +cond_syscall(sys_adjtimex); > +cond_syscall(sys_clock_adjtime); > +cond_syscall(compat_sys_adjtimex); > +cond_syscall(compat_sys_clock_adjtime); > +#endif > diff --git a/kernel/time/Makefile b/kernel/time/Makefile > index 938dbf33ef49..44bd321e4560 100644 > --- a/kernel/time/Makefile > +++ b/kernel/time/Makefile > @@ -1,7 +1,11 @@ > obj-y += time.o timer.o hrtimer.o > -obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o > +obj-y += timekeeping.o clocksource.o jiffies.o timer_list.o > obj-y += timeconv.o timecounter.o alarmtimer.o > > +ifeq ($(CONFIG_NTP),y) > + obj-y += ntp.o > +endif > + > ifeq ($(CONFIG_POSIX_TIMERS),y) > obj-y += posix-timers.o posix-cpu-timers.o posix-clock.o itimer.o > else > diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h > index d8a7c11fa71a..9d1ebc042968 100644 > --- a/kernel/time/ntp_internal.h > +++ b/kernel/time/ntp_internal.h > @@ -1,6 +1,7 @@ > #ifndef _LINUX_NTP_INTERNAL_H > #define _LINUX_NTP_INTERNAL_H > > +#ifdef CONFIG_NTP > extern void ntp_init(void); > extern void ntp_clear(void); > /* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ > @@ -10,4 +11,32 @@ extern int second_overflow(time64_t secs); > extern int ntp_validate_timex(struct timex *); > extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *); > extern void __hardpps(const struct timespec64 *, const struct timespec64 *); > +#else > +static inline void ntp_init(void) > +{} > +static inline void ntp_clear(void) > +{} > +static inline u64 ntp_tick_length(void) > +{ > + return 0; > +} > +static inline ktime_t ntp_get_next_leap(void) > +{ > + return KTIME_MAX; > +} > +static inline int second_overflow(time64_t secs) > +{ > + return 0; > +} > +static inline int ntp_validate_timex(struct timex *txc) > +{ > + return 0; > +} > +static inline int __do_adjtimex(struct timex *txc, struct timespec64 *ts, > + s32 *time_tai) > +{ > + return TIME_OK; > +} > +#endif > + > #endif /* _LINUX_NTP_INTERNAL_H */ > diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c > index 13d6881f908b..dd31eaddc196 100644 > --- a/kernel/time/posix-timers.c > +++ b/kernel/time/posix-timers.c > @@ -207,12 +207,13 @@ static int posix_clock_realtime_set(const clockid_t which_clock, > return do_sys_settimeofday64(tp, NULL); > } > > +#ifdef CONFIG_NTP > static int posix_clock_realtime_adj(const clockid_t which_clock, > struct timex *t) > { > return do_adjtimex(t); > } > - > +#endif > /* > * Get monotonic time for posix timers > */ > @@ -1065,7 +1066,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, > > return error; > } > - > +#ifdef CONFIG_NTP > SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, > struct timex __user *, utx) > { > @@ -1088,7 +1089,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, > > return err; > } > - > +#endif > SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, > struct timespec __user *, tp) > { > @@ -1141,7 +1142,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock, > > return err; > } > - > +#ifdef CONFIG_NTP > COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock, > struct compat_timex __user *, utp) > { > @@ -1165,7 +1166,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock, > > return err; > } > - > +#endif > COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock, > struct compat_timespec __user *, tp) > { > @@ -1252,7 +1253,9 @@ static const struct k_clock clock_realtime = { > .clock_getres = posix_get_hrtimer_res, > .clock_get = posix_clock_realtime_get, > .clock_set = posix_clock_realtime_set, > +#ifdef CONFIG_NTP > .clock_adj = posix_clock_realtime_adj, > +#endif > .nsleep = common_nsleep, > .timer_create = common_timer_create, > .timer_set = common_timer_set, > diff --git a/kernel/time/time.c b/kernel/time/time.c > index 44a8c1402133..413eca43a09c 100644 > --- a/kernel/time/time.c > +++ b/kernel/time/time.c > @@ -297,7 +297,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, > return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); > } > #endif > - > +#ifdef CONFIG_NTP > SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) > { > struct timex txc; /* Local copy of parameter */ > @@ -333,7 +333,7 @@ COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp) > return ret; > } > #endif > - > +#endif > /* > * Convert jiffies to milliseconds and back. > * > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index 2cafb49aa65e..223fe15daa75 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -2247,6 +2247,7 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real, > return base; > } > > +#ifdef CONFIG_NTP > /** > * do_adjtimex() - Accessor function to NTP __do_adjtimex function > */ > @@ -2317,6 +2318,7 @@ void hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts) > } > EXPORT_SYMBOL(hardpps); > #endif /* CONFIG_NTP_PPS */ > +#endif /* CONFIG_NTP */ > > /** > * xtime_update() - advances the timekeeping infrastructure > -- > 2.14.1 > From 1582980106532233430@xxx Thu Nov 02 18:31:10 +0000 2017 X-GM-THRID: 1582980106532233430 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread