Motr
M0
process_attr.c
Go to the documentation of this file.
1
/* -*- C -*- */
2
/*
3
* Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
* For any questions about this software or licensing,
18
* please email opensource@seagate.com or cortx-questions@seagate.com.
19
*
20
*/
21
22
23
#include <unistd.h>
/* daemon */
24
25
#define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_M0D
26
#include "
lib/trace.h
"
27
28
#include <sys/resource.h>
29
#include "
lib/bitmap.h
"
30
#include "
motr/process_attr.h
"
31
#include "
module/instance.h
"
/* m0 */
32
38
static
int
reqh_memlimit_set
(uint resource, uint64_t limit)
39
{
40
int
rc
;
41
struct
rlimit rl;
42
43
M0_ENTRY
();
44
45
rc
= -getrlimit(resource, &rl);
46
if
(
rc
!=0)
47
return
M0_ERR
(
rc
);
48
rl.rlim_cur = limit;
49
rc
= -setrlimit(resource, &rl);
50
51
return
M0_RC
(
rc
);
52
}
53
54
int
m0_cs_memory_limits_setup
(
struct
m0
*
instance
)
55
{
56
int
rc
;
57
struct
m0_proc_attr
*proc_attr = &
instance
->
i_proc_attr
;
58
59
M0_ENTRY
();
60
61
rc
= proc_attr->
pca_memlimit_as
!=
M0_PROCESS_ATTRIBUTE_NO_MEMLIMIT
?
62
reqh_memlimit_set
(RLIMIT_AS, proc_attr->
pca_memlimit_as
) : 0;
63
rc
=
rc
== 0 &&
64
proc_attr->
pca_memlimit_rss
!=
M0_PROCESS_ATTRIBUTE_NO_MEMLIMIT
?
65
reqh_memlimit_set
(RLIMIT_RSS, proc_attr->
pca_memlimit_rss
) :
rc
;
66
rc
=
rc
== 0 &&
67
proc_attr->
pca_memlimit_stack
!=
M0_PROCESS_ATTRIBUTE_NO_MEMLIMIT
?
68
reqh_memlimit_set
(RLIMIT_STACK, proc_attr->
pca_memlimit_stack
) :
rc
;
69
rc
=
rc
== 0 &&
70
proc_attr->
pca_memlimit_memlock
!=
M0_PROCESS_ATTRIBUTE_NO_MEMLIMIT
?
71
reqh_memlimit_set
(RLIMIT_MEMLOCK, proc_attr->
pca_memlimit_memlock
) :
72
rc
;
73
return
M0_RC
(
rc
);
74
}
75
77
#undef M0_TRACE_SUBSYSTEM
78
79
/*
80
* Local variables:
81
* c-indentation-style: "K&R"
82
* c-basic-offset: 8
83
* tab-width: 8
84
* fill-column: 80
85
* scroll-step: 1
86
* End:
87
*/
trace.h
process_attr.h
m0_proc_attr::pca_memlimit_memlock
uint64_t pca_memlimit_memlock
Definition:
process_attr.h:59
M0_RC
return M0_RC(rc)
M0_ENTRY
#define M0_ENTRY(...)
Definition:
trace.h:170
M0_ERR
return M0_ERR(-EOPNOTSUPP)
M0_PROCESS_ATTRIBUTE_NO_MEMLIMIT
Definition:
process_attr.h:45
m0_cs_memory_limits_setup
int m0_cs_memory_limits_setup(struct m0 *instance)
Definition:
process_attr.c:54
m0
Definition:
instance.h:80
instance.h
m0_proc_attr::pca_memlimit_rss
uint64_t pca_memlimit_rss
Definition:
process_attr.h:57
bitmap.h
m0_proc_attr
Definition:
process_attr.h:52
instance
static struct m0 instance
Definition:
main.c:78
m0::i_proc_attr
struct m0_proc_attr i_proc_attr
Definition:
instance.h:143
m0_proc_attr::pca_memlimit_stack
uint64_t pca_memlimit_stack
Definition:
process_attr.h:58
rc
int32_t rc
Definition:
trigger_fop.h:47
reqh_memlimit_set
static int reqh_memlimit_set(uint resource, uint64_t limit)
Definition:
process_attr.c:38
m0_proc_attr::pca_memlimit_as
uint64_t pca_memlimit_as
Definition:
process_attr.h:56
motr
process_attr.c
Generated on Thu Apr 14 2022 14:02:58 for Motr by
1.8.14