Skip to contentSkip to conversation

: Cache allocation of entries

PATCH In review Gerrit Renker 2 participants 2 messages Jun 17, 2007 – Jun 28, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 3/9 : 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.

---
 net/dccp/ccids/ccid3.c             |   25 +--------
 net/dccp/ccids/lib/loss_interval.c |   93 +++++++++----------------------------
 net/dccp/ccids/lib/loss_interval.h |   22 --------
 net/dccp/ccids/lib/tfrc_module.c   |    8 ++-
 4 files changed, 36 insertions(+), 112 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 -21
@@ -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,25 +65,8 @@ static inline u8 tfrc_lh_length(struct t
 	return min(lh->counter, (u8)LIH_SIZE);
 }
 
-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);
-}
-
-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 +25 -68

118 lines not on this page · raw message

net/dccp/ccids/ccid3.c +3 -22
@@ -48,7 +48,6 @@ static int ccid3_debug;
 #endif
 
 DECLARE_TFRC_TX_CACHE(ccid3_tx_hist);
-static struct dccp_li_hist *ccid3_li_hist;
 
 /*
  *	Transmitter Half-Connection Routines
@@ -908,7 +907,7 @@ static int ccid3_hc_rx_init(struct ccid 
 
 	if (tfrc_rx_hist_init(&hcrx->ccid3hcrx_hist))
 		return 1;
-	INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
+	tfrc_lh_init(&hcrx->ccid3hcrx_li_hist);
 	hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
 	hcrx->ccid3hcrx_s     = 0;
 	hcrx->ccid3hcrx_rtt   = 0;
@@ -922,9 +921,7 @@ static void ccid3_hc_rx_exit(struct sock
 	ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);
 
 	tfrc_rx_hist_cleanup(&hcrx->ccid3hcrx_hist);
-
-	/* Empty loss interval history */
-	dccp_li_hist_purge(ccid3_li_hist, &hcrx->ccid3hcrx_li_hist);
+	tfrc_lh_cleanup(&hcrx->ccid3hcrx_li_hist);
 }
 
 static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
@@ -1001,22 +998,11 @@ static __init int ccid3_module_init(void
 	if (tfrc_tx_cache_init(&ccid3_tx_hist, "ccid3"))
 		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;
+		tfrc_tx_cache_cleanup(ccid3_tx_hist);
 out:
 	return rc;
-
-out_free_loss_interval_history:
-	dccp_li_hist_delete(ccid3_li_hist);
-	ccid3_li_hist = NULL;
-out_free_tx:
-	tfrc_tx_cache_cleanup(ccid3_tx_hist);
-	goto out;
 }
 module_init(ccid3_module_init);
 
@@ -1026,11 +1012,6 @@ static __exit void ccid3_module_exit(voi
 
 	if (ccid3_tx_hist != NULL)
 		tfrc_tx_cache_cleanup(ccid3_tx_hist);
-
-	if (ccid3_li_hist != NULL) {
-		dccp_li_hist_delete(ccid3_li_hist);
-		ccid3_li_hist = NULL;
-	}
 }
 module_exit(ccid3_module_exit);