All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org
Subject: [GIT pull] timers/urgent for 5.7-rc2
Date: Sun, 19 Apr 2020 13:56:43 -0000	[thread overview]
Message-ID: <158730460342.31269.11473437311616524528.tglx@nanos.tec.linutronix.de> (raw)
In-Reply-To: 158730459860.31269.9496277256253823777.tglx@nanos.tec.linutronix.de

Linus,

please pull the latest timers/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-urgent-2020-04-19

up to:  94d440d61846: proc, time/namespace: Show clock symbolic names in /proc/pid/timens_offsets


An update for the proc interface of time namespaces: Use symbolic names
instead of clockid numbers. The usability nuisance of numbers was noticed
by Michael when polishing the man page.

Thanks,

	tglx

------------------>
Andrei Vagin (1):
      proc, time/namespace: Show clock symbolic names in /proc/pid/timens_offsets


 fs/proc/base.c          | 14 +++++++++++++-
 kernel/time/namespace.c | 15 ++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 6042b646ab27..572898dd16a0 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1573,6 +1573,7 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
 	noffsets = 0;
 	for (pos = kbuf; pos; pos = next_line) {
 		struct proc_timens_offset *off = &offsets[noffsets];
+		char clock[10];
 		int err;
 
 		/* Find the end of line and ensure we don't look past it */
@@ -1584,10 +1585,21 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
 				next_line = NULL;
 		}
 
-		err = sscanf(pos, "%u %lld %lu", &off->clockid,
+		err = sscanf(pos, "%9s %lld %lu", clock,
 				&off->val.tv_sec, &off->val.tv_nsec);
 		if (err != 3 || off->val.tv_nsec >= NSEC_PER_SEC)
 			goto out;
+
+		clock[sizeof(clock) - 1] = 0;
+		if (strcmp(clock, "monotonic") == 0 ||
+		    strcmp(clock, __stringify(CLOCK_MONOTONIC)) == 0)
+			off->clockid = CLOCK_MONOTONIC;
+		else if (strcmp(clock, "boottime") == 0 ||
+			 strcmp(clock, __stringify(CLOCK_BOOTTIME)) == 0)
+			off->clockid = CLOCK_BOOTTIME;
+		else
+			goto out;
+
 		noffsets++;
 		if (noffsets == ARRAY_SIZE(offsets)) {
 			if (next_line)
diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
index 3b30288793fe..53bce347cd50 100644
--- a/kernel/time/namespace.c
+++ b/kernel/time/namespace.c
@@ -338,7 +338,20 @@ static struct user_namespace *timens_owner(struct ns_common *ns)
 
 static void show_offset(struct seq_file *m, int clockid, struct timespec64 *ts)
 {
-	seq_printf(m, "%d %lld %ld\n", clockid, ts->tv_sec, ts->tv_nsec);
+	char *clock;
+
+	switch (clockid) {
+	case CLOCK_BOOTTIME:
+		clock = "boottime";
+		break;
+	case CLOCK_MONOTONIC:
+		clock = "monotonic";
+		break;
+	default:
+		clock = "unknown";
+		break;
+	}
+	seq_printf(m, "%-10s %10lld %9ld\n", clock, ts->tv_sec, ts->tv_nsec);
 }
 
 void proc_timens_show_offsets(struct task_struct *p, struct seq_file *m)


  parent reply	other threads:[~2020-04-19 13:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-19 13:56 [GIT pull] core/urgent for 5.7-rc2 Thomas Gleixner
2020-04-19 13:56 ` [GIT pull] irq/urgent " Thomas Gleixner
2020-04-19 19:20   ` pr-tracker-bot
2020-04-19 13:56 ` [GIT pull] perf/urgent " Thomas Gleixner
2020-04-19 18:56   ` Linus Torvalds
2020-04-19 20:07     ` Josh Poimboeuf
2020-04-20  7:48       ` Ingo Molnar
2020-04-20  8:27         ` Peter Zijlstra
2020-04-22  7:45           ` Ingo Molnar
2020-04-22 11:56             ` Peter Zijlstra
2020-04-20 16:51         ` Linus Torvalds
2020-04-20 17:40           ` Peter Zijlstra
2020-04-20 18:17             ` Josh Poimboeuf
2020-04-20 19:17               ` Peter Zijlstra
2020-04-20 19:21               ` Linus Torvalds
2020-04-20 19:36                 ` Josh Poimboeuf
2020-04-19 19:20   ` pr-tracker-bot
2020-04-19 13:56 ` [GIT pull] sched/urgent " Thomas Gleixner
2020-04-19 19:20   ` pr-tracker-bot
2020-04-19 13:56 ` Thomas Gleixner [this message]
2020-04-19 19:20   ` [GIT pull] timers/urgent " pr-tracker-bot
2020-04-19 13:56 ` [GIT pull] x86/urgent " Thomas Gleixner
2020-04-19 19:20   ` pr-tracker-bot
2020-04-19 19:20 ` [GIT pull] core/urgent " pr-tracker-bot

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=158730460342.31269.11473437311616524528.tglx@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.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.