Commit a0021e16 authored by Jonathan Jenkins's avatar Jonathan Jenkins

add iface/impl for LSM req priorities

parent 75ba7b7e
......@@ -97,6 +97,23 @@ void lsm_event_new_reverse(tw_lp *sender);
*/
void* lsm_event_data(tw_event *event);
/* get the priority count for the LSM scheduler.
* returns 0 if priorities aren't being used, -1 if no LSMs were configured,
* and >0 otherwise.
* This should not be called before lsm_configure */
int lsm_get_num_priorities(
char const * annotation,
int ignore_annotations);
/* set a request priority for the following lsm_event_*.
* - tw_error will be called if the priority ends up being out-of-bounds
* (won't able to tell until the lsm_event call b/c annotations)
* - not setting a priority (or setting a negative priority) is equivalent to
* setting the message to the lowest priority
*/
void lsm_set_event_priority(int prio);
/* registers the storage model LP with CODES/ROSS */
void lsm_register(void);
......
......@@ -174,6 +174,9 @@ static int lsm_magic = 0;
static disk_model_t model_unanno, *models_anno = NULL;
static const config_anno_map_t *anno_map = NULL;
/* sched temporary for lsm_set_event_priority */
static int temp_prio = -1;
/*
* lsm_lp
* - implements ROSS callback interfaces
......@@ -336,7 +339,22 @@ static tw_event* lsm_event_new_base(
m->data.offset = io_offset;
m->data.size = io_size_bytes;
strcpy(m->data.category, category);
m->data.prio = 0; // TODO
// get the priority count for checking
int num_prios = lsm_get_num_priorities(annotation, ignore_annotations);
// prio checks and sets
if (num_prios <= 0) // disabled scheduler - ignore
m->data.prio = 0;
else if (temp_prio < 0) // unprovided priority - defer to max possible
m->data.prio = num_prios-1;
else if (temp_prio < num_prios) // valid priority
m->data.prio = temp_prio;
else
tw_error(TW_LOC,
"LP %lu, LSM LP %lu: Bad priority (%d supplied, %d lanes)\n",
sender->gid, dest_gid, temp_prio, num_prios);
// reset temp_prio
temp_prio = -1;
/* save callers dest_gid and message size */
m->wrap.id = dest_gid;
......@@ -407,6 +425,41 @@ void* lsm_event_data(tw_event *event)
return m->wrap.message;
}
int lsm_get_num_priorities(
char const * annotation,
int ignore_annotations)
{
if (ignore_annotations) {
/* find the first valid model
* (unannotated if listed first, annotated otherwise) */
if (anno_map->is_unanno_first)
return model_unanno.use_sched;
else if (anno_map->num_annos)
return models_anno->use_sched;
else
return -1;
}
else if (annotation == NULL) {
if (anno_map->has_unanno_lp)
return model_unanno.use_sched;
else
return -1;
}
else {
for (int i = 0; i < anno_map->num_annos; i++) {
if (strcmp(anno_map->annotations[i], annotation) == 0)
return models_anno[i].use_sched;
}
// bad annotation
return -1;
}
}
void lsm_set_event_priority(int prio)
{
temp_prio = prio;
}
/*
* lsm_lp_init
* - initialize the lsm model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment