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

Re: [Xen-devel] [PATCH v6 for Xen 4.7 4/4] xl: enable per-VCPU parameter settings for RTDS scheduler



On Tue, Mar 8, 2016 at 1:12 PM, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> On Sun, Mar 06, 2016 at 11:55:58AM -0600, Chong Li wrote:
> [...]
>> @@ -6222,77 +6359,166 @@ 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 = (int *)xmalloc(sizeof(int)); /* IDs of VCPUs that change */
>> +    int *periods = (int *)xmalloc(sizeof(int)); /* period is in microsecond 
>> */
>> +    int *budgets = (int *)xmalloc(sizeof(int)); /* budget is in microsecond 
>> */
>> +    int v_size = 1; /* size of vcpus array */
>> +    int p_size = 1; /* size of periods array */
>> +    int b_size = 1; /* size of budgets array */
>> +    int v_index = 0; /* index in vcpus array */
>> +    int p_index =0; /* index in periods array */
>> +    int b_index =0; /* index for in budgets array */
>>      bool opt_p = false;
>>      bool opt_b = false;
>> -    int opt, rc;
>> +    bool opt_v = false;
>> +    bool opt_all = false; /* output per-dom parameters */
>> +    int opt, i;
>> +    int rc = 0;
>>      static struct option opts[] = {
>>          {"domain", 1, 0, 'd'},
>>          {"period", 1, 0, 'p'},
>>          {"budget", 1, 0, 'b'},
>> +        {"vcpuid",1, 0, 'v'},
>>          {"cpupool", 1, 0, 'c'},
>>          COMMON_LONG_OPTS
>>      };
>>
>> -    SWITCH_FOREACH_OPT(opt, "d:p:b:c:", opts, "sched-rtds", 0) {
>> +    SWITCH_FOREACH_OPT(opt, "d:p:b:v:c", opts, "sched-rtds", 0) {
>>      case 'd':
>>          dom = optarg;
>>          break;
>>      case 'p':
>> -        period = strtol(optarg, NULL, 10);
>> +        if (p_index >= p_size) { /* periods array is full */
>> +            p_size *= 2;
>> +            periods = xrealloc(periods, p_size);
>> +        }
>> +        periods[p_index++] = strtol(optarg, NULL, 10);
>>          opt_p = 1;
>>          break;
>>      case 'b':
>> -        budget = strtol(optarg, NULL, 10);
>> +        if (b_index >= b_size) { /* budgets array is full */
>> +            b_size *= 2;
>> +            budgets = xrealloc(budgets, b_size);
>> +        }
>> +        budgets[b_index++] = strtol(optarg, NULL, 10);
>>          opt_b = 1;
>>          break;
>> +    case 'v':
>> +        if (!strcmp(optarg, "all")) { /* get or set all vcpus of a domain */
>> +            opt_all = 1;
>> +            break;
>> +        }
>> +        if (v_index >= v_size) { /* vcpus array is full */
>> +            v_size *= 2;
>> +            vcpus = xrealloc(vcpus, v_size);
>> +        }
>> +        vcpus[v_index++] = strtol(optarg, NULL, 10);
>> +        opt_v = 1;
>> +        break;
>
> I'm still not quite sure why this is written like this. What's the
> expected syntax of this command? The hunk to patch xl manpage is very
> terse...

We have three arrays here, vcpus[], periods[] and budgets[]. If the xl
command is like (more examples at cover letter):

xl sched-rtds -d vm1 -v 3 -p 500 -b 200 -v 1 -p 600 -b 300 (set the
scheduling parameters of two vcpus of vm1)

then, the three arrays would be like:

vcpus: [3, 1]
periods: [500, 600]
budgets: [200, 300]

What makes this code complicated is the size of these three arrays
grows along with the
reading of OPTS. At the beginning, all three arrays have the size for
only one int. When
one array becomes full, we double its size.

Chong



-- 
Chong Li
Department of Computer Science and Engineering
Washington University in St.louis

_______________________________________________
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®.