tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Another kvm user can go away?



Hi Paul,

Paul Goyette wrote:

> I have managed to provide access to all of the kernel history data via 
> sysctl, and I've come up with a modified version of vmstat(1) that can 
> read the data from sysctl rather than having to use kvm.

Great to see more progress on sysctls instead of kvm(3)!

> Diffs for sys/sys/kernhist.h and sys/kern/kern_history.c can be found at 
> www.netbsd.org/~pgoyette/my_vmstat/kernhist.diffs  In the same directory 
> you can find a source file my_vmstat.c (and its associated Makefile).
> 
> Please review and comment (preferably constructively), and let me know 
> what more needs to be done before it gets committed.

One thing to be careful of is 64-bit safe alignment of the sysctl
structures.  The first structure is ok:

+/* info for a single kernhist */
+struct sysctl_history_list_entry {
+       uint32_t        shle_nameoffset;
+       uint32_t        shle_numentries;
+       uint32_t        shle_nextfree;
+       uint32_t        shle_filler;
+};

But for the second structure, I don't think the "struct timeval" is
64-bit alignment safe (unless something has changed in the last few
years):

+/* info for a single history event */
+struct sysctl_history_event {
+       struct timeval  she_tv;
+       uint64_t        she_callnumber;
+       uint64_t        she_values[4];
+       uint32_t        she_cpunum;
+       uint32_t        she_fmtoffset;
+       uint32_t        she_funcoffset;
+       uint32_t        she_filler;
+};

Some of the original sysctl stuff used uint32_t for the seconds part of
a timeval, but I suspect you'd want to use a uint64_t nowadays.  You
might end up with something like:

struct sysctl_history_event {
	uint64_t	she_tv_sec;
	uint32_t	she_tv_usec;
	uint32_t	she_pad1;
	uint64_t	she_callnumber;
	uint64_t	she_values[4];
	...

Cheers,
Simon.


Home | Main Index | Thread Index | Old Index