Merge lp:~mshankar/epics-base/memlock_linux into lp:~epics-core/epics-base/3.15

Proposed by Murali Shankar
Status: Merged
Merged at revision: 12523
Proposed branch: lp:~mshankar/epics-base/memlock_linux
Merge into: lp:~epics-core/epics-base/3.15
Diff against target: 75 lines (+47/-0)
2 files modified
documentation/RELEASE_NOTES.html (+23/-0)
src/libCom/osi/os/posix/osdThread.c (+24/-0)
To merge this branch: bzr merge lp:~mshankar/epics-base/memlock_linux
Reviewer Review Type Date Requested Status
Andrew Johnson Approve
Review via email: mp+232466@code.launchpad.net

Description of the change

This change will attempt to lock the process's virtual address space into RAM if the process has the ability to run threads with different priorities. If unsuccessful, it prints an message to stderr and continues.

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

Approved, will merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'documentation/RELEASE_NOTES.html'
2--- documentation/RELEASE_NOTES.html 2014-07-31 17:45:40 +0000
3+++ documentation/RELEASE_NOTES.html 2014-08-27 19:21:22 +0000
4@@ -15,6 +15,29 @@
5 <h2 align="center">Changes between 3.15.0.1 and 3.15.0.2</h2>
6 <!-- Insert new items immediately below here ... -->
7
8+<h3>On POSIX systems, attempt to lock all memory on startup if running with a FIFO scheduler</h3>
9+
10+<p>
11+On POSIX systems, an IOC application's ability to meet timing deadlines is often
12+dependent on its ability to lock part or all of the process's virtual
13+address space into RAM, preventing that memory from being paged to the swap
14+area. This change will attempt to lock the process's virtual address space into
15+RAM if the process has the ability to run threads with different priorities. If
16+unsuccessful, it prints an message to stderr and continues.
17+
18+In Linux, one can grant a process the ability to run threads with different
19+priorities by using a command like <code>ulimit -r unlimited</code>. To use the FIFO
20+scheduler, use a command like so - <code>chrt -f 1 softIoc -d test.db</code>
21+
22+In Linux, one can grant a process the ability to lock memory by using a command
23+like <code>ulimit -l unlimited</code>. Alternatively, these limits can be configured on a per
24+user/per group basis by changing /etc/security/limits.conf or its equivalent.
25+
26+In Linux, a child process created via fork inherits its parent's resource
27+limits. Thus, it is probably a good idea to start the caRepeater before
28+starting the IOC.
29+</p>
30+
31 <h3>Implement EPICS_CAS_INTF_ADDR_LIST in rsrv</h3>
32
33 <p>The IOC server can now bind to a single IP address (and optional port number)
34
35=== modified file 'src/libCom/osi/os/posix/osdThread.c'
36--- src/libCom/osi/os/posix/osdThread.c 2014-05-18 15:24:38 +0000
37+++ src/libCom/osi/os/posix/osdThread.c 2014-08-27 19:21:22 +0000
38@@ -35,6 +35,13 @@
39 #include "epicsAssert.h"
40 #include "epicsExit.h"
41
42+#if defined(linux)
43+#if _POSIX_MEMLOCK > 0
44+#include <sys/mman.h>
45+#endif
46+#endif
47+
48+
49 epicsShareFunc void epicsThreadShowInfo(epicsThreadOSD *pthreadInfo, unsigned int level);
50 epicsShareFunc void osdThreadHooksRun(epicsThreadId id);
51 epicsShareFunc void osdThreadHooksRunMain(epicsThreadId id);
52@@ -344,6 +351,23 @@
53 fprintf(stderr,"sched_get_priority_min failed set to %d\n",
54 pcommonAttr->maxPriority);
55 }
56+
57+#if _POSIX_MEMLOCK > 0
58+ if(errVerbose) {
59+ fprintf(stderr, "LRT: min priority: %d max priority %d\n",
60+ pcommonAttr->minPriority, pcommonAttr->maxPriority);
61+ }
62+ if (pcommonAttr->maxPriority > pcommonAttr->minPriority) {
63+ status = mlockall(MCL_CURRENT | MCL_FUTURE);
64+ if(status) {
65+ fprintf(stderr, "Unable to lock the virtual address space using mlockall\n");
66+ } else {
67+ fprintf(stderr,"Successfully locked memory using mlockAll\n");
68+ }
69+ }
70+#endif
71+
72+
73 #else
74 if(errVerbose) fprintf(stderr,"task priorities are not implemented\n");
75 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */

Subscribers

People subscribed via source and target branches