Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
4663afe2
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
161
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4663afe2
编写于
10月 12, 2006
作者:
E
Eric Dumazet
提交者:
David S. Miller
10月 15, 2006
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NET]: reduce sizeof(struct inet_peer), cleanup, change in peer_check_expire()
1) shrink struct inet_peer on 64 bits platforms.
上级
ea614d7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
22 deletion
+24
-22
include/net/inetpeer.h
include/net/inetpeer.h
+2
-15
net/ipv4/inetpeer.c
net/ipv4/inetpeer.c
+22
-7
未找到文件。
include/net/inetpeer.h
浏览文件 @
4663afe2
...
...
@@ -19,7 +19,7 @@ struct inet_peer
{
struct
inet_peer
*
avl_left
,
*
avl_right
;
struct
inet_peer
*
unused_next
,
**
unused_prevp
;
unsigned
long
dtime
;
/* the time of last use of not
__u32
dtime
;
/* the time of last use of not
* referenced entries */
atomic_t
refcnt
;
__be32
v4daddr
;
/* peer's address */
...
...
@@ -35,21 +35,8 @@ void inet_initpeers(void) __init;
/* can be called with or without local BH being disabled */
struct
inet_peer
*
inet_getpeer
(
__be32
daddr
,
int
create
);
extern
spinlock_t
inet_peer_unused_lock
;
extern
struct
inet_peer
**
inet_peer_unused_tailp
;
/* can be called from BH context or outside */
static
inline
void
inet_putpeer
(
struct
inet_peer
*
p
)
{
spin_lock_bh
(
&
inet_peer_unused_lock
);
if
(
atomic_dec_and_test
(
&
p
->
refcnt
))
{
p
->
unused_prevp
=
inet_peer_unused_tailp
;
p
->
unused_next
=
NULL
;
*
inet_peer_unused_tailp
=
p
;
inet_peer_unused_tailp
=
&
p
->
unused_next
;
p
->
dtime
=
jiffies
;
}
spin_unlock_bh
(
&
inet_peer_unused_lock
);
}
extern
void
inet_putpeer
(
struct
inet_peer
*
p
);
extern
spinlock_t
inet_peer_idlock
;
/* can be called with or without local BH being disabled */
...
...
net/ipv4/inetpeer.c
浏览文件 @
4663afe2
...
...
@@ -94,10 +94,8 @@ int inet_peer_minttl = 120 * HZ; /* TTL under high load: 120 sec */
int
inet_peer_maxttl
=
10
*
60
*
HZ
;
/* usual time to live: 10 min */
static
struct
inet_peer
*
inet_peer_unused_head
;
/* Exported for inet_putpeer inline function. */
struct
inet_peer
**
inet_peer_unused_tailp
=
&
inet_peer_unused_head
;
DEFINE_SPINLOCK
(
inet_peer_unused_lock
);
#define PEER_MAX_CLEANUP_WORK 30
static
struct
inet_peer
**
inet_peer_unused_tailp
=
&
inet_peer_unused_head
;
static
DEFINE_SPINLOCK
(
inet_peer_unused_lock
);
static
void
peer_check_expire
(
unsigned
long
dummy
);
static
DEFINE_TIMER
(
peer_periodic_timer
,
peer_check_expire
,
0
,
0
);
...
...
@@ -340,7 +338,8 @@ static int cleanup_once(unsigned long ttl)
spin_lock_bh
(
&
inet_peer_unused_lock
);
p
=
inet_peer_unused_head
;
if
(
p
!=
NULL
)
{
if
(
time_after
(
p
->
dtime
+
ttl
,
jiffies
))
{
__u32
delta
=
(
__u32
)
jiffies
-
p
->
dtime
;
if
(
delta
<
ttl
)
{
/* Do not prune fresh entries. */
spin_unlock_bh
(
&
inet_peer_unused_lock
);
return
-
1
;
...
...
@@ -432,7 +431,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
/* Called with local BH disabled. */
static
void
peer_check_expire
(
unsigned
long
dummy
)
{
int
i
;
unsigned
long
now
=
jiffies
;
int
ttl
;
if
(
peer_total
>=
inet_peer_threshold
)
...
...
@@ -441,7 +440,10 @@ static void peer_check_expire(unsigned long dummy)
ttl
=
inet_peer_maxttl
-
(
inet_peer_maxttl
-
inet_peer_minttl
)
/
HZ
*
peer_total
/
inet_peer_threshold
*
HZ
;
for
(
i
=
0
;
i
<
PEER_MAX_CLEANUP_WORK
&&
!
cleanup_once
(
ttl
);
i
++
);
while
(
!
cleanup_once
(
ttl
))
{
if
(
jiffies
!=
now
)
break
;
}
/* Trigger the timer after inet_peer_gc_mintime .. inet_peer_gc_maxtime
* interval depending on the total number of entries (more entries,
...
...
@@ -455,3 +457,16 @@ static void peer_check_expire(unsigned long dummy)
peer_total
/
inet_peer_threshold
*
HZ
;
add_timer
(
&
peer_periodic_timer
);
}
void
inet_putpeer
(
struct
inet_peer
*
p
)
{
spin_lock_bh
(
&
inet_peer_unused_lock
);
if
(
atomic_dec_and_test
(
&
p
->
refcnt
))
{
p
->
unused_prevp
=
inet_peer_unused_tailp
;
p
->
unused_next
=
NULL
;
*
inet_peer_unused_tailp
=
p
;
inet_peer_unused_tailp
=
&
p
->
unused_next
;
p
->
dtime
=
(
__u32
)
jiffies
;
}
spin_unlock_bh
(
&
inet_peer_unused_lock
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录