From: Tony Zelenoff <hidden> Date: 2012-02-21 17:26:35
While working at my project, saw some issues that better to refactor and
save a bit of CPU cycles. So, here they are.
Patches based on net-next tree.
Tony Zelenoff (3):
net/netfilter: whitespace removed
net/netfilter: refactor notifier registration
net/netfilter: refactor nf_ct_deliver_cached_events
net/netfilter/nf_conntrack_ecache.c | 81 +++++++++++++++++------------------
1 files changed, 39 insertions(+), 42 deletions(-)
@@ -47,31 +49,32 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct)events=xchg(&e->cache,0);-if(nf_ct_is_confirmed(ct)&&!nf_ct_is_dying(ct)&&events){-structnf_ct_eventitem={-.ct=ct,-.pid=0,-.report=0-};-intret;-/* We make a copy of the missed event cache without taking-*thelock,thuswemaysendmissedeventstwice.However,-*thisdoesnotharmandithappensveryrarely.*/-unsignedlongmissed=e->missed;--if(!((events|missed)&e->ctmask))-gotoout_unlock;--ret=notify->fcn(events|missed,&item);-if(unlikely(ret<0||missed)){-spin_lock_bh(&ct->lock);-if(ret<0)-e->missed|=events;-else-e->missed&=~missed;-spin_unlock_bh(&ct->lock);-}-}+if(!nf_ct_is_confirmed(ct)||nf_ct_is_dying(ct)||!events)+gotoout_unlock;++/* We make a copy of the missed event cache without taking+*thelock,thuswemaysendmissedeventstwice.However,+*thisdoesnotharmandithappensveryrarely.*/+missed=e->missed;++if(!((events|missed)&e->ctmask))+gotoout_unlock;++item.ct=ct;+item.pid=0;+item.report=0;++ret=notify->fcn(events|missed,&item);++if(likely(ret>=0&&!missed))+gotoout_unlock;++spin_lock_bh(&ct->lock);+if(ret<0)+e->missed|=events;+else+e->missed&=~missed;+spin_unlock_bh(&ct->lock);out_unlock:rcu_read_unlock();
From: Tony Zelenoff <hidden> Date: 2012-02-21 17:26:35
* ret variable initialization removed as useless
* Similar code strings concatenated and functions code
flow became more plain
Signed-off-by: Tony Zelenoff <redacted>
---
net/netfilter/nf_conntrack_ecache.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)