From: Greg KH <gregkh@suse.de>
To: Alexander Shishkin <virtuoso@slind.org>
Cc: lkml@vger.kernel.org, "Kirill A. Shutemov" <kirill@shutemov.name>,
Thomas Gleixner <tglx@linutronix.de>,
John Stultz <johnstul@us.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jon Hunter <jon-hunter@ti.com>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
David Howells <dhowells@redhat.com>, Avi Kivity <avi@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>, John Kacur <jkacur@redhat.com>,
Chris Friesen <chris.friesen@genband.com>,
Kay Sievers <kay.sievers@vrfy.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [RFCv2] notify userspace about time changes
Date: Wed, 18 Aug 2010 07:26:47 -0700 [thread overview]
Message-ID: <20100818142647.GA32627@suse.de> (raw)
In-Reply-To: <1282139739-23832-1-git-send-email-virtuoso@slind.org>
On Wed, Aug 18, 2010 at 04:55:39PM +0300, Alexander Shishkin wrote:
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-kernel-time-notify
> @@ -0,0 +1,39 @@
> +What: /sys/kernel/time_notify
> +Date: August 2010
> +Contact: Alexander Shishkin <virtuoso@slind.org>
> +Description:
> + This file is used by processes which want to receive
> + notifications about system time changes, to communicate their
> + eventfd descriptor number along with the type of event they
> + wish to subscribe to and filtering options. Every time one of
> + the processes in the system succeeds in doing a settimeofday()
> + or adjtimex(), this eventfd will be signalled.
> + This file is not readable. Upon write, this is the format
> + accepted by the kernel:
> + <fd> <want-others> <want-own> <want-set> <want-adj>
> + where
> + - <fd> is the file descriptor of the eventfd that the process
> + will listen to for time change events;
> + - <want-others> is 0 or 1 depending on whether the process wants
> + to be notified about other processes' time changes;
> + - <want-own> -- likewise, for process' own time changes;
> + - <want-set> is 0 or 1 depending on whether the process wants
> + to be notified about settimeofday()/stime() system calls;
> + - <want-adj> -- likewise, for adjtimex() system call.
> +
> + A simple snippet of C code illustrates the usage pattern:
> +
> + efd = eventfd(0, 0);
> + fd = open("/sys/kernel/time_notify", O_WRONLY);
> + fdprintf(fd, "%d 1 0 1 1", efd);
> + close(fd);
> +
> + fds[0].fd = efd;
> + fds[0].events = POLLIN;
> + while (poll(fds, 1, -1) > 0) {
> + uint64_t n;
> +
> + read(efd, &n, 8);
> + printf("time has been modified %d time(s)\n", n);
> + }
While this isn't the "nicest" sysfs file ever, it's not all that bad.
> +/* time change events */
> +#define TIME_EVENT_SET 0
> +#define TIME_EVENT_ADJ 1
> +
> +#ifdef CONFIG_TIME_NOTIFY
> +void time_notify_all(int type);
> +#else
> +#define time_notify_all(x) do {} while (0)
static inline please so we do a typecheck.
> +#endif
> +
> #endif /* __KERNEL__ */
>
> #define NFDBITS __NFDBITS
> diff --git a/init/Kconfig b/init/Kconfig
> index 2de5b1c..aa4d890 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -980,6 +980,14 @@ config PERF_USE_VMALLOC
> help
> See tools/perf/design.txt for details
>
> +config TIME_NOTIFY
> + bool
> + default y
Really? You obviously haven't added new Kconfig options to the kernel
in the past and been yelled at by Linus :)
> + evt->eventfd = eventfd_ctx_fileget(file);
> + if (!evt->eventfd) {
> + ret = PTR_ERR(evt->eventfd);
Are you sure this is correct?
thanks,
greg k-h
next prev parent reply other threads:[~2010-08-18 14:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 13:55 [PATCH] [RFCv2] notify userspace about time changes Alexander Shishkin
2010-08-18 14:26 ` Greg KH [this message]
2010-08-18 22:57 ` Andrew Morton
2010-08-18 23:43 ` H. Peter Anvin
2010-08-18 23:53 ` Andrew Morton
2010-08-19 4:09 ` Greg KH
2010-08-19 4:39 ` Andrew Morton
2010-08-19 8:21 ` Alexander Shishkin
2010-08-19 8:36 ` Kirill A. Shutemov
2010-08-19 8:39 ` Kay Sievers
2010-08-19 15:31 ` Greg KH
2010-08-20 8:37 ` Kirill A. Shutemov
2010-08-20 15:33 ` Greg KH
2010-08-20 15:38 ` Alexander Shishkin
2010-08-19 9:50 ` Peter Zijlstra
2010-08-19 10:53 ` Kay Sievers
2010-08-19 11:14 ` Alexander Shishkin
2010-08-18 23:50 ` Chris Friesen
2010-08-18 23:09 ` john stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100818142647.GA32627@suse.de \
--to=gregkh@suse.de \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=chris.friesen@genband.com \
--cc=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=jkacur@redhat.com \
--cc=johnstul@us.ibm.com \
--cc=jon-hunter@ti.com \
--cc=kay.sievers@vrfy.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=virtuoso@slind.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.