svn commit: r203766 - in projects/tcp_cc_head/sys: netinet vm
Lawrence Stewart
lstewart at FreeBSD.org
Thu Feb 11 02:56:06 UTC 2010
Author: lstewart
Date: Thu Feb 11 02:56:05 2010
New Revision: 203766
URL: http://svn.freebsd.org/changeset/base/203766
Log:
- Add public KPI functions to lookup a helper's ID based on its name and get a data block
based on an ID.
- Add a new skeleton UMA function to free all items currently allocated from a
zone. Doesn't do anything yet but hope to figure out how to make it work at
some point.
- Lot's of other tweaks as well.
Modified:
projects/tcp_cc_head/sys/netinet/h_ertt.c
projects/tcp_cc_head/sys/netinet/helper.c
projects/tcp_cc_head/sys/netinet/helper.h
projects/tcp_cc_head/sys/netinet/helper_module.h
projects/tcp_cc_head/sys/vm/uma.h
projects/tcp_cc_head/sys/vm/uma_core.c
Modified: projects/tcp_cc_head/sys/netinet/h_ertt.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/h_ertt.c Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/netinet/h_ertt.c Thu Feb 11 02:56:05 2010 (r203766)
@@ -74,9 +74,9 @@ void
ertt_tcpest_hook(void *udata, void *ctx_data, void *dblock)
{
//struct ertt *e = (struct ertt *)(((struct tcpcb *)inp->inp_ppcb)->helper_data[0]);
- struct ertt *e = (struct ertt *)dblock;
- printf("In the hook with errt->test: %d, ctx_data: %p, curack = %u\n",
- e->test, ctx_data, ((struct tcp_hhook_data *)ctx_data)->curack);
+ //struct ertt *e = (struct ertt *)dblock;
+ //printf("In the hook with errt->test: %d, ctx_data: %p, curack = %u\n",
+ //e->test, ctx_data, ((struct tcp_hhook_data *)ctx_data)->curack);
}
Modified: projects/tcp_cc_head/sys/netinet/helper.c
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper.c Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/netinet/helper.c Thu Feb 11 02:56:05 2010 (r203766)
@@ -112,8 +112,8 @@ destroy_helper_dblocks(struct helper_dbl
HELPER_LIST_WLOCK();
for (nblocks--; nblocks >= 0; nblocks--) {
- h = get_helper(dblocks[nblocks].id);
- uma_zfree(h->zone, dblocks[nblocks].block);
+ if ((h = get_helper(dblocks[nblocks].id)) != NULL)
+ uma_zfree(h->zone, dblocks[nblocks].block);
}
HELPER_LIST_WUNLOCK();
@@ -156,6 +156,33 @@ deregister_helper(struct helper *h)
return (0);
}
+int
+get_helper_id(char *hname)
+{
+ struct helper *h;
+ int id = -1;
+
+ HELPER_LIST_RLOCK();
+ STAILQ_FOREACH(h, &helpers, h_next) {
+ if (strncmp(h->name, hname, HELPER_NAME_MAXLEN) == 0) {
+ id = h->id;
+ break;
+ }
+ }
+ HELPER_LIST_RUNLOCK();
+ return (id);
+}
+
+void *
+get_helper_dblock(struct helper_dblock *dblocks, int nblocks, int id)
+{
+ for (nblocks--; nblocks >= 0; nblocks--) {
+ if (dblocks[nblocks].id == id)
+ return (dblocks[nblocks].block);
+ }
+ return (NULL);
+}
+
/*
* Private KPI functions.
*/
@@ -198,6 +225,8 @@ helper_modevent(module_t mod, int event_
break;
}
}
+ strlcpy(hmd->helper->name, hmd->name,
+ HELPER_NAME_MAXLEN);
if (hmd->helper->mod_init != NULL)
error = hmd->helper->mod_init();
if (!error)
@@ -206,6 +235,7 @@ helper_modevent(module_t mod, int event_
case MOD_QUIESCE:
error = deregister_helper(hmd->helper);
+ uma_zfree_all(hmd->helper->zone);
uma_zdestroy(hmd->helper->zone);
if (!error && hmd->helper->mod_destroy != NULL)
hmd->helper->mod_destroy();
Modified: projects/tcp_cc_head/sys/netinet/helper.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper.h Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/netinet/helper.h Thu Feb 11 02:56:05 2010 (r203766)
@@ -41,7 +41,9 @@ struct helper_dblock {
void *block;
};
+#define HELPER_NAME_MAXLEN 16
struct helper {
+ char name[HELPER_NAME_MAXLEN];
/* Init global module state on kldload. */
int (*mod_init) (void);
@@ -68,11 +70,12 @@ struct helper {
#define HELPER_CLASS_TCP 0x00000001
int init_helper_dblocks(struct helper_dblock **dblocks, int *nblocks);
-int destroy_helper_dblocks(struct helper_dblock *array_head, int nblocks);
+int destroy_helper_dblocks(struct helper_dblock *dblocks, int nblocks);
int register_helper(struct helper *h);
int deregister_helper(struct helper *h);
-/*struct helper_dblock * get_helper_dblock(struct helper_dblock *array_head, int
-id);*/
+int get_helper_id(char *hname);
+void * get_helper_dblock(struct helper_dblock *dblocks,
+ int nblocks, int id);
#define HELPER_LIST_WLOCK() rw_wlock(&helper_list_lock)
#define HELPER_LIST_WUNLOCK() rw_wunlock(&helper_list_lock)
Modified: projects/tcp_cc_head/sys/netinet/helper_module.h
==============================================================================
--- projects/tcp_cc_head/sys/netinet/helper_module.h Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/netinet/helper_module.h Thu Feb 11 02:56:05 2010 (r203766)
@@ -34,7 +34,7 @@
#define _NETINET_HELPER_MODULE_H_
struct helper_modevent_data {
- char *name;
+ char name[HELPER_NAME_MAXLEN];
struct helper *helper;
int uma_zsize;
uma_ctor umactor;
Modified: projects/tcp_cc_head/sys/vm/uma.h
==============================================================================
--- projects/tcp_cc_head/sys/vm/uma.h Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/vm/uma.h Thu Feb 11 02:56:05 2010 (r203766)
@@ -306,6 +306,14 @@ uma_zalloc(uma_zone_t zone, int flags)
}
/*
+ * Frees all items currently allocated back into the specified zone.
+ *
+ * Arguments:
+ * zone The zone free all currently allocated items from.
+ */
+void uma_zfree_all(uma_zone_t zone);
+
+/*
* Frees an item back into the specified zone.
*
* Arguments:
Modified: projects/tcp_cc_head/sys/vm/uma_core.c
==============================================================================
--- projects/tcp_cc_head/sys/vm/uma_core.c Wed Feb 10 20:35:20 2010 (r203765)
+++ projects/tcp_cc_head/sys/vm/uma_core.c Thu Feb 11 02:56:05 2010 (r203766)
@@ -2315,6 +2315,9 @@ slab_alloc_item(uma_zone_t zone, uma_sla
}
item = slab->us_data + (keg->uk_rsize * freei);
+ //printf("slab_alloc_item() slab %p us_freecount: %d\n", slab,
+ //slab->us_freecount);
+
slab->us_freecount--;
keg->uk_free--;
#ifdef INVARIANTS
@@ -2676,6 +2679,36 @@ zfree_internal:
return;
}
+void
+uma_zfree_all(uma_zone_t zone)
+{
+ uma_klink_t kl;
+ uma_slab_t slab;
+
+ printf("zone->uz_count: %d\n", zone->uz_count);
+
+ ZONE_LOCK(zone);
+ LIST_FOREACH(kl, &zone->uz_kegs, kl_link) {
+ printf("keg %s (%p) uk_free: %d\n", kl->kl_keg->uk_name,
+ kl->kl_keg, kl->kl_keg->uk_free);
+
+ LIST_FOREACH(slab, &kl->kl_keg->uk_part_slab, us_link) {
+ printf("partially full slab %p us_freecount: %d, firstfree: %d\n",
+ slab, slab->us_freecount, slab->us_firstfree);
+
+ }
+ LIST_FOREACH(slab, &kl->kl_keg->uk_full_slab, us_link) {
+ printf("full slab %p us_freecount: %d\n",
+ slab, slab->us_freecount);
+ }
+ LIST_FOREACH(slab, &kl->kl_keg->uk_free_slab, us_link) {
+ printf("free slab %p us_freecount: %d\n",
+ slab, slab->us_freecount);
+ }
+ }
+ ZONE_UNLOCK(zone);
+}
+
/*
* Frees an item to an INTERNAL zone or allocates a free bucket
*
More information about the svn-src-projects
mailing list