public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: How to document dimension units for virtual files?
@ 2006-11-08 16:54 Michael Holzheu
  2006-11-08 17:04 ` Randy Dunlap
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Michael Holzheu @ 2006-11-08 16:54 UTC (permalink / raw)
  To: pavel; +Cc: Ingo Oeser, linux-kernel, mschwid2

Pavel, Ingo,

Pavel Machek <pavel@ucw.cz> wrote on 10/28/2006 07:40:48 PM:
> Hi!
> 
> > > > 2. Encode dimension unit into filename (e.g. onlinetime_ms or
> > memory_kb)
> > >
> > > This is the recommended one.
> > > - simple to implement and understand on both sides
> > >

[snip]

> > I also think that this is the best solution. It would be nice to have
> > that documented somewhere. Maybe in the Documentation directory
> > something like:
> > 
> > Howto export data in virtual files
> > ==================================
> > 
> > If you want to export data to userspace via virtual filesystems
> > like procfs, sysfs, debugfs etc., the following rules are recommended:
> 
> ...yes please... such patch would be nice.

What about the following ...

Michael

---

 Documentation/filesystems/00-INDEX   |    2 +
 Documentation/filesystems/ExportData |   47 +++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff -Naur linux-2.6.18/Documentation/filesystems/00-INDEX linux-2.6.18-exp-data-doc/Documentation/filesystems/00-INDEX
--- linux-2.6.18/Documentation/filesystems/00-INDEX	2006-09-20 10:50:34.000000000 +0200
+++ linux-2.6.18-exp-data-doc/Documentation/filesystems/00-INDEX	2006-11-08 17:45:31.000000000 +0100
@@ -1,5 +1,7 @@
 00-INDEX
 	- this file (info on some of the filesystems supported by linux).
+ExportData
+	- recommendation of how to export data via virtual File Systems.
 Exporting
 	- explanation of how to make filesystems exportable.
 Locking
diff -Naur linux-2.6.18/Documentation/filesystems/ExportData linux-2.6.18-exp-data-doc/Documentation/filesystems/ExportData
--- linux-2.6.18/Documentation/filesystems/ExportData	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.18-exp-data-doc/Documentation/filesystems/ExportData	2006-11-08 17:44:59.000000000 +0100
@@ -0,0 +1,47 @@
+
+Export data via virtual File Systems
+====================================
+
+If you want to export data to userspace via virtual filesystems
+like procfs, sysfs, debugfs etc., the following rules are recommended:
+
+- Export only one value in one virtual file.
+- Data format should be as simple as possible.
+- Use ASCII formated strings, no binary data if possible.
+- If data has dimension units, encode that in the filename.
+
+Please use the following prefixes, when dimension units are required (According
+to IEC 60027-2 and SI/International System of Units):
+
+Storage size (SI prefixes)
+--------------------------
+* kB: kilobyte (10^3 Byte)
+* MB: megabyte (10^6 Byte)
+* GB: gigabyte (10^9 Byte)
+* TB: terabyte (10^12 Byte)
+* PB: petabyte (10^15 Byte)
+
+Storage size (Binary prefixes)
+------------------------------
+* KiB: kibibyte (2^10 Byte)
+* MiB: mebibyte (2^20 Byte)
+* GiB: gibibyte (2^30 Byte)
+* TiB: tebibyte (2^40 Byte)
+* PiB: pebibyte (2^50 Byte)
+
+Time (SI pefixes)
+-----------------
+* s:  Second
+* ms: Millisecond (10^-3 Seconds)
+* us: Microsecond (10^-6 Seconds)
+* ns: Nanosecond (10^-9 Seconds)
+
+Examples:
+---------
+> ls /sys/kernel/debug/sysinfo
+free_mem_KiB
+online_time_ms
+cpu_time_us
+
+> cat /sys/kernel/debug/free_mem_KiB
+147536

^ permalink raw reply	[flat|nested] 23+ messages in thread
* How to document dimension units for virtual files?
@ 2006-10-23 12:32 Michael Holzheu
  2006-10-23 19:03 ` Ingo Oeser
  0 siblings, 1 reply; 23+ messages in thread
From: Michael Holzheu @ 2006-10-23 12:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: schwidefsky

For the s390 hypervisor filesystem (s390_hypfs) we export performance
and status information to user space. In order to make parsing for
programs as easy as possilbe, we export exactly one value in one file
without adding the dimension unit to the output string.

For example:

cat /hypfs/cpus/onlinetime
476362365

cat /hypfs/memory
900620

As far as I know that is the recommended way of exporting such data
to user space, right?

The question is how to provide the dimension unit information to
the user.

I see three possibilites:

1. Write dimension unit into the output string (e.g. "476362365 kB"),
which makes parsing a bit more complicated.

2. Encode dimension unit into filename (e.g. onlinetime_ms or memory_kb)

3. Document dimension unit somewhere. In that case we need some central
place to provide such information. E.g. in the Documentation directory of
the linux kernel.

So, what is the recommended way?

Thanks!

Michael

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

end of thread, other threads:[~2006-11-14  8:48 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-08 16:54 How to document dimension units for virtual files? Michael Holzheu
2006-11-08 17:04 ` Randy Dunlap
2006-11-08 18:27   ` Michael Holzheu
2006-11-10  6:53     ` Greg KH
2006-11-10 10:03       ` Michael Holzheu
2006-11-13 17:16         ` Greg KH
2006-11-13 12:18       ` Pavel Machek
2006-11-13 17:46         ` Henrique de Moraes Holschuh
2006-11-14  8:50           ` Michael Holzheu
2006-11-08 17:09 ` Jörn Engel
2006-11-08 18:32   ` Michael Holzheu
2006-11-08 18:01 ` Henrique de Moraes Holschuh
2006-11-08 18:37   ` Michael Holzheu
2006-11-08 19:59     ` Henrique de Moraes Holschuh
2006-11-09 23:15 ` Pavel Machek
2006-11-10 13:18   ` Kyle Moffett
2006-11-10 15:41     ` Sanjoy Mahajan
2006-11-13  4:33       ` Kyle Moffett
  -- strict thread matches above, loose matches on Subject: below --
2006-10-23 12:32 Michael Holzheu
2006-10-23 19:03 ` Ingo Oeser
2006-10-24 14:15   ` Michael Holzheu
2006-10-24 20:13     ` Arnd Bergmann
2006-10-28 18:40     ` Pavel Machek

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