Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLAScommon
Commits
6fb72537
Commit
6fb72537
authored
May 20, 2021
by
Steffen Vogel
🎅🏼
Browse files
kernel: refactor naming style
parent
8949fb44
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/villas/kernel/kernel.hpp
View file @
6fb72537
...
...
@@ -34,10 +34,10 @@ namespace kernel {
utils
::
Version
getVersion
();
/** Get number of reserved hugepages. */
int
get
_nr_h
ugepages
();
int
get
NrH
ugepages
();
/** Set number of reserved hugepages. */
int
set
_nr_h
ugepages
(
int
nr
);
int
set
NrH
ugepages
(
int
nr
);
/** Get kernel cmdline parameter
*
...
...
@@ -49,7 +49,7 @@ int set_nr_hugepages(int nr);
* @retval 0 Parameter \p key was found and value was copied to \p value
* @reval <>0 Kernel was not booted with parameter \p key
*/
int
get
_c
mdline
_p
aram
(
const
char
*
param
,
char
*
buf
,
size_t
len
);
int
get
C
mdline
P
aram
(
const
char
*
param
,
char
*
buf
,
size_t
len
);
/** Checks if a kernel module is loaded
*
...
...
@@ -57,28 +57,28 @@ int get_cmdline_param(const char *param, char *buf, size_t len);
* @retval 0 Module is loaded.
* @reval <>0 Module is not loaded.
*/
int
m
odule
_l
oaded
(
const
char
*
module
);
int
isM
odule
L
oaded
(
const
char
*
module
);
/** Load kernel module via modprobe */
int
module_load
(
const
char
*
module
);
int
loadModule
(
const
char
*
module
);
/** Set parameter of loaded kernel module */
int
m
odule
_set_p
aram
(
const
char
*
module
,
const
char
*
param
,
const
char
*
value
);
int
setM
odule
P
aram
(
const
char
*
module
,
const
char
*
param
,
const
char
*
value
);
/** Get cacheline size in bytes */
int
get
_c
acheline
_s
ize
();
int
get
C
acheline
S
ize
();
/** Get the size of a standard page in bytes. */
int
get
_p
age
_s
ize
();
int
get
P
age
S
ize
();
/** Get the size of a huge page in bytes. */
int
get
_h
uge
p
age
_s
ize
();
int
get
H
uge
P
age
S
ize
();
/** Get CPU base frequency */
int
get_cpu_frequency
(
uint64_t
*
freq
);
/** Set SMP affinity of IRQ */
int
irq_seta
ffinity
(
unsigned
irq
,
uintmax_t
aff
,
uintmax_t
*
old
);
int
setIRQA
ffinity
(
unsigned
irq
,
uintmax_t
aff
,
uintmax_t
*
old
);
}
/* namespace villas */
}
/* namespace kernel */
lib/kernel/kernel.cpp
View file @
6fb72537
...
...
@@ -59,7 +59,7 @@ Version villas::kernel::getVersion()
return
Version
(
ver
);
}
int
villas
::
kernel
::
get
_c
acheline
_s
ize
()
int
villas
::
kernel
::
get
C
acheline
S
ize
()
{
#if defined(__linux__) && defined(__x86_64__) && defined(__GLIBC__)
return
sysconf
(
_SC_LEVEL1_ICACHE_LINESIZE
);
...
...
@@ -82,7 +82,7 @@ int villas::kernel::get_cacheline_size()
}
#if defined(__linux__) || defined(__APPLE__)
int
villas
::
kernel
::
get
_p
age
_s
ize
()
int
villas
::
kernel
::
get
P
age
S
ize
()
{
return
sysconf
(
_SC_PAGESIZE
);
}
...
...
@@ -91,7 +91,7 @@ int villas::kernel::get_page_size()
#endif
/* There is no sysconf interface to get the hugepage size */
int
villas
::
kernel
::
get
_h
uge
p
age
_s
ize
()
int
villas
::
kernel
::
get
H
uge
P
age
S
ize
()
{
#ifdef __linux__
char
*
key
,
*
value
,
*
unit
,
*
line
=
nullptr
,
*
lasts
;
...
...
@@ -129,7 +129,7 @@ int villas::kernel::get_hugepage_size()
#ifdef __linux__
int
villas
::
kernel
::
m
odule
_set_p
aram
(
const
char
*
module
,
const
char
*
param
,
const
char
*
value
)
int
villas
::
kernel
::
setM
odule
P
aram
(
const
char
*
module
,
const
char
*
param
,
const
char
*
value
)
{
FILE
*
f
;
char
fn
[
256
];
...
...
@@ -148,11 +148,11 @@ int villas::kernel::module_set_param(const char *module, const char *param, cons
return
0
;
}
int
villas
::
kernel
::
module_load
(
const
char
*
module
)
int
villas
::
kernel
::
loadModule
(
const
char
*
module
)
{
int
ret
;
ret
=
m
odule
_l
oaded
(
module
);
ret
=
isM
odule
L
oaded
(
module
);
if
(
!
ret
)
{
auto
logger
=
logging
.
get
(
"kernel"
);
logger
->
debug
(
"Kernel module {} already loaded..."
,
module
);
...
...
@@ -171,11 +171,11 @@ int villas::kernel::module_load(const char *module)
default:
wait
(
&
ret
);
return
m
odule
_l
oaded
(
module
);
return
isM
odule
L
oaded
(
module
);
}
}
int
villas
::
kernel
::
m
odule
_l
oaded
(
const
char
*
module
)
int
villas
::
kernel
::
isM
odule
L
oaded
(
const
char
*
module
)
{
FILE
*
f
;
int
ret
=
-
1
;
...
...
@@ -199,7 +199,7 @@ int villas::kernel::module_loaded(const char *module)
return
ret
;
}
int
villas
::
kernel
::
get
_c
mdline
_p
aram
(
const
char
*
param
,
char
*
buf
,
size_t
len
)
int
villas
::
kernel
::
get
C
mdline
P
aram
(
const
char
*
param
,
char
*
buf
,
size_t
len
)
{
int
ret
;
char
cmdline
[
512
],
key
[
128
],
value
[
128
],
*
lasts
,
*
tok
;
...
...
@@ -236,7 +236,7 @@ out:
return
-
1
;
/* not found or error */
}
int
villas
::
kernel
::
get
_nr_h
ugepages
()
int
villas
::
kernel
::
get
NrH
ugepages
()
{
FILE
*
f
;
int
nr
,
ret
;
...
...
@@ -257,7 +257,7 @@ int villas::kernel::get_nr_hugepages()
return
nr
;
}
int
villas
::
kernel
::
set
_nr_h
ugepages
(
int
nr
)
int
villas
::
kernel
::
set
NrH
ugepages
(
int
nr
)
{
FILE
*
f
;
...
...
@@ -266,7 +266,7 @@ int villas::kernel::set_nr_hugepages(int nr)
auto
logger
=
logging
.
get
(
"kernel"
);
if
(
is_container
())
{
logger
->
warn
(
"This functionality is unavailable in this mode. Please run the
Docker
container in the privileged mode:"
);
logger
->
warn
(
"This functionality is unavailable in this mode. Please run the container in the privileged mode:"
);
logger
->
warn
(
" $ docker run --privilged ..."
);
}
else
...
...
@@ -281,7 +281,7 @@ int villas::kernel::set_nr_hugepages(int nr)
return
0
;
}
int
villas
::
kernel
::
irq_seta
ffinity
(
unsigned
irq
,
uintmax_t
aff
,
uintmax_t
*
old
)
int
villas
::
kernel
::
setIRQA
ffinity
(
unsigned
irq
,
uintmax_t
aff
,
uintmax_t
*
old
)
{
char
fn
[
64
];
FILE
*
f
;
...
...
lib/kernel/rt.cpp
View file @
6fb72537
...
...
@@ -62,7 +62,7 @@ void init(int priority, int affinity)
logger
->
warn
(
"You might want to use the 'priority' setting to increase "
PROJECT_NAME
"'s process priority"
);
if
(
affinity
)
{
is_isol
=
get
_c
mdline
_p
aram
(
"isolcpus"
,
isolcpus
,
sizeof
(
isolcpus
));
is_isol
=
get
C
mdline
P
aram
(
"isolcpus"
,
isolcpus
,
sizeof
(
isolcpus
));
if
(
is_isol
)
logger
->
warn
(
"You should reserve some cores for "
PROJECT_NAME
" (see 'isolcpus')"
);
else
{
...
...
lib/kernel/vfio.cpp
View file @
6fb72537
...
...
@@ -85,7 +85,7 @@ Container::Container()
};
for
(
const
char
*
module
:
requiredKernelModules
)
{
if
(
kernel
::
module_load
(
module
)
!=
0
)
if
(
kernel
::
loadModule
(
module
)
!=
0
)
throw
RuntimeError
(
"Kernel module '{}' required but could not be loaded. "
"Please load manually!"
,
module
);
}
...
...
@@ -280,7 +280,7 @@ Container::attachDevice(const pci::Device &pdev)
Logger
logger
=
logging
.
get
(
"kernel:vfio"
);
/* Load PCI bus driver for VFIO */
if
(
kernel
::
module_load
(
"vfio_pci"
))
if
(
kernel
::
loadModule
(
"vfio_pci"
))
throw
RuntimeError
(
"Failed to load kernel driver: vfio_pci"
);
/* Bind PCI card to vfio-pci driver if not already bound */
...
...
@@ -292,7 +292,7 @@ Container::attachDevice(const pci::Device &pdev)
/* Get IOMMU group of device */
int
index
=
isIommuEnabled
()
?
pdev
.
getIOMMUGroup
()
:
0
;
if
(
index
<
0
)
{
ret
=
kernel
::
get
_c
mdline
_p
aram
(
"intel_iommu"
,
iommu_state
,
sizeof
(
iommu_state
));
ret
=
kernel
::
get
C
mdline
P
aram
(
"intel_iommu"
,
iommu_state
,
sizeof
(
iommu_state
));
if
(
ret
!=
0
||
strcmp
(
"on"
,
iommu_state
)
!=
0
)
logger
->
warn
(
"Kernel booted without command line parameter "
"'intel_iommu' set to 'on'. Please check documentation "
...
...
tests/unit/kernel.cpp
View file @
6fb72537
...
...
@@ -47,13 +47,13 @@ Test(kernel, sizes)
{
int
sz
;
sz
=
get
_p
age
_s
ize
();
sz
=
get
P
age
S
ize
();
cr_assert_eq
(
sz
,
PAGESIZE
);
sz
=
get
_h
uge
p
age
_s
ize
();
sz
=
get
H
uge
P
age
S
ize
();
cr_assert
(
sz
==
HUGEPAGESIZE
);
sz
=
get
_c
acheline
_s
ize
();
sz
=
get
C
acheline
S
ize
();
cr_assert_eq
(
sz
,
CACHELINESIZE
);
}
...
...
@@ -62,16 +62,16 @@ Test(kernel, hugepages)
{
int
ret
;
ret
=
set
_nr_h
ugepages
(
25
);
ret
=
set
NrH
ugepages
(
25
);
cr_assert_eq
(
ret
,
0
);
ret
=
get
_nr_h
ugepages
();
ret
=
get
NrH
ugepages
();
cr_assert_eq
(
ret
,
25
);
ret
=
set
_nr_h
ugepages
(
10
);
ret
=
set
NrH
ugepages
(
10
);
cr_assert_eq
(
ret
,
0
);
ret
=
get
_nr_h
ugepages
();
ret
=
get
NrH
ugepages
();
cr_assert_eq
(
ret
,
10
);
}
...
...
@@ -91,10 +91,10 @@ Test(kernel, module, .disabled = true)
{
int
ret
;
ret
=
m
odule
_l
oaded
(
"nf_nat"
);
ret
=
isM
odule
L
oaded
(
"nf_nat"
);
cr_assert_eq
(
ret
,
0
);
ret
=
m
odule
_l
oaded
(
"does_not_exist"
);
ret
=
isM
odule
L
oaded
(
"does_not_exist"
);
cr_assert_neq
(
ret
,
0
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment