[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v1 4/4] xl: enabling XL to set per-VCPU parameters of a domain for RTDS scheduler



> @@ -5744,6 +5749,7 @@ static int sched_rtds_pool_output(uint32_t poolid)
>      return 0;
>  }
>
> +
>  static int sched_default_pool_output(uint32_t poolid)
>  {
>      char *poolname;
> @@ -6120,38 +6126,87 @@ int main_sched_rtds(int argc, char **argv)
>  {
>      const char *dom = NULL;
>      const char *cpupool = NULL;
> -    int period = 0; /* period is in microsecond */
> -    int budget = 0; /* budget is in microsecond */
> +
> +    int vcpus[LIBXL_XEN_LEGACY_MAX_VCPUS]; /* indices of VCPUs that change */
> +    int periods[LIBXL_XEN_LEGACY_MAX_VCPUS]; /* period is in microsecond */
> +    int budgets[LIBXL_XEN_LEGACY_MAX_VCPUS]; /* budget is in microsecond */


We know this is not good (ugly), but not sure about the best approach
to do this. Basically, if users tries to input several pairs of period
and budget, what is the best way to hold those data? Should we just
increase the array size by using something like remalloc when we find
more parameters are inputted?


> +    int index=0; /*index of the arrays above*/
> +    bool flag_b = false;
> +    bool flag_p = false;
> +    bool flag_v = false;
>      bool opt_p = false;
>      bool opt_b = false;
> -    int opt, rc;
> +    bool opt_v = false;
> +    int opt, rc, i;
>      static struct option opts[] = {
>          {"domain", 1, 0, 'd'},
>          {"period", 1, 0, 'p'},
>          {"budget", 1, 0, 'b'},
> +        {"vcpu",1, 0, 'v'},
>          {"cpupool", 1, 0, 'c'},
>          COMMON_LONG_OPTS,
>          {0, 0, 0, 0}
>      };
>
> -    SWITCH_FOREACH_OPT(opt, "d:p:b:c:h", opts, "sched-rtds", 0) {
> +    SWITCH_FOREACH_OPT(opt, "d:p:b:v:c:h", opts, "sched-rtds", 0) {
>      case 'd':
>          dom = optarg;
>          break;
>      case 'p':
> -        period = strtol(optarg, NULL, 10);
> +        periods[index] = strtol(optarg, NULL, 10);
>          opt_p = 1;
> +        if (flag_p == 1) { /* budget or vcpuID is missed */
> +            fprintf(stderr, "Must specify period, budget and vcpuID\n");
> +            return 1;
> +        }
> +        flag_p = 1;
> +        if (flag_p && flag_b && flag_v) {
> +            /*
> +             * Get one complete set of per-VCPU parameters
> +             * (period, budget, vcpuID).
> +             */
> +            flag_p = 0;
> +            flag_b = 0;
> +            flag_v = 0;
> +            index++;
> +        }
>          break;
>      case 'b':
> -        budget = strtol(optarg, NULL, 10);
> +        budgets[index] = strtol(optarg, NULL, 10);
>          opt_b = 1;
> +        if (flag_b == 1) { /* period or vcpuID is missed */
> +            fprintf(stderr, "Must specify period, budget and vcpuID\n");
> +            return 1;
> +        }
> +        flag_b = 1;
> +        if (flag_p && flag_b && flag_v) {
> +            flag_p = 0;
> +            flag_b = 0;
> +            flag_v = 0;
> +            index++;
> +        }
> +        break;
> +    case 'v':
> +        vcpus[index] = strtol(optarg, NULL, 10);
> +        opt_v = 1;
> +        if (flag_v == 1) { /* period or budget is missed */
> +            fprintf(stderr, "Must specify period, budget and vcpuID\n");
> +            return 1;
> +        }
> +        flag_v = 1;
> +        if (flag_p && flag_b && flag_v) {
> +            flag_p = 0;
> +            flag_b = 0;
> +            flag_v = 0;
> +            index++;
> +        }
>          break;
>      case 'c':
>          cpupool = optarg;
>          break;
>      }
>
> -    if (cpupool && (dom || opt_p || opt_b)) {
> +    if (cpupool && (dom || opt_p || opt_b || opt_v)) {
>          fprintf(stderr, "Specifying a cpupool is not allowed with "
>                  "other options.\n");
>          return 1;

Thanks,

Meng


-----------
Meng Xu
PhD Student in Computer and Information Science
University of Pennsylvania
http://www.cis.upenn.edu/~mengxu/

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.