xfrm: optimise the use of walk list header in xfrm_policy/state_walk
Subsystems (3)
PATCH v2 1/1 xfrm: optimise the use of walk list header in xfrm_policy/state_walk
From: Li RongQing <[email protected]>
The walk from input is the list header, and marked as dead, and will be skipped in loop.
list_first_entry() can be used to return the true usable value from walk if walk is not empty
--- net/xfrm/xfrm_policy.c | 4 +++- net/xfrm/xfrm_state.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +3 -1
@@ -1004,7 +1004,9 @@ int xfrm_policy_walk(struct net *net, struct xfrm_policy_walk *walk,if (list_empty (&walk->walk.all)) x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all);else - x = list_entry(&walk->walk.all, struct xfrm_policy_walk_entry, all); + x =list_first_entry (&walk->walk.all, + struct xfrm_policy_walk_entry, all); +list_for_each_entry_from (x, &net->xfrm.policy_all, all) {if (x->dead)continue ;
net/xfrm/xfrm_state.c +1 -1
@@ -1626,7 +1626,7 @@ int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk,if (list_empty (&walk->all)) x = list_first_entry(&net->xfrm.state_all, struct xfrm_state_walk, all);else - x = list_entry(&walk->all, struct xfrm_state_walk, all); + x = list_first_entry(&walk->all, struct xfrm_state_walk, all);list_for_each_entry_from (x, &net->xfrm.state_all, all) {if (x->state ==XFRM_STATE_DEAD )continue ;
Signature · 1 line
2.1.0
Quoted 9 lines · On Wed, Apr 22, 2015 at 05:09:54PM +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
The walk from input is the list header, and marked as dead, and will be skipped in loop.
list_first_entry()can be used to return the true usable value from walk if walk is not emptySigned-off-by Li RongQing <[email protected]>
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 6 lines · Herbert Xu
Quoted 5 lines · On Wed, Apr 22, 2015 at 05:09:54PM +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
The walk from input is the list header, and marked as dead, and will be skipped in loop.
Quoted 6 lines
Quoted 4 lines
list_first_entry()can be used to return the true usable value from walk if walk is not emptySigned-off-by Li RongQing <[email protected]>Acked-by Herbert Xu <[email protected]>
Applied to ipsec-next, thanks everyone!