memguard(9) rewrite

Matthew Fleming matthew.fleming at isilon.com
Thu Mar 11 20:46:57 UTC 2010


This patch is against something close to stable/7.

We've found internally that memguard(9) isn't very usable for debugging;
it seems to run out of resources and do other unfriendly things.  This
patch is my first attempt to make it more usable.

The basic changes are:

 - take a lot more KVA if available
 - use vm_map_findspace() directly, with a moving cursor, so that KVA is
   not reused for a while.  When the cursor gets to the end of the map,
   start from the beginning which will re-use KVA.
 - free the physical pages and KVA on a memguard_free().

This requires no extra space for tracking, and no additional locks
beyond
the vm_map lock.  Since on amd64 the KVA reserved is generally more than
physical memory, there's also a limit on the physical memory used to
keep
memguard's page promotions from using up all the system resources.

I hope this is useful.  I'm working on code to add unused pages on each
side of the allocation to detect memory overflow and underflow, and also
some knobs to limit page promotions to larger allocations, and also
randomly guarding any call to malloc(9).

This code is going into our HEAD build today; in a few days I'll have
good system test results to know if I butchered anything.  I don't have
a good test rig for CURRENT, but I can produce a patch against CURRENT
that has no references to Isilon tags or isi_* filenames if desired.  Is
there anyone who wants to take such a patch and commit it?  Should I
send
this to freebsd-arch as well?

Thanks,
matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: memguard.diff
Type: application/octet-stream
Size: 28783 bytes
Desc: memguard.diff
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100311/d31d08f3/memguard.obj


More information about the freebsd-hackers mailing list