Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9dd02965
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9dd02965
编写于
10月 17, 2013
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numa: Introduce virNumaGetNodeMemory and use it instead of numa_node_size64
上级
f72cfea1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
13 deletion
+67
-13
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/nodeinfo.c
src/nodeinfo.c
+8
-13
src/util/virnuma.c
src/util/virnuma.c
+55
-0
src/util/virnuma.h
src/util/virnuma.h
+3
-0
未找到文件。
src/libvirt_private.syms
浏览文件 @
9dd02965
...
...
@@ -1524,6 +1524,7 @@ virDomainNumatuneMemModeTypeFromString;
virDomainNumatuneMemModeTypeToString;
virNumaGetAutoPlacementAdvice;
virNumaGetMaxNode;
virNumaGetNodeMemory;
virNumaIsAvailable;
virNumaSetupMemoryPolicy;
virNumaTuneMemPlacementModeTypeFromString;
...
...
src/nodeinfo.c
浏览文件 @
9dd02965
...
...
@@ -1680,6 +1680,7 @@ nodeGetCellsFreeMemory(unsigned long long *freeMems,
int
startCell
,
int
maxCells
)
{
unsigned
long
long
mem
;
int
n
,
lastCell
,
numCells
;
int
ret
=
-
1
;
int
maxCell
;
...
...
@@ -1702,9 +1703,7 @@ nodeGetCellsFreeMemory(unsigned long long *freeMems,
lastCell
=
maxCell
;
for
(
numCells
=
0
,
n
=
startCell
;
n
<=
lastCell
;
n
++
)
{
long
long
mem
;
if
(
numa_node_size64
(
n
,
&
mem
)
<
0
)
mem
=
0
;
virNumaGetNodeMemory
(
n
,
NULL
,
&
mem
);
freeMems
[
numCells
++
]
=
mem
;
}
...
...
@@ -1717,6 +1716,7 @@ cleanup:
unsigned
long
long
nodeGetFreeMemory
(
void
)
{
unsigned
long
long
mem
;
unsigned
long
long
freeMem
=
0
;
int
max_node
;
int
n
;
...
...
@@ -1728,9 +1728,7 @@ nodeGetFreeMemory(void)
return
0
;
for
(
n
=
0
;
n
<=
max_node
;
n
++
)
{
long
long
mem
;
if
(
numa_node_size64
(
n
,
&
mem
)
<
0
)
continue
;
virNumaGetNodeMemory
(
n
,
NULL
,
&
mem
);
freeMem
+=
mem
;
}
...
...
@@ -1742,21 +1740,19 @@ nodeGetFreeMemory(void)
* nodeGetCellMemory
* @cell: The number of the numa cell to get memory info for.
*
* Will call the numa_node_size64() function from libnuma to get
* the amount of total memory in bytes. It is then converted to
* KiB and returned.
* Request size of memory in a NUMA node.
*
* Returns 0 if unavailable, amount of memory in KiB on success.
*/
static
unsigned
long
long
nodeGetCellMemory
(
int
cell
)
{
long
long
mem
;
unsigned
long
long
mem
;
unsigned
long
long
memKiB
=
0
;
int
maxCell
;
/* Make sure the provided cell number is valid. */
if
((
maxCell
=
virNumaGetMaxNode
())
<
0
)
return
0
;
goto
cleanup
;
if
(
cell
>
maxCell
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -1766,8 +1762,7 @@ static unsigned long long nodeGetCellMemory(int cell)
}
/* Get the amount of memory(bytes) in the node */
mem
=
numa_node_size64
(
cell
,
NULL
);
if
(
mem
<
0
)
{
if
(
virNumaGetNodeMemory
(
cell
,
&
mem
,
NULL
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to query NUMA total memory for node: %d"
),
cell
);
...
...
src/util/virnuma.c
浏览文件 @
9dd02965
...
...
@@ -202,6 +202,45 @@ virNumaGetMaxNode(void)
return
ret
;
}
/**
* virNumaGetNodeMemorySize:
* @node: identifier of the requested NUMA node
* @memsize: returns the total size of memory in the NUMA node
* @memfree: returns the total free memory in a NUMA node
*
* Returns the size of the memory in one NUMA node in bytes via the @size
* argument and free memory of a node in the @free argument. The caller has to
* guarantee that @node is in range (see virNumaGetMaxNode).
*
* Returns 0 on success, -1 on error. Does not report errors.
*/
int
virNumaGetNodeMemory
(
int
node
,
unsigned
long
long
*
memsize
,
unsigned
long
long
*
memfree
)
{
long
long
node_size
;
long
long
node_free
;
if
(
memsize
)
*
memsize
=
0
;
if
(
memfree
)
*
memfree
=
0
;
if
((
node_size
=
numa_node_size64
(
node
,
&
node_free
))
<
0
)
return
-
1
;
if
(
memsize
)
*
memsize
=
node_size
;
if
(
memfree
)
*
memfree
=
node_free
;
return
0
;
}
#else
int
virNumaSetupMemoryPolicy
(
virNumaTuneDef
numatune
,
...
...
@@ -232,4 +271,20 @@ virNumaGetMaxNode(void)
_
(
"NUMA isn't available on this host"
));
return
-
1
;
}
int
virNumaGetNodeMemory
(
int
node
ATTRIBUTE_UNUSED
,
unsigned
long
long
*
memsize
,
unsigned
long
long
*
memfree
)
{
if
(
memsize
)
*
memsize
=
0
;
if
(
memfree
)
*
memfree
=
0
;
VIR_DEBUG
(
"NUMA isn't available on this host"
);
return
-
1
;
}
#endif
src/util/virnuma.h
浏览文件 @
9dd02965
...
...
@@ -58,5 +58,8 @@ int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
bool
virNumaIsAvailable
(
void
);
int
virNumaGetMaxNode
(
void
);
int
virNumaGetNodeMemory
(
int
node
,
unsigned
long
long
*
memsize
,
unsigned
long
long
*
memfree
);
#endif
/* __VIR_NUMA_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录