* [PATCH] uapi, posix-timers: provide clockid-related macros and functions to UAPI
@ 2019-09-20 16:20 Eugene Syromiatnikov
2019-09-22 7:56 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Eugene Syromiatnikov @ 2019-09-20 16:20 UTC (permalink / raw)
To: John Stultz, Thomas Gleixner, Stephen Boyd
Cc: Frederic Weisbecker, Sebastian Andrzej Siewior,
Eric W. Biederman, linux-kernel
As of now, there is no interface exposed for converting pid/fd into
clockid and vice versa; linuxptp, for example, has been carrying these
definitions in missing.h header for quite some time[1].
[1] https://sourceforge.net/p/linuxptp/code/ci/af380e86/tree/missing.h
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
include/linux/posix-timers.h | 47 +-------------------------------------------
include/uapi/linux/time.h | 47 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 46 deletions(-)
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 3d10c84..ddc7e6e6 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -4,58 +4,13 @@
#include <linux/spinlock.h>
#include <linux/list.h>
+#include <linux/time.h>
#include <linux/alarmtimer.h>
#include <linux/timerqueue.h>
struct kernel_siginfo;
struct task_struct;
-/*
- * Bit fields within a clockid:
- *
- * The most significant 29 bits hold either a pid or a file descriptor.
- *
- * Bit 2 indicates whether a cpu clock refers to a thread or a process.
- *
- * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
- *
- * A clockid is invalid if bits 2, 1, and 0 are all set.
- */
-#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
-#define CPUCLOCK_PERTHREAD(clock) \
- (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
-
-#define CPUCLOCK_PERTHREAD_MASK 4
-#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
-#define CPUCLOCK_CLOCK_MASK 3
-#define CPUCLOCK_PROF 0
-#define CPUCLOCK_VIRT 1
-#define CPUCLOCK_SCHED 2
-#define CPUCLOCK_MAX 3
-#define CLOCKFD CPUCLOCK_MAX
-#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
-
-static inline clockid_t make_process_cpuclock(const unsigned int pid,
- const clockid_t clock)
-{
- return ((~pid) << 3) | clock;
-}
-static inline clockid_t make_thread_cpuclock(const unsigned int tid,
- const clockid_t clock)
-{
- return make_process_cpuclock(tid, clock | CPUCLOCK_PERTHREAD_MASK);
-}
-
-static inline clockid_t fd_to_clockid(const int fd)
-{
- return make_process_cpuclock((unsigned int) fd, CLOCKFD);
-}
-
-static inline int clockid_to_fd(const clockid_t clk)
-{
- return ~(clk >> 3);
-}
-
#ifdef CONFIG_POSIX_TIMERS
/**
diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h
index 958932e..41a004c 100644
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -70,4 +70,51 @@ struct itimerval {
*/
#define TIMER_ABSTIME 0x01
+/*
+ * Bit fields within a clockid:
+ *
+ * The most significant 29 bits hold either a pid or a file descriptor.
+ *
+ * Bit 2 indicates whether a cpu clock refers to a thread or a process.
+ *
+ * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
+ *
+ * A clockid is invalid if bits 2, 1, and 0 are all set.
+ */
+#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
+#define CPUCLOCK_PERTHREAD(clock) \
+ (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
+
+#define CPUCLOCK_PERTHREAD_MASK 4
+#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
+#define CPUCLOCK_CLOCK_MASK 3
+#define CPUCLOCK_PROF 0
+#define CPUCLOCK_VIRT 1
+#define CPUCLOCK_SCHED 2
+#define CPUCLOCK_MAX 3
+#define CLOCKFD CPUCLOCK_MAX
+#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
+
+static inline clockid_t make_process_cpuclock(const unsigned int pid,
+ const clockid_t clock)
+{
+ return ((~pid) << 3) | clock;
+}
+static inline clockid_t make_thread_cpuclock(const unsigned int tid,
+ const clockid_t clock)
+{
+ return make_process_cpuclock(tid, clock | CPUCLOCK_PERTHREAD_MASK);
+}
+
+static inline clockid_t fd_to_clockid(const int fd)
+{
+ return make_process_cpuclock((unsigned int) fd, CLOCKFD);
+}
+
+static inline int clockid_to_fd(const clockid_t clk)
+{
+ return ~(clk >> 3);
+}
+
+
#endif /* _UAPI_LINUX_TIME_H */
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] uapi, posix-timers: provide clockid-related macros and functions to UAPI
2019-09-20 16:20 [PATCH] uapi, posix-timers: provide clockid-related macros and functions to UAPI Eugene Syromiatnikov
@ 2019-09-22 7:56 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2019-09-22 7:56 UTC (permalink / raw)
To: Eugene Syromiatnikov
Cc: kbuild-all, John Stultz, Thomas Gleixner, Stephen Boyd,
Frederic Weisbecker, Sebastian Andrzej Siewior,
Eric W. Biederman, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2165 bytes --]
Hi Eugene,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.3 next-20190920]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Eugene-Syromiatnikov/uapi-posix-timers-provide-clockid-related-macros-and-functions-to-UAPI/20190921-051356
config: i386-randconfig-a003-201937 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from ./usr/include/linux/timex.h:56:0,
from <command-line>:32:
>> ./usr/include/linux/time.h:98:19: error: unknown type name 'clockid_t'
static __inline__ clockid_t make_process_cpuclock(const unsigned int pid,
^~~~~~~~~
./usr/include/linux/time.h:99:9: error: unknown type name 'clockid_t'
const clockid_t clock)
^~~~~~~~~
./usr/include/linux/time.h:103:19: error: unknown type name 'clockid_t'
static __inline__ clockid_t make_thread_cpuclock(const unsigned int tid,
^~~~~~~~~
./usr/include/linux/time.h:104:9: error: unknown type name 'clockid_t'
const clockid_t clock)
^~~~~~~~~
./usr/include/linux/time.h:109:19: error: unknown type name 'clockid_t'
static __inline__ clockid_t fd_to_clockid(const int fd)
^~~~~~~~~
./usr/include/linux/time.h:114:43: error: unknown type name 'clockid_t'
static __inline__ int clockid_to_fd(const clockid_t clk)
^~~~~~~~~
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30645 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-22 7:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 16:20 [PATCH] uapi, posix-timers: provide clockid-related macros and functions to UAPI Eugene Syromiatnikov
2019-09-22 7:56 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).