svn commit: r186893 - in user/luigi/geom_sched/sys: geom geom/sched
i386/conf sys
Luigi Rizzo
luigi at FreeBSD.org
Thu Jan 8 04:10:12 PST 2009
Author: luigi
Date: Thu Jan 8 12:10:11 2009
New Revision: 186893
URL: http://svn.freebsd.org/changeset/base/186893
Log:
1. restore original structure for struct bio -- now the classification
info is stored by g_io_request() in the bio_caller1 field in the
first bio of the geom chain.
2. create a DISKLESS configuration for tests
Added:
user/luigi/geom_sched/sys/i386/conf/DISKLESS
user/luigi/geom_sched/sys/i386/conf/DISKLESS.env
Modified:
user/luigi/geom_sched/sys/geom/geom_io.c
user/luigi/geom_sched/sys/geom/sched/g_as.c
user/luigi/geom_sched/sys/geom/sched/g_gsched.h
user/luigi/geom_sched/sys/geom/sched/g_rr.c
user/luigi/geom_sched/sys/geom/sched/gs_as.c
user/luigi/geom_sched/sys/geom/sched/gs_rr.c
user/luigi/geom_sched/sys/sys/bio.h
Modified: user/luigi/geom_sched/sys/geom/geom_io.c
==============================================================================
--- user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 12:10:11 2009 (r186893)
@@ -172,7 +172,6 @@ g_clone_bio(struct bio *bp)
bp2->bio_offset = bp->bio_offset;
bp2->bio_data = bp->bio_data;
bp2->bio_attribute = bp->bio_attribute;
- bp2->bio_thread = bp->bio_thread;
bp->bio_children++;
}
#ifdef KTR
@@ -370,9 +369,19 @@ g_io_request(struct bio *bp, struct g_co
bp->bio_error = 0;
bp->bio_completed = 0;
- /* Pass down the thread that issued the bio. */
- if (bp->bio_thread == NULL)
- bp->bio_thread = curthread;
+ /*
+ * Scheduler support: if this is the first element in the geom
+ * chain (we know from bp->bio_parent == NULL), store
+ * the thread that originated the request in bp->bio_caller1,
+ * which should be unused in this particular entry (at least
+ * with the code in 7.1/8.0).
+ */
+ if (bp->bio_parent == NULL) {
+ if (bp->bio_caller1 != NULL)
+ printf("unexpected bio_caller1 %p\n", bp->bio_caller1);
+ else
+ bp->bio_caller1 = (void *)curthread->td_tid;
+ }
KASSERT(!(bp->bio_flags & BIO_ONQUEUE),
("Bio already on queue bp=%p", bp));
Modified: user/luigi/geom_sched/sys/geom/sched/g_as.c
==============================================================================
--- user/luigi/geom_sched/sys/geom/sched/g_as.c Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/sched/g_as.c Thu Jan 8 12:10:11 2009 (r186893)
@@ -49,7 +49,7 @@
struct g_as_softc {
struct g_geom *sc_geom;
- struct thread *sc_curthread;
+ u_long sc_curkey;
int sc_status;
long sc_batch;
@@ -76,7 +76,7 @@ g_as_dispatch(struct g_as_softc *sc)
* scheduler starve other threads while an aggressive one
* is making continuously new requests.
*/
- sc->sc_curthread = NULL;
+ sc->sc_curkey = 0;
bio = bioq_takefirst(&sc->sc_bioq);
if (bio != NULL) {
@@ -130,7 +130,7 @@ g_as_start(void *data, struct bio *bio)
* stop the timer and dispatch it, otherwise do nothing.
*/
if (sc->sc_status == G_AS_NOWAIT ||
- bio->bio_thread == sc->sc_curthread) {
+ g_sched_classify(bio) == sc->sc_curkey) {
callout_stop(&sc->sc_wait);
g_as_dispatch(sc);
}
@@ -152,7 +152,7 @@ g_as_done(void *data, struct bio *bio)
/*
* Start waiting for a new request from curthread.
*/
- sc->sc_curthread = bio->bio_thread;
+ sc->sc_curkey = g_sched_classify(bio);
sc->sc_status = G_AS_WAITING;
callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE,
g_as_wait_timeout, sc);
@@ -172,7 +172,7 @@ g_as_init(struct g_geom *geom)
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
sc->sc_geom = geom;
- sc->sc_curthread = NULL;
+ sc->sc_curkey = 0;
sc->sc_status = G_AS_NOWAIT;
callout_init(&sc->sc_wait, CALLOUT_MPSAFE);
Modified: user/luigi/geom_sched/sys/geom/sched/g_gsched.h
==============================================================================
--- user/luigi/geom_sched/sys/geom/sched/g_gsched.h Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/sched/g_gsched.h Thu Jan 8 12:10:11 2009 (r186893)
@@ -70,6 +70,27 @@ void g_sched_lock(struct g_geom *gp);
void g_sched_unlock(struct g_geom *gp);
/*
+ * Lookup the identity of the issuer of the original request.
+ * In the current implementation we use the curthread of the
+ * issuer, but different mechanisms may be implemented later
+ * so we do not make assumptions on the return value which for
+ * us is just an opaque identifier.
+ * For the time being we make this inline.
+ */
+static inline
+u_long g_sched_classify(struct bio *bp)
+{
+
+ if (bp == NULL) {
+ printf("g_sched_classify: NULL bio\n");
+ return (0); /* as good as anything */
+ }
+ while (bp->bio_parent != NULL)
+ bp = bp->bio_parent;
+ return ((u_long)(bp->bio_caller1));
+}
+
+/*
* Declaration of a scheduler module.
*/
int g_gsched_modevent(module_t mod, int cmd, void *arg);
Modified: user/luigi/geom_sched/sys/geom/sched/g_rr.c
==============================================================================
--- user/luigi/geom_sched/sys/geom/sched/g_rr.c Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/sched/g_rr.c Thu Jan 8 12:10:11 2009 (r186893)
@@ -58,7 +58,6 @@ struct g_rr_queue {
int q_refs;
int q_status;
u_long q_key;
- struct proc *q_proc;
struct bio_queue_head q_bioq;
unsigned int q_service;
@@ -94,13 +93,6 @@ struct g_rr_softc {
struct callout sc_wait;
};
-static inline u_long
-g_rr_key(struct thread *tp)
-{
-
- return (tp != NULL ? tp->td_tid : 0);
-}
-
/* Return the hash chain for the given key. */
static inline struct g_hash *
g_rr_hash(struct g_rr_softc *sc, u_long key)
@@ -114,13 +106,11 @@ g_rr_hash(struct g_rr_softc *sc, u_long
* it if necessary.
*/
static struct g_rr_queue *
-g_rr_queue_get(struct g_rr_softc *sc, struct thread *tp)
+g_rr_queue_get(struct g_rr_softc *sc, u_long key)
{
struct g_hash *bucket;
struct g_rr_queue *qp;
- u_long key;
- key = g_rr_key(tp);
bucket = g_rr_hash(sc, key);
LIST_FOREACH(qp, bucket, q_hash) {
if (qp->q_key == key) {
@@ -136,7 +126,6 @@ g_rr_queue_get(struct g_rr_softc *sc, st
qp->q_refs = 2;
qp->q_key = key;
- qp->q_proc = tp->td_proc;
bioq_init(&qp->q_bioq);
qp->q_budget = G_RR_DEFAULT_BUDGET;
LIST_INSERT_HEAD(bucket, qp, q_hash);
@@ -265,7 +254,7 @@ g_rr_start(void *data, struct bio *bp)
sc = data;
/* Get the queue for the thread that issued the request. */
- qp = g_rr_queue_get(sc, bp->bio_thread);
+ qp = g_rr_queue_get(sc, g_sched_classify(bp));
if (qp == NULL) {
g_io_request(bp, LIST_FIRST(&sc->sc_geom->consumer));
return;
Modified: user/luigi/geom_sched/sys/geom/sched/gs_as.c
==============================================================================
--- user/luigi/geom_sched/sys/geom/sched/gs_as.c Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/sched/gs_as.c Thu Jan 8 12:10:11 2009 (r186893)
@@ -50,7 +50,7 @@
struct gs_as_softc {
struct disk *sc_disk;
- struct thread *sc_curthread;
+ u_long sc_curkey;
int sc_status;
long sc_batch;
@@ -83,7 +83,7 @@ gs_as_next(void *data, int force)
* scheduler starve other threads while an aggressive one
* is making continuously new requests.
*/
- sc->sc_curthread = NULL;
+ sc->sc_curkey = NULL;
bio = bioq_takefirst(&sc->sc_bioq);
if (bio != NULL) {
@@ -123,7 +123,7 @@ gs_as_wait_timeout(void *data)
mtx_lock(&dp->d_sched_lock);
/*
- * We were waiting for a new request for curthread, it did
+ * We were waiting for a new request for curkey, it did
* not come, just dispatch the next one.
*/
if (sc->sc_status == G_AS_WAITING)
@@ -148,7 +148,7 @@ gs_as_start(void *data, struct bio *bio)
* stop the timer and dispatch it, otherwise do nothing.
*/
if (sc->sc_status == G_AS_NOWAIT ||
- bio->bio_thread == sc->sc_curthread) {
+ g_sched_classify(bio) == sc->sc_curkey) {
callout_stop(&sc->sc_wait);
sc->sc_status = G_AS_NOWAIT;
}
@@ -164,7 +164,8 @@ gs_as_done(void *data, struct bio *bio)
if (sc->sc_status == G_AS_WAITREQ) {
next = bioq_first(&sc->sc_bioq);
- if (next != NULL && next->bio_thread == bio->bio_thread) {
+ if (next != NULL &&
+ g_sched_classify(next) == g_sched_classify(bio)) {
/*
* Don't wait if the current thread already
* has pending requests. This is not complete,
@@ -177,11 +178,11 @@ gs_as_done(void *data, struct bio *bio)
}
/* Start waiting for a new request from curthread. */
- sc->sc_curthread = bio->bio_thread;
+ sc->sc_curkey = g_sched_classify(bio);
sc->sc_status = G_AS_WAITING;
callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE,
gs_as_wait_timeout, sc);
- G_SCHED_DEBUG(2, "gs_as: waiting for %p", sc->sc_curthread);
+ G_SCHED_DEBUG(2, "gs_as: waiting for %lu", sc->sc_curkey);
return (0);
}
@@ -196,7 +197,7 @@ gs_as_init(struct disk *dp)
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
sc->sc_disk = dp;
- sc->sc_curthread = NULL;
+ sc->sc_curkey = 0;
sc->sc_status = G_AS_NOWAIT;
callout_init(&sc->sc_wait, CALLOUT_MPSAFE);
Modified: user/luigi/geom_sched/sys/geom/sched/gs_rr.c
==============================================================================
--- user/luigi/geom_sched/sys/geom/sched/gs_rr.c Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/geom/sched/gs_rr.c Thu Jan 8 12:10:11 2009 (r186893)
@@ -61,7 +61,6 @@ struct gs_rr_queue {
int q_refs;
int q_status;
u_long q_key;
- struct proc *q_proc;
struct bio_queue_head q_bioq;
unsigned int q_service;
@@ -99,13 +98,6 @@ struct gs_rr_softc {
struct callout sc_wait;
};
-static inline u_long
-gs_rr_key(struct thread *tp)
-{
-
- return (tp != NULL ? tp->td_tid : 0);
-}
-
/* Return the hash chain for the given key. */
static inline struct gs_hash *
gs_rr_hash(struct gs_rr_softc *sc, u_long key)
@@ -119,13 +111,11 @@ gs_rr_hash(struct gs_rr_softc *sc, u_lon
* it if necessary.
*/
static struct gs_rr_queue *
-gs_rr_queue_get(struct gs_rr_softc *sc, struct thread *tp)
+gs_rr_queue_get(struct gs_rr_softc *sc, u_long key)
{
struct gs_hash *bucket;
struct gs_rr_queue *qp, *new_qp;
- u_long key;
- key = gs_rr_key(tp);
new_qp = NULL;
bucket = gs_rr_hash(sc, key);
retry:
@@ -159,7 +149,6 @@ retry:
new_qp->q_refs = 2;
new_qp->q_key = key;
- new_qp->q_proc = tp->td_proc;
bioq_init(&new_qp->q_bioq);
new_qp->q_budget = G_RR_DEFAULT_BUDGET;
LIST_INSERT_HEAD(bucket, new_qp, q_hash);
@@ -238,7 +227,7 @@ gs_rr_start(void *data, struct bio *bp)
sc = data;
/* Get the queue for the thread that issued the request. */
- qp = gs_rr_queue_get(sc, bp->bio_thread);
+ qp = gs_rr_queue_get(sc, g_sched_classify(bp));
if (bioq_first(&qp->q_bioq) == NULL) {
/* We're inserting into an empty queue... */
if (qp == sc->sc_active) {
Added: user/luigi/geom_sched/sys/i386/conf/DISKLESS
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/luigi/geom_sched/sys/i386/conf/DISKLESS Thu Jan 8 12:10:11 2009 (r186893)
@@ -0,0 +1,25 @@
+#
+# $FreeBSD: src/sys/i386/conf/DISKLESS,v 1.474.2.14 2008/08/29 18:54:35 jhb Exp $
+
+include "GENERIC"
+ident DISKLESS
+
+# Make some environment vars available
+env "DISKLESS.env"
+
+# To statically compile in device wiring instead of /boot/device.hints
+hints "GENERIC.hints" # Default places to look for devices.
+
+# make sure we start with an open firewall
+options IPFIREWALL
+options IPFIREWALL_DEFAULT_TO_ACCEPT
+options IPDIVERT
+options DUMMYNET
+
+# added against GENERIC
+options BOOTP
+options BOOTP_NFSROOT
+options BOOTP_COMPAT
+options INCLUDE_CONFIG_FILE # Include this file in kernel
+options KDB
+options DDB
Added: user/luigi/geom_sched/sys/i386/conf/DISKLESS.env
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/luigi/geom_sched/sys/i386/conf/DISKLESS.env Thu Jan 8 12:10:11 2009 (r186893)
@@ -0,0 +1,2 @@
+# you can put here env/kenv variables
+# machdep.bios.pnp=disable
Modified: user/luigi/geom_sched/sys/sys/bio.h
==============================================================================
--- user/luigi/geom_sched/sys/sys/bio.h Thu Jan 8 11:09:27 2009 (r186892)
+++ user/luigi/geom_sched/sys/sys/bio.h Thu Jan 8 12:10:11 2009 (r186893)
@@ -42,7 +42,6 @@
struct disk;
struct bio;
-struct thread;
typedef void bio_task_t(void *);
@@ -79,9 +78,6 @@ struct bio {
bio_task_t *bio_task; /* Task_queue handler */
void *bio_task_arg; /* Argument to above */
-
- struct thread *bio_thread; /* Thread that issued the request */
-
#ifdef DIAGNOSTIC
void *_bio_caller1;
void *_bio_caller2;
More information about the svn-src-user
mailing list