So, previously it was discussed that /dev/mem could be used to mmap a specific hardware memory into a process. Now I need to unit test some userland code that does exactly that, but I need to make sure that the unit test selects a small page that is always free in kernel land. How can I query mem to just grab the location of a free page? (my development setup is different from my other deployment; in deployment these values are hard coded, in development they occur on a qemu emulator)
On Thu, Oct 22, 2015 at 03:13:31PM -0400, Kenneth Adam Miller wrote:
So, previously it was discussed that /dev/mem could be used to mmap a specific hardware memory into a process. Now I need to unit test some userland code that does exactly that, but I need to make sure that the unit test selects a small page that is always free in kernel land. How can I query mem to just grab the location of a free page?
You can't know this from userspace, and even if you could, what would guarantee that 1 second later the kernel wouldn't grab that page to do something else with it? sorry, greg k-h
From: kernelnewbies-bounces@kernelnewbies.org [mailto:kernelnewbies-bounces@kernelnewbies.org] On Behalf Of Kenneth Adam Miller Sent: Thursday, October 22, 2015 12:14 PM To: Kernelnewbies Subject: Query Hard Memory Addresses So, previously it was discussed that /dev/mem could be used to mmap a specific hardware memory into a process. Now I need to unit test some userland code that does exactly that, but I need to make sure that the unit test selects a small page that is always free in kernel land. How can I query mem to just grab the location of a free page? (my development setup is different from my other deployment; in deployment these values are hard coded, in development they occur on a qemu emulator) I suppose it might work to write a kernel module that allocates a page in its init routine and then provides the address to user space via a /proc entry. Jeff Haran
On Thu, Oct 22, 2015 at 3:38 PM, Jeff Haran <Jeff.Haran@citrix.com> wrote:
*From:* kernelnewbies-bounces@kernelnewbies.org [mailto: kernelnewbies-bounces@kernelnewbies.org] *On Behalf Of *Kenneth Adam Miller *Sent:* Thursday, October 22, 2015 12:14 PM *To:* Kernelnewbies *Subject:* Query Hard Memory Addresses
So, previously it was discussed that /dev/mem could be used to mmap a specific hardware memory into a process. Now I need to unit test some userland code that does exactly that, but I need to make sure that the unit test selects a small page that is always free in kernel land. How can I query mem to just grab the location of a free page?
(my development setup is different from my other deployment; in deployment these values are hard coded, in development they occur on a qemu emulator)
I suppose it might work to write a kernel module that allocates a page in its init routine and then provides the address to user space via a /proc entry.
Well see now we're back to where I was before finding out about /dev/mem. In any case, I think I can isolate my userland tests with some shared memory regions at the process level, and then in the production environment serve up a buffer grabbed by mmap.
Jeff Haran
participants (3)
-
Greg KH -
Jeff Haran -
Kenneth Adam Miller