From 12d4b978be3c9d837d43df6f051d048a74d9d776 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 18 Aug 2009 20:44:12 +0000 Subject: [PATCH] - scheduler: if client request uses a weak authenticator, don't modify user preferences or CPID. - client: fix bug that shows ATI version incorrectly - database: host.posts has been repurposed as a salt (or seqno) for a new type of weak authenticator that won't depend on password - web code: modify forum_preferences.posts instead of host.posts. (actually, the former isn't used either, we just do a select count(*); should fix this at some point). svn path=/trunk/boinc/; revision=18865 --- checkin_notes | 27 +++++++++++++++++++++++ client/cpu_sched.cpp | 45 +++++++++++++++++++++++++++++++-------- db/boinc_db.h | 3 +-- db/schema.sql | 2 +- doc/boinc_news.php | 4 ++++ html/inc/forum.inc | 2 +- html/ops/forum_repair.php | 5 +++-- lib/coproc.cpp | 4 ++-- sched/handle_request.cpp | 10 ++++----- sched/sched_types.h | 4 ++++ 10 files changed, 84 insertions(+), 22 deletions(-) diff --git a/checkin_notes b/checkin_notes index c11b80f7ac..af86a07982 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6971,3 +6971,30 @@ David 17 Aug 2009 lib/ gui_rpc_client.h gui_rpc_client_ops.cpp + +David 18 Aug 2009 + - scheduler: if client request uses a weak authenticator, + don't modify user preferences or CPID. + - client: fix bug that shows ATI version incorrectly + - database: host.posts has been repurposed as a salt (or seqno) + for a new type of weak authenticator that won't depend on password + - web code: + modify forum_preferences.posts instead of host.posts. + (actually, the former isn't used either, we just do a select count(*); + should fix this at some point). + + client/ + cpu_sched.cpp + db/ + boinc_db.h + schema.sql + html/ + inc/ + forum.inc + ops/ + forum_repair.php + lib/ + coproc.pp + sched/ + handle_request.cpp + sched_types.h diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index ecf8d61688..cd1669bb49 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -740,8 +740,8 @@ static inline bool in_ordered_scheduled_results(ACTIVE_TASK* atp) { static inline bool more_important(RESULT* r0, RESULT* r1) { // favor jobs in danger of deadline miss // - bool miss0 = r0->rr_sim_misses_deadline; - bool miss1 = r1->rr_sim_misses_deadline; + bool miss0 = r0->edf_scheduled; + bool miss1 = r1->edf_scheduled; if (miss0 && !miss1) return true; if (!miss0 && miss1) return false; @@ -790,7 +790,7 @@ static void print_job_list(vector& jobs, bool details) { msg_printf(rp->project, MSG_INFO, "[cpu_sched_debug] %d: %s (MD: %s; UTS: %s)", i, rp->name, - rp->rr_sim_misses_deadline?"yes":"no", + rp->edf_scheduled?"yes":"no", rp->unfinished_time_slice?"yes":"no" ); } @@ -923,15 +923,40 @@ bool CLIENT_STATE::enforce_schedule() { // Loop through the jobs we want to schedule. // ncpus_used = 0; + bool running_edf_scheduled_job = false; for (i=0; iuses_coprocs() && (ncpus_used >= ncpus)) { - if (log_flags.cpu_sched_debug) { - msg_printf(rp->project, MSG_INFO, - "[cpu_sched_debug] all CPUs used, skipping %s", rp->name - ); + + // decide if we're already using too many CPUs to run this job + // + if (!rp->uses_coprocs()) { + if (running_edf_scheduled_job) { + // if we're running an EDF job, + // don't use more than 150% of #CPUs. + // + double x = ncpus_used + rp->avp->avg_ncpus; + if (x > 1.5001*ncpus) { + if (log_flags.cpu_sched_debug) { + msg_printf(rp->project, MSG_INFO, + "[cpu_sched_debug] have EDF job, %s would oversaturate CPUs, skipping", + rp->name + ); + } + continue; + } + } else { + // Otherwise saturate CPUs. + // + if (ncpus_used >= ncpus) { + if (log_flags.cpu_sched_debug) { + msg_printf(rp->project, MSG_INFO, + "[cpu_sched_debug] all CPUs used, skipping %s", + rp->name + ); + } + continue; + } } - continue; } atp = lookup_active_task_by_result(rp); @@ -949,6 +974,8 @@ bool CLIENT_STATE::enforce_schedule() { } } + if (rp->edf_scheduled) running_edf_scheduled_job = true; + if (log_flags.cpu_sched_debug) { msg_printf(rp->project, MSG_INFO, "[cpu_sched_debug] scheduling %s", rp->name diff --git a/db/boinc_db.h b/db/boinc_db.h index dc0db9cb63..10cf838384 100644 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -155,8 +155,7 @@ struct USER { bool show_hosts; int posts; // number of messages posted (redundant) // deprecated as of 9/2004 - forum_preferences.posts is used instead - // may be used as a temp var - // WARNING: it's a shortint (16 bits) in the DB + // now used as salt for weak auth // The following are specific to SETI@home; // they record info about the user's involvement in a prior project diff --git a/db/schema.sql b/db/schema.sql index 9c21778284..f15493ad71 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -85,7 +85,7 @@ create table user ( send_email smallint not null, show_hosts smallint not null, posts smallint not null, - -- deprecated + -- reused: salt for weak auth seti_id integer not null, seti_nresults integer not null, seti_last_result_time integer not null, diff --git a/doc/boinc_news.php b/doc/boinc_news.php index 961bc2fed3..8266f0fe77 100644 --- a/doc/boinc_news.php +++ b/doc/boinc_news.php @@ -1,6 +1,10 @@ an article in The Sydney Morning Herald + about volunteer computing in Australia." +), array("August 3, 2009", "Intel (in partnership with GridRepublic and BOINC) announces Progress Thru Processors, diff --git a/html/inc/forum.inc b/html/inc/forum.inc index d0d05390a0..83752d6a4a 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -792,7 +792,7 @@ function create_post($content, $parent_id, $user, $forum, $thread, $signature) { notify_subscriber($thread, $user2); } } - $user->update("posts=posts+1"); + $user->prefs->update("posts=posts+1"); $thread->update("replies=replies+1, timestamp=$now"); $forum->update("posts=posts+1, timestamp=$now"); } diff --git a/html/ops/forum_repair.php b/html/ops/forum_repair.php index a90fad248d..91afd2ccdf 100644 --- a/html/ops/forum_repair.php +++ b/html/ops/forum_repair.php @@ -43,10 +43,11 @@ function update_thread_timestamps() { function update_user_posts() { $users = BoincUser::enum(); foreach ($users as $user) { + BoincForumPrefs::lookup($user); $num = BoincPost::count("user=$user->id"); - if ($num != $user->posts) { + if ($num != $user->prefs->posts) { echo "user $user->id: $user->posts $num\n"; - $user->update("posts=$num"); + $user->prefs->update("posts=$num"); } } } diff --git a/lib/coproc.cpp b/lib/coproc.cpp index ccfa94a9d2..80e27dd4b8 100644 --- a/lib/coproc.cpp +++ b/lib/coproc.cpp @@ -618,7 +618,7 @@ void COPROC_ATI::get(COPROCS& coprocs, vector& strings) { (*__calInit)(); (*__calDeviceGetCount)(&numDevices); - (*__calGetVersion)(&cal_major,&cal_minor,&cal_imp); + (*__calGetVersion)(&cal_major, &cal_minor, &cal_imp); if (!numDevices) { strings.push_back("No usable CAL devices found"); @@ -644,6 +644,7 @@ void COPROC_ATI::get(COPROCS& coprocs, vector& strings) { } cc.attribs = attribs; strcpy(cc.name, gpu_name.c_str()); + sprintf(cc.version, "%d.%d.%d", cal_major, cal_minor, cal_imp); cc.device_num = i; gpus.push_back(cc); } @@ -666,7 +667,6 @@ void COPROC_ATI::get(COPROCS& coprocs, vector& strings) { COPROC_ATI* ccp = new COPROC_ATI; *ccp = best; - sprintf(ccp->version, "%d.%d.%d", cal_major, cal_minor, cal_imp); strcpy(ccp->type, "ATI"); ccp->count = numDevices; coprocs.coprocs.push_back(ccp); diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp index 95eadd7d9b..2e51e6008b 100644 --- a/sched/handle_request.cpp +++ b/sched/handle_request.cpp @@ -270,25 +270,25 @@ int authenticate_user() { // look up user based on the ID in host record, // and see if the authenticator matches (regular or weak) // + g_request->using_weak_auth = false; sprintf(buf, "where id=%d", host.userid); retval = user.lookup(buf); if (!retval && !strcmp(user.authenticator, g_request->authenticator)) { // req auth matches user auth - go on } else { - bool weak_auth = false; if (!retval) { // user for host.userid exists - check weak auth // get_weak_auth(user, buf); if (!strcmp(buf, g_request->authenticator)) { - weak_auth = true; + g_request->using_weak_auth = true; log_messages.printf(MSG_DEBUG, "[HOST#%d] accepting weak authenticator\n", host.id ); } } - if (!weak_auth) { + if (!g_request->using_weak_auth) { // weak auth failed - look up user based on authenticator // strlcpy( @@ -478,7 +478,7 @@ got_host: // if new user CPID, update user record // - if (strlen(g_request->cross_project_id)) { + if (!g_request->using_weak_auth && strlen(g_request->cross_project_id)) { if (strcmp(g_request->cross_project_id, g_reply->user.cross_project_id)) { user.id = g_reply->user.id; escape_string(g_request->cross_project_id, sizeof(g_request->cross_project_id)); @@ -743,7 +743,7 @@ int handle_global_prefs() { // decide whether to update DB // - if (have_master_prefs) { + if (!g_request->using_weak_auth && have_master_prefs) { bool update_user_record = false; if (have_db_prefs) { if (master_mod_time > db_mod_time && same_account) { diff --git a/sched/sched_types.h b/sched/sched_types.h index eeb0774824..cffc59e9eb 100644 --- a/sched/sched_types.h +++ b/sched/sched_types.h @@ -395,6 +395,10 @@ struct SCHEDULER_REQUEST { bool client_cap_plan_class; int sandbox; // -1 = don't know + bool using_weak_auth; + // Request uses weak authenticator. + // Don't modify user prefs or CPID + SCHEDULER_REQUEST(); ~SCHEDULER_REQUEST(); const char* parse(FILE*);