* mlock into kernel module
@ 2006-05-12 15:22 sej.kernel
2006-05-12 15:52 ` linux-os (Dick Johnson)
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: sej.kernel @ 2006-05-12 15:22 UTC (permalink / raw)
To: linux-kernel
Hello,
I need to use mlock and munlock function into a kernel module. How so
I call this system call from my module ?
I need to do this because I must use mlock in my software, but I can't
use root or suser to start it. So mlock alwaays fail.
Regards,
sej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mlock into kernel module
2006-05-12 15:22 sej.kernel
@ 2006-05-12 15:52 ` linux-os (Dick Johnson)
2006-05-12 18:44 ` Arjan van de Ven
2006-05-12 19:08 ` Chris Wright
2 siblings, 0 replies; 6+ messages in thread
From: linux-os (Dick Johnson) @ 2006-05-12 15:52 UTC (permalink / raw)
To: sej.kernel; +Cc: linux-kernel
On Fri, 12 May 2006, sej.kernel wrote:
> Hello,
> I need to use mlock and munlock function into a kernel module. How so
> I call this system call from my module ?
> I need to do this because I must use mlock in my software, but I can't
> use root or suser to start it. So mlock alwaays fail.
> Regards,
> sej
You don't call mlock from a module. You can lock down pages inside
your module by using non-paged RAM. This can be accessed from user-space
by implimenting mmap() in your module so that the user-code can
memory-map it. That way, the page(s) you have allocated in the
kernel are never swapped.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.4 on an i686 machine (5592.89 BogoMips).
New book: http://www.lymanschool.com
_
\x1a\x04
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mlock into kernel module
2006-05-12 15:22 sej.kernel
2006-05-12 15:52 ` linux-os (Dick Johnson)
@ 2006-05-12 18:44 ` Arjan van de Ven
2006-05-12 19:08 ` Chris Wright
2 siblings, 0 replies; 6+ messages in thread
From: Arjan van de Ven @ 2006-05-12 18:44 UTC (permalink / raw)
To: sej.kernel; +Cc: linux-kernel
On Fri, 2006-05-12 at 17:22 +0200, sej.kernel wrote:
> Hello,
> I need to use mlock and munlock function into a kernel module. How so
> I call this system call from my module ?
no it's a bug if you need to do that
> I need to do this because I must use mlock in my software, but I can't
> use root or suser to start it. So mlock alwaays fail.
that's an rlimit thing, just fix the rlimit on your system.
Also if you want to do this for pinning hardware at a physical address
you have a really wrong design (mlock is the wrong api) which also
includes a security hole btw
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mlock into kernel module
2006-05-12 15:22 sej.kernel
2006-05-12 15:52 ` linux-os (Dick Johnson)
2006-05-12 18:44 ` Arjan van de Ven
@ 2006-05-12 19:08 ` Chris Wright
2 siblings, 0 replies; 6+ messages in thread
From: Chris Wright @ 2006-05-12 19:08 UTC (permalink / raw)
To: sej.kernel; +Cc: linux-kernel
* sej.kernel (sej.kernel@gmail.com) wrote:
> I need to use mlock and munlock function into a kernel module. How so
> I call this system call from my module ?
You shouldn't.
> I need to do this because I must use mlock in my software, but I can't
> use root or suser to start it. So mlock alwaays fail.
You should be using rlimits for this.
thanks,
-chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mlock into kernel module
[not found] ` <6bLbw-344-3@gated-at.bofh.it>
@ 2006-05-15 8:35 ` sej
2006-05-15 17:26 ` Chris Wright
0 siblings, 1 reply; 6+ messages in thread
From: sej @ 2006-05-15 8:35 UTC (permalink / raw)
To: Chris Wright, linux-kernel
Chris Wright a écrit :
> * sej.kernel (sej.kernel@gmail.com) wrote:
>> I need to use mlock and munlock function into a kernel module. How so
>> I call this system call from my module ?
>
> You shouldn't.
>
>> I need to do this because I must use mlock in my software, but I can't
>> use root or suser to start it. So mlock alwaays fail.
>
> You should be using rlimits for this.
>
> thanks,
> -chris
So how to set rlimits ?
My program is in user mode and has to allocate about 128MB to 512MB of
non swappable memory. Maybe I can change the rlimits rights into my
kernel module ?
Do you know how to do this and where to find informations ?
Regards,
sej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mlock into kernel module
2006-05-15 8:35 ` mlock into kernel module sej
@ 2006-05-15 17:26 ` Chris Wright
0 siblings, 0 replies; 6+ messages in thread
From: Chris Wright @ 2006-05-15 17:26 UTC (permalink / raw)
To: sej; +Cc: Chris Wright, linux-kernel
* sej (sej@sej.fr) wrote:
> So how to set rlimits ?
You have a few options. Considering your program can't run as root,
that means directly using setrlimit (or smth like ulimit in bash) is
probably not right for you. Take a look at the pam docs for
/etc/security/limits.conf, specifically for memlock.
> My program is in user mode and has to allocate about 128MB to 512MB of
> non swappable memory. Maybe I can change the rlimits rights into my
> kernel module ?
I have no idea what your kernel module is, nor what your exact
requirements are. However, you shouldn't be changing rlimits in a
kernel module, there's plenty of userspace support for that.
thanks,
-chris
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-05-15 17:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <6bHKI-6a8-9@gated-at.bofh.it>
[not found] ` <6bLbw-344-3@gated-at.bofh.it>
2006-05-15 8:35 ` mlock into kernel module sej
2006-05-15 17:26 ` Chris Wright
2006-05-12 15:22 sej.kernel
2006-05-12 15:52 ` linux-os (Dick Johnson)
2006-05-12 18:44 ` Arjan van de Ven
2006-05-12 19:08 ` Chris Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox