Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
14fc18b9
A
accel-ppp
项目概览
Achou.Wang
/
accel-ppp
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
accel-ppp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
14fc18b9
编写于
12月 25, 2010
作者:
D
Dmitry Kozlov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mempool: allocate memory for mmaped pools in page boundary
mempool: don't clean mmaped pools
上级
0c62497d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
10 deletion
+10
-10
accel-pptpd/triton/mempool.c
accel-pptpd/triton/mempool.c
+10
-10
未找到文件。
accel-pptpd/triton/mempool.c
浏览文件 @
14fc18b9
...
...
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <linux/mman.h>
...
...
@@ -15,7 +16,6 @@
#endif
//#define MEMPOOL_DISABLE
#define MMAP_PAGE_SIZE 16
#define MAGIC1 0x2233445566778899llu
...
...
@@ -126,7 +126,7 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line)
struct
_mempool_t
*
p
=
(
struct
_mempool_t
*
)
pool
;
struct
_item_t
*
it
;
uint32_t
size
=
sizeof
(
*
it
)
+
p
->
size
+
8
;
int
i
;
int
i
,
n
;
spin_lock
(
&
p
->
lock
);
if
(
!
list_empty
(
&
p
->
items
))
{
...
...
@@ -155,11 +155,12 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line)
spin_unlock
(
&
p
->
lock
);
if
(
p
->
mmap
)
{
it
=
mmap
(
NULL
,
size
*
MMAP_PAGE_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANON
|
MAP_32BIT
,
-
1
,
0
);
__sync_add_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
*
(
MMAP_PAGE_SIZE
-
1
));
__sync_add_and_fetch
(
&
triton_stat
.
mempool_available
,
size
*
(
MMAP_PAGE_SIZE
-
1
));
n
=
(
sysconf
(
_SC_PAGE_SIZE
)
-
1
)
/
size
+
1
;
it
=
mmap
(
NULL
,
n
*
size
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANON
|
MAP_32BIT
,
-
1
,
0
);
__sync_add_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
*
(
n
-
1
));
__sync_add_and_fetch
(
&
triton_stat
.
mempool_available
,
size
*
(
n
-
1
));
spin_lock
(
&
p
->
lock
);
for
(
i
=
0
;
i
<
MMAP_PAGE_SIZE
-
1
;
i
++
,
it
)
{
for
(
i
=
0
;
i
<
n
-
1
;
i
++
,
it
)
{
it
->
owner
=
p
;
it
->
magic2
=
p
->
magic
;
it
->
magic1
=
MAGIC1
;
...
...
@@ -298,6 +299,8 @@ void sigclean(int num)
spin_lock
(
&
pools_lock
);
list_for_each_entry
(
p
,
&
pools
,
entry
)
{
if
(
p
->
mmap
)
continue
;
size
=
sizeof
(
*
it
)
+
p
->
size
+
8
;
spin_lock
(
&
p
->
lock
);
while
(
!
list_empty
(
&
p
->
items
))
{
...
...
@@ -307,10 +310,7 @@ void sigclean(int num)
VALGRIND_MAKE_MEM_DEFINED
(
&
it
->
owner
,
size
-
sizeof
(
it
->
entry
)
-
sizeof
(
it
->
timestamp
));
#endif
list_del
(
&
it
->
entry
);
if
(
p
->
mmap
)
munmap
(
it
,
size
);
else
_free
(
it
);
_free
(
it
);
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
);
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_available
,
size
);
#ifdef VALGRIND
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录