[Gllug] Writing my own system call

Richard W.M. Jones rich at annexia.org
Fri Jun 17 11:17:09 UTC 2011


On Wed, Jun 15, 2011 at 11:49:26AM +0100, Adrian McMenamin wrote:
> I need to know the physical address of memory allocated from the heap in
> user space (this is for research, not because I am suggesting this is a
> sensible thing for anyone in the real world to be able to do) - I am
> researching/confirming phases of memory locality in the kernel.
> 
> As far as I can see the only way I will be able to do this is to write my
> own system call handle the return from __pa().
> 
> But, just to check - anyone know of a simpler way?

AFAIK this is the only way.

However instead of writing a full-blown system call, I would be
tempted to just hack this.  Add an ioctl to some common device,
eg. for files here:

http://lxr.linux.no/#linux+v2.6.38/fs/ioctl.c#L539

argp could point to a pair of addresses: first would be the heap
pointer you want to look up, and second would be the place to return
the physical address (note that physical addresses can be larger than
pointers, esp. on 32 bit).

Be interesting if you could follow up with how this works out.

Rich.

-- 
Richard Jones
Red Hat
--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list