From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id 92E456B0038 for ; Wed, 7 Dec 2016 11:33:46 -0500 (EST) Received: by mail-oi0-f71.google.com with SMTP id u15so671497726oie.6 for ; Wed, 07 Dec 2016 08:33:46 -0800 (PST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0056.outbound.protection.outlook.com. [104.47.2.56]) by mx.google.com with ESMTPS id z22si12211285oia.136.2016.12.07.08.33.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 08:33:45 -0800 (PST) Received: by mail-wm0-f48.google.com with SMTP id f82so175459576wmf.1 for ; Wed, 07 Dec 2016 08:33:43 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <52a0d9c3-5c9a-d207-4cbc-a6df27ba6a9c@suse.cz> References: <52a0d9c3-5c9a-d207-4cbc-a6df27ba6a9c@suse.cz> From: Federico Reghenzani Date: Wed, 7 Dec 2016 17:33:19 +0100 Message-ID: Subject: Re: mlockall() with pid parameter Content-Type: multipart/alternative; boundary="001a114d46b85c4168054314158e" Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Federico Reghenzani , linux-mm@kvack.org --001a114d46b85c4168054314158e Content-Type: text/plain; charset="UTF-8" 2016-12-07 17:21 GMT+01:00 Vlastimil Babka : > On 12/07/2016 04:39 PM, Federico Reghenzani wrote: > > Hello, > > > > I'm working on Real-Time applications in Linux. `mlockall()` is a > > typical syscall used in RT processes in order to avoid page faults. > > However, the use of this syscall is strongly limited by ulimits, so > > basically all RT processes that want to call `mlockall()` have to be > > executed with root privileges. > > Is it not possible to change the ulimits with e.g. prlimit? > > Yes, but it requires a synchronization between non-root process and root process. Because the root process has to change the limits before the non-root process executes the mlockall(). Just to provide an example, another syscall used in RT tasks is the sched_setscheduler() that also suffers the limitation of ulimits, but it accepts the pid so the scheduling policy can be enforced by a root process to any other process. > > What I would like to have is a syscall that accept a "pid", so a process > > spawned by root would be able to enforce the memory locking to other > > non-root processes. The prototypes would be: > > > > int mlockall(int flags, pid_t pid); > > int munlockall(pid_t pid); > > > > I checked the source code and it seems to me quite easy to add this > > syscall variant. > > > > I'm writing here to have a feedback before starting to edit the code. Do > > you think that this is a good approach? > > > > > > Thank you, > > Federico > > > > -- > > *Federico Reghenzani* > > PhD Candidate > > Politecnico di Milano > > Dipartimento di Elettronica, Informazione e Bioingegneria > > > > -- *Federico Reghenzani* PhD Candidate Politecnico di Milano Dipartimento di Elettronica, Informazione e Bioingegneria --001a114d46b85c4168054314158e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


2016-12-07 17:21 GMT+01:00 Vlastimil Babka <vbabka@suse.cz>= :
On 12/07/2016 04:39 PM, Federico Reghenzani wrote:
> Hello,
>
> I'm working on Real-Time applications in Linux. `mlockall()` is a<= br> > typical syscall used in RT processes in order to avoid page faults. > However, the use of this syscall is strongly limited by ulimits, so > basically all RT processes that want to call `mlockall()` have to be > executed with root privileges.

Is it not possible to change the ulimits with e.g. prlimit?


Yes, but= it requires a synchronization between non-root process and root process.
Because the root process has to change the limits before the non-r= oot process executes the mlockall().

Just to provi= de an example, another syscall used in RT tasks is the sched_setscheduler()= that also suffers
the limitation of ulimits, but it accepts the = pid so the scheduling policy can be enforced by a root process to
any other process.
=C2=A0
=C2=A0
> What I would like to have is a syscall that accept a "pid", = so a process
> spawned by root would be able to enforce the memory locking to other > non-root processes. The prototypes would be:
>
> int mlockall(int flags, pid_t pid);
> int munlockall(pid_t pid);
>
> I checked the source code and it seems to me quite easy to add this > syscall variant.
>
> I'm writing here to have a feedback before starting to edit the co= de. Do
> you think that this is a good approach?
>
>
> Thank you,
> Federico
>
> --
> *Federico Reghenzani*
> PhD Candidate
> Politecnico di Milano
> Dipartimento di Elettronica, Informazione e Bioingegneria
>




--
=
Federico Reghenzani<= div>PhD Candidate
Polite= cnico di Milano
Dipartimento di Elettroni= ca, Informazione e Bioingegneria

--001a114d46b85c4168054314158e-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org