]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Allow specification of the local CPU ID using environment variable
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 20 May 2010 13:05:28 +0000 (15:05 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 20 May 2010 13:05:28 +0000 (15:05 +0200)
frsh_api/frsh_core.c
resources/cpu_aquosa/lib/aqcpu_fra.c
resources/cpu_aquosa/mngr/frm_aqcpu.c
resources/cpucg/lib/cpucg_fra.c
resources/cpucg/mngr/frm_cgcpu.c

index 111bd76fe3d5592ca5a9011d96464abaf03a452d..9b163e75609d5ec597c3e3b9320fe28a0a76477d 100644 (file)
@@ -164,3 +164,15 @@ bool frsh_config_is_admission_test_enabled()
        return true;
 }
 
+frsh_resource_id_t frsh_get_local_cpu_id(void)
+{
+       frsh_resource_id_t id;
+       long int ret =  FRSH_CPU_ID_DEFAULT;
+       if (getenv("FRSH_CPU_ID")) {
+               errno = 0;      /* See strtol(1) */
+               ret = strtol(getenv("FRSH_CPU_ID"), NULL, 10);
+               if (errno != 0)
+                       ret = FRSH_CPU_ID_DEFAULT;
+       }
+       return ret;
+}
index 34c7943f1dad9866e71f2829370679cd41f981dd..2c6a9a53a5dc2425e58d512a40574a6c03c57709 100644 (file)
@@ -443,6 +443,8 @@ int aqcpu_fra_init(void)
 {
        int rv;
 
+       aqcpu_allocator.res_id = frsh_get_local_cpu_id();
+               
        if ((rv = fra_register(&aqcpu_allocator))) {
                return rv;
        }
index 743c960795ff429a65c26492f957ab840affa3ab..fe657590c5126fa3a07f9ef93290ec7d76009d10 100644 (file)
@@ -99,7 +99,7 @@ static int aqcpu_admtest(struct fres_sa_scenario *scenario, void *priv,
        return 0;
 }
 
-static const struct fres_res_manager frm = {
+static struct fres_res_manager frm = {
        .res_type = FRSH_RT_PROCESSOR,
        .res_id = FRSH_CPU_ID_DEFAULT,
        .admission_test = aqcpu_admtest,
@@ -142,7 +142,8 @@ int main(int argc, char *argv[])
        
        orb = forb_init(&argc, &argv, &attr);
        if (!orb) error(1, errno, "forb_init");
-       
+
+       frm.res_id = frsh_get_local_cpu_id();
        ret = frm_register_and_run(orb, &frm);
 
        if (ret != 0) {
index cd1da37afc7ea2a9a4594f479beede53836331f8..c01304e30fb616a5ded62ded550487fc895756c3 100644 (file)
@@ -360,6 +360,8 @@ int cpucg_fra_init(void)
 {
        int rv;
 
+       cpucg_allocator.res_id = frsh_get_local_cpu_id();
+
        if ((rv = fra_register(&cpucg_allocator))) {
                return rv;
        }
index 827b3d2110a8caede3466dceb14304dd6524949a..57d01195c680b902c843acd83fad6a76621c6491 100644 (file)
@@ -64,6 +64,7 @@
 #include <ul_log.h>
 #include <ul_logreg.h>
 #include <stdio.h>
+#include <frsh_core.h>
 
 UL_LOG_CUST(ulogd_frm_cpucg);
 ul_log_domain_t ulogd_frm_cpucg = {UL_LOGL_DEB, "frm_cpucg"};
@@ -106,7 +107,7 @@ static int cpucg_admtest(struct fres_sa_scenario *scenario, void *priv,
        return 0;
 }
 
-static const struct fres_res_manager frm = {
+static struct fres_res_manager frm = {
        .res_type = FRSH_RT_PROCESSOR,
        .res_id = 0,
        .name = "cgroup",
@@ -171,6 +172,7 @@ int main(int argc, char *argv[])
        }
        fclose(fd);
        
+       frm.res_id = frsh_get_local_cpu_id();
        ret = frm_register_and_run(orb, &frm);
        if (ret != 0) {
                error(1, errno, "frm_generic_run");