All of lore.kernel.org
 help / color / mirror / Atom feed
* Publishing mips_hpt_frequency in /proc/cpuinfo
@ 2011-01-28  4:59 ` Earl Chew
  0 siblings, 0 replies; 5+ messages in thread
From: Earl Chew @ 2011-01-28  4:59 UTC (permalink / raw)
  To: linux-mips

The CPU frequency is known to the Linux kernel. For example:

> CPU revision is: 00019374 (MIPS 24Kc)
> Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
> ...
> Calibrating delay loop... 452.19 BogoMIPS (lpj=2260992)

Unfortunately that information is not available from userspace:

> cpu model               : MIPS 24Kc V7.4
> BogoMIPS                : 452.19

This makes it difficult to use CPU timers (rdhwr) from user space
applications.


Is there any reason not to publish mips_hpt_frequency in /proc/cpuinfo ?


Earl


--- proc.c      2011-01-17 14:05:16.397444347 -0800
+++ /tmp/proc.c 2011-01-27 20:56:18.807454356 -0800
@@ -43,6 +43,9 @@
        seq_printf(m, "BogoMIPS\t\t: %u.%02u\n",
                      cpu_data[n].udelay_val / (500000/HZ),
                      (cpu_data[n].udelay_val / (5000/HZ)) % 100);
+       seq_printf(m, "timer frequency\t: %u.%03u\n",
+                     mips_hpt_frequency / 1000000,
+                     mips_hpt_frequency % 1000000 / 1000);
        seq_printf(m, "wait instruction\t: %s\n", cpu_wait ? "yes" : "no");
        seq_printf(m, "microsecond timers\t: %s\n",
                      cpu_has_counter ? "yes" : "no");

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

* Publishing mips_hpt_frequency in /proc/cpuinfo
@ 2011-01-28  4:59 ` Earl Chew
  0 siblings, 0 replies; 5+ messages in thread
From: Earl Chew @ 2011-01-28  4:59 UTC (permalink / raw)
  To: linux-mips

The CPU frequency is known to the Linux kernel. For example:

> CPU revision is: 00019374 (MIPS 24Kc)
> Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
> ...
> Calibrating delay loop... 452.19 BogoMIPS (lpj=2260992)

Unfortunately that information is not available from userspace:

> cpu model               : MIPS 24Kc V7.4
> BogoMIPS                : 452.19

This makes it difficult to use CPU timers (rdhwr) from user space
applications.


Is there any reason not to publish mips_hpt_frequency in /proc/cpuinfo ?


Earl


--- proc.c      2011-01-17 14:05:16.397444347 -0800
+++ /tmp/proc.c 2011-01-27 20:56:18.807454356 -0800
@@ -43,6 +43,9 @@
        seq_printf(m, "BogoMIPS\t\t: %u.%02u\n",
                      cpu_data[n].udelay_val / (500000/HZ),
                      (cpu_data[n].udelay_val / (5000/HZ)) % 100);
+       seq_printf(m, "timer frequency\t: %u.%03u\n",
+                     mips_hpt_frequency / 1000000,
+                     mips_hpt_frequency % 1000000 / 1000);
        seq_printf(m, "wait instruction\t: %s\n", cpu_wait ? "yes" : "no");
        seq_printf(m, "microsecond timers\t: %s\n",
                      cpu_has_counter ? "yes" : "no");

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

* Re: Publishing mips_hpt_frequency in /proc/cpuinfo
  2011-01-28  4:59 ` Earl Chew
  (?)
@ 2011-01-28 10:57 ` Ralf Baechle
  2011-01-28 12:28   ` Thomas Gleixner
  -1 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2011-01-28 10:57 UTC (permalink / raw)
  To: Earl Chew; +Cc: linux-mips, Thomas Gleixner

On Thu, Jan 27, 2011 at 08:59:55PM -0800, Earl Chew wrote:

> The CPU frequency is known to the Linux kernel. For example:
> 
> > CPU revision is: 00019374 (MIPS 24Kc)
> > Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
> > ...
> > Calibrating delay loop... 452.19 BogoMIPS (lpj=2260992)
> 
> Unfortunately that information is not available from userspace:
> 
> > cpu model               : MIPS 24Kc V7.4
> > BogoMIPS                : 452.19
> 
> This makes it difficult to use CPU timers (rdhwr) from user space
> applications.
> 
> 
> Is there any reason not to publish mips_hpt_frequency in /proc/cpuinfo ?

The CPU clock frequency may change at any time due to clockscaling  A
process might be rescheduled to another CPU running at a different clock
rate.  A suspended process might miss counter wraparounds.

This right approach is to handle this in a virtual syscall, something like
vsys_clock_gettime().

  Ralf

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

* Re: Publishing mips_hpt_frequency in /proc/cpuinfo
  2011-01-28 10:57 ` Ralf Baechle
