: Cache allocation of entries
PATCH 18/43 : Cache allocation of entries
[TFRC]: Cache allocation of entries
This updates and simplifies the allocation of kmem_cache entries with regard to the new structure.
Main changes:
1. On-demand allocation: no memory consumption when running over loss-free links.
2. Since cache allocation is local to the module, the cache constructor/destructor have been integrated into the module initialisation/cleanup routines.
Signed-off-by Gerrit Renker <[email protected]>
--- net/dccp/ccids/ccid3.c | 23 +------- net/dccp/ccids/lib/loss_interval.c | 103 +++++++++---------------------------- net/dccp/ccids/lib/loss_interval.h | 24 -------- net/dccp/ccids/lib/tfrc_module.c | 8 ++ 4 files changed, 38 insertions(+), 120 deletions(-)
net/dccp/ccids/lib/tfrc_module.c +7 -1
@@ -6,12 +6,17 @@#include "tfrc.h" /* Initialisation / Clean-up routines */ +extern int li_init (void ); +extern void li_cleanup (void );extern int packet_history_init (void );extern void packet_history_cleanup (void );static int __init tfrc_module_init (void ) { -int rc =packet_history_init (); +int rc =li_init (); + +if (rc =0 ) + rc =packet_history_init ();return rc; }
@@ -19,6 +24,7 @@ static int __init tfrc_module_init(void) static void __exit tfrc_module_exit(void) {packet_history_cleanup (); +li_cleanup (); }module_init (tfrc_module_init);
net/dccp/ccids/lib/loss_interval.h +1 -23
@@ -40,9 +40,6 @@ struct tfrc_loss_interval {u32 li_length; }; -extern struct dccp_li_hist *dccp_li_hist_new (const char *name); -extern void dccp_li_hist_delete (struct dccp_li_hist *hist); -/** * tfrc_loss_hist - Loss record database * @ring: Circular queue managed in LIFO manner
@@ -68,27 +65,8 @@ static inline u8 tfrc_lh_length(struct t return min(lh->counter, (u8)LIH_SIZE); } -#if 0 /*XXX next patch */ -static inline struct dccp_li_hist_entry * -dccp_li_hist_entry_new (struct dccp_li_hist *hist, -const gfp_t prio) -{ -return kmem_cache_alloc (hist->dccplih_slab, prio); -} -#endif - -static inline void dccp_li_hist_entry_delete (struct dccp_li_hist *hist, -struct dccp_li_hist_entry *entry) -{ -if (entry !=NULL ) -kmem_cache_free (hist->dccplih_slab, entry); -} - -extern void dccp_li_hist_purge (struct dccp_li_hist *hist, -struct list_head *list); +extern void tfrc_lh_cleanup (struct tfrc_loss_hist *lh);extern u32 dccp_li_hist_calc_i_mean (struct list_head *list); -extern int dccp_li_hist_interval_new (struct dccp_li_hist *hist, -struct list_head *list,const u64 seq_loss,const u8 win_loss);#endif /* _DCCP_LI_HIST_ */
net/dccp/ccids/lib/loss_interval.c +26 -77
128 lines not on this page · raw message
net/dccp/ccids/ccid3.c +4 -19
@@ -46,7 +46,6 @@ static int ccid3_debug;#endif static struct dccp_tx_hist *ccid3_tx_hist; -static struct dccp_li_hist *ccid3_li_hist;/* * Transmitter Half-Connection Routines
@@ -1088,23 +1087,13 @@ static __init int ccid3_module_init(voidif (ccid3_tx_hist =NULL ) goto out; - ccid3_li_hist =dccp_li_hist_new ("ccid3" ); -if (ccid3_li_hist =NULL ) - goto out_free_tx; - rc =ccid_register (&ccid3); -if (rc !=0 ) - goto out_free_loss_interval_history; +if (rc !=0 ) { +dccp_tx_hist_delete (ccid3_tx_hist); + ccid3_tx_hist =NULL ; + } out:return rc; - -out_free_loss_interval_history: -dccp_li_hist_delete (ccid3_li_hist); - ccid3_li_hist =NULL ; -out_free_tx: -dccp_tx_hist_delete (ccid3_tx_hist); - ccid3_tx_hist =NULL ; - goto out; }module_init (ccid3_module_init);
@@ -1116,10 +1105,6 @@ static __exit void ccid3_module_exit(voidccp_tx_hist_delete (ccid3_tx_hist); ccid3_tx_hist =NULL ; } -if (ccid3_li_hist !=NULL ) { -dccp_li_hist_delete (ccid3_li_hist); - ccid3_li_hist =NULL ; - } }module_exit (ccid3_module_exit);
Quoted 1 line · Gerrit Renker
[TFRC]: Cache allocation of entries
Acked-by Ian McDonald <[email protected]>
Signature · 3 lines
Web: http://wand.net.nz/~iam4/ Blog: http://iansblog.jandi.co.nz WAND Network Research Group