From 7a84dabbbceea7cde175b1035e67603a6fbceb1a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 16 Sep 2014 11:07:36 -0700 Subject: [PATCH] scheduler: fix bug that broke enforcement of per-app job limits The old scheduler worked as follows: scan jobs; for each job get_app_version do various checks add_job_to_reply The check for per-app job limits was in get_app_version, and the incrementing of per-app job count is in add_job_to_reply. The new (score-based) scheduler works as follows: scan jobs; for each job get_app_version add to list sort list by score scan list; for each job do various checks add_job_to_reply So the limit check (in get_app_version) was ineffective because it happens before we've incremented counts. Fix: do the limit check (also) in the "scan list" loop. Bigger picture: we need to restructure app version selection; job limit enforcement doesn't belong there any more. --- sched/sched_score.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sched/sched_score.cpp b/sched/sched_score.cpp index 0eccc71f59..22a9e0dc93 100644 --- a/sched/sched_score.cpp +++ b/sched/sched_score.cpp @@ -234,13 +234,31 @@ void send_work_score_type(int rt) { bool sema_locked = false; for (unsigned int i=0; ineed_proc_type(rt)) { break; } JOB& job = jobs[i]; + + // check limits on jobs for this (app, processor type) + // + if (config.max_jobs_in_progress.exceeded(job.app, job.bavp->host_usage.proc_type)) { + if (config.debug_quota) { + log_messages.printf(MSG_NORMAL, + "[quota] limit for app/proctype exceeded\n" + ); + } + continue; + } + if (!sema_locked) { lock_sema(); sema_locked = true;