public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntp, add debugfs entries for time_status and time_state
@ 2012-10-04 13:48 Prarit Bhargava
  2012-10-09  1:47 ` John Stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Prarit Bhargava @ 2012-10-04 13:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: Prarit Bhargava, John Stultz, Thomas Gleixner

Add debugfs entries for ntp time_status and time_state.  These are useful
for debugging ntp issues.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/ntp.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 24174b4..e1ba393 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -15,6 +15,7 @@
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/debugfs.h>
 
 #include "tick-internal.h"
 
@@ -965,3 +966,42 @@ void __init ntp_init(void)
 {
 	ntp_clear();
 }
+
+static int time_status_get(void *data, u64 *val)
+{
+	*val = time_status;
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(time_status_fops, time_status_get, NULL, "0x%0llx\n");
+
+static int time_state_get(void *data, u64 *val)
+{
+	*val = time_state;
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(time_state_fops, time_state_get, NULL, "0x%llx\n");
+
+static int __init ntp_debugfs_init(void)
+{
+	struct dentry *ntp_dentry, *time_status_dentry, *time_state_dentry;
+
+	ntp_dentry = debugfs_create_dir("ntp", NULL);
+	if (!ntp_dentry)
+		return -ENOMEM;
+
+	time_status_dentry = debugfs_create_file("time_status", 0444,
+						 ntp_dentry, NULL,
+						 &time_status_fops);
+	if (!time_status_dentry)
+		return -ENOMEM;
+
+	time_state_dentry = debugfs_create_file("time_state", 0444,
+						ntp_dentry, NULL,
+						&time_state_fops);
+	if (!time_state_dentry)
+		return -ENOMEM;
+
+	return 0;
+}
+/* debugfs init is core_initcall */
+postcore_initcall(ntp_debugfs_init);
-- 
1.7.9.3


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

* Re: [PATCH] ntp, add debugfs entries for time_status and time_state
  2012-10-04 13:48 [PATCH] ntp, add debugfs entries for time_status and time_state Prarit Bhargava
@ 2012-10-09  1:47 ` John Stultz
  2012-10-09 11:05   ` Prarit Bhargava
  0 siblings, 1 reply; 3+ messages in thread
From: John Stultz @ 2012-10-09  1:47 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-kernel, Thomas Gleixner

On 10/04/2012 06:48 AM, Prarit Bhargava wrote:
> Add debugfs entries for ntp time_status and time_state.  These are useful
> for debugging ntp issues.
Aren't these easily fetched from adjtimex()?  How does having them in 
debugfs help?

thanks
-john


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

* Re: [PATCH] ntp, add debugfs entries for time_status and time_state
  2012-10-09  1:47 ` John Stultz
@ 2012-10-09 11:05   ` Prarit Bhargava
  0 siblings, 0 replies; 3+ messages in thread
From: Prarit Bhargava @ 2012-10-09 11:05 UTC (permalink / raw)
  To: John Stultz; +Cc: linux-kernel, Thomas Gleixner



On 10/08/2012 09:47 PM, John Stultz wrote:
> On 10/04/2012 06:48 AM, Prarit Bhargava wrote:
>> Add debugfs entries for ntp time_status and time_state.  These are useful
>> for debugging ntp issues.
> Aren't these easily fetched from adjtimex()?  How does having them in debugfs help?
> 

They are, however, there have been circumstances in the past when I've been
monitoring things from kernel-side that I've found it useful to have them in
debugfs.

P.

> thanks
> -john
> 

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

end of thread, other threads:[~2012-10-09 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04 13:48 [PATCH] ntp, add debugfs entries for time_status and time_state Prarit Bhargava
2012-10-09  1:47 ` John Stultz
2012-10-09 11:05   ` Prarit Bhargava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox