tech-kern archive

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

Re: Another kvm user can go away?



Paul Goyette wrote:

> Any suggestions on how to ensure proper alignment?  There doesn't seem 
> to be any way to kmem_allocate() what alignment is needed...  :)  It 
> seems to currently always provide 64-bit (8-byte) alignment, but the man 
> page makes no guarantees.
> 
> I guess I could allocate an extra 8 bytes, and then manipulate the 
> returned address... But that just "feels wrong".  :)

I meant alignment within the structures.  Maybe "packing" might be
a better word.  This helps for example with mixed 32-bit and 64-bit
emulations.  If you look at your original struct sysctl_history_event:

	struct sysctl_history_event {
		struct timeval	she_tv;
		uint64_t	she_callnumber;
		uint64_t	she_values[4];

The timeval is a structure with a 64-bit int for seconds and and
a 32-bit int for microseconds.  With the following uint64_t some
architectures might pad out she_callnumber in the structure so that it's
on a 64-bit boundary while others will by happy with a 32-bit alignment
and not use any padding.

In short, just make sure everything in the struct packs nicely. :)

Cheers,
Simon.


Home | Main Index | Thread Index | Old Index