@ 2011-01-28 12:28   ` Thomas Gleixner
  2011-01-28 15:29     ` Earl Chew
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2011-01-28 12:28 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Earl Chew, linux-mips

On Fri, 28 Jan 2011, Ralf Baechle wrote:
> On Thu, Jan 27, 2011 at 08:59:55PM -0800, Earl Chew wrote:
> 
> > The CPU frequency is known to the Linux kernel. For example:
> > 
> > > CPU revision is: 00019374 (MIPS 24Kc)
> > > Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
> > > ...
> > > Calibrating delay loop... 452.19 BogoMIPS (lpj=2260992)
> > 
> > Unfortunately that information is not available from userspace:
> > 
> > > cpu model               : MIPS 24Kc V7.4
> > > BogoMIPS                : 452.19
> > 
> > This makes it difficult to use CPU timers (rdhwr) from user space
> > applications.
> > 
> > 
> > Is there any reason not to publish mips_hpt_frequency in /proc/cpuinfo ?
> 
> The CPU clock frequency may change at any time due to clockscaling  A
> process might be rescheduled to another CPU running at a different clock
> rate.  A suspended process might miss counter wraparounds.
> 
> This right approach is to handle this in a virtual syscall, something like
> vsys_clock_gettime().

Right. We had this discussion on x86 over and over and using a
vsyscall is the correct approach. That's also a huge win in general if
you can avoid going into the kernel to read the time. gettimeofday()
and clock_gettime() belong to the most frequently called syscalls on
any Linux system.

Thanks,

	tglx

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

* Re: Publishing mips_hpt_frequency in /proc/cpuinfo
  2011-01-28 12:28   ` Thomas Gleixner
@ 2011-01-28 15:29     ` Earl Chew
  0 siblings, 0 replies; 5+ messages in thread
From: Earl Chew @ 2011-01-28 15:29 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Ralf Baechle, linux-mips@linux-mips.org

Ralf Baechle wrote:
> The CPU clock frequency may change at any time due to clockscaling  A
> process might be rescheduled to another CPU running at a different clock
> rate.  A suspended process might miss counter wraparounds.
>
> This right approach is to handle this in a virtual syscall, something like
> vsys_clock_gettime().

Thomas Gleixner wrote:
> Right. We had this discussion on x86 over and over and using a
> vsyscall is the correct approach. That's also a huge win in general if
> you can avoid going into the kernel to read the time. gettimeofday()
> and clock_gettime() belong to the most frequently called syscalls on
> any Linux system.

Ralf, Thomas,

Yes, I have seen that code on x86, and I completely agree with you both. The scenarios
that Ralf described pertinent, but for my currently application the win of
not going to the kernel that Thomas described is much more important.

I would very much like to go down the vsyscall route, but I can't see any
of that infrastructure in the arch/mips subdirectories.

It seems to me that that work has not been started for MIPS.  Am I mistaken ?

[ I'm trying to figure out where I should start. ]


Looking in /proc/cpuinfo for x86 I see:

> processor       : 0
> vendor_id       : GenuineIntel
> cpu family      : 6
> model           : 28
> model name      : Intel(R) Atom(TM) CPU D510   @ 1.66GHz
> stepping        : 10
> cpu MHz         : 1666.670

This makes available the clock frequency of the CPU. To get similar information
for MIPS, I need to rummage around inside dmesg:

> CPU revision is: 00019374 (MIPS 24Kc)
> Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz

Would you be averse to publishing additional CPU information (include cpu MHz)
in /proc/cpuinfo for MIPS ?


Earl

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

end of thread, other threads:[~2011-01-28 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-28  4:59 Publishing mips_hpt_frequency in /proc/cpuinfo Earl Chew
2011-01-28  4:59 ` Earl Chew
2011-01-28 10:57 ` Ralf Baechle
2011-01-28 12:28   ` Thomas Gleixner
2011-01-28 15:29     ` Earl Chew

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.