xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com,
	stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com
Subject: Re: [PATCH v1 5/5] xentrace: Implement cpu mask range parsing of human values (-C).
Date: Wed, 4 Jun 2014 18:18:55 +0100	[thread overview]
Message-ID: <538F54FF.3070005@eu.citrix.com> (raw)
In-Reply-To: <1401889471-1174-6-git-send-email-konrad.wilk@oracle.com>

On 06/04/2014 02:44 PM, Konrad Rzeszutek Wilk wrote:
> Instead of just using -c 0x<some hex value> we can
> also use -C <starting cpu>-<end cpu> or -C <cpu1>,<cpu2>

Would it be better, I wonder, to just try to overload the -c operator, 
special-casing "0x[hex]" to use the old interface?  Anyone who's 
currently using -c should almost certainly be using a hex string there, 
I should think -- using decimal would be pretty daft.

All it would take, I think, would be to check for bytes 0 and 1 being 
"0x", and if so, calling strtoul() rather than parse_cpumask_range().

[snip]
> @@ -967,6 +970,98 @@ static int parse_cpumask(const char *arg)
>       return 0;
>   }
>
> +static int parse_cpumask_range(const char *arg)
> +{
> +    xc_cpumap_t map;
> +    unsigned int a, b, buflen = strlen(arg);
> +    int c, c_old, totaldigits, nmaskbits;
> +    int exp_digit, in_range;
> +
> +    if ( !buflen )
> +    {
> +        fprintf(stderr, "Invalid option argument: %s\n", arg);
> +        usage(); /* does exit */
> +    }
> +    nmaskbits = xc_get_max_cpus(xc_handle);
> +    if ( nmaskbits <= 0 )
> +    {
> +        fprintf(stderr, "Failed to get max number of CPUs! rc: %d\n", nmaskbits);
> +        usage();
> +    }
> +    map = xc_cpumap_alloc(xc_handle);
> +    if ( !map )
> +    {
> +        fprintf(stderr, "Out of memory!\n");
> +        usage();
> +    }
> +    c = c_old = totaldigits = 0;
> +    do {
> +        exp_digit = 1;
> +        in_range = 0;
> +        a = b = 0;
> +        while ( buflen )
> +        {
> +            c = *arg++;
> +            buflen--;
> +
> +            if ( isspace(c) )
> +                continue;

Is it possible for this to have a space at the beginning?  Doesn't 
getopt() take care of that?

> +
> +            if ( totaldigits && c && isspace(c_old) )

c_old doesn't seem to be set anywhere after it's initialized above.

> +            {
> +                fprintf(stderr, "No embedded whitespaces allowed in: %s\n", arg);
> +                goto err_out;
> +            }
> +
> +            /* A '\0' or a ',' signal the end of a cpu# or range */
> +            if ( c == '\0' || c == ',' )
> +                break;
> +
> +            if ( c == '-' )
> +            {
> +                if ( exp_digit || in_range )
> +                        goto err_out;

Isn't exp_digit a bit redundant, as if "in_range" is 1, "exp_digit" will 
also always be 1?

Everything else looks reasonable.

  -George

  reply	other threads:[~2014-06-04 17:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 13:44 [PATCH v1] Misc fixes to xentrace, docs, and add code to support selective human CPU selection Konrad Rzeszutek Wilk
2014-06-04 13:44 ` [PATCH v1 1/5] docs: xentrace manpage Konrad Rzeszutek Wilk
2014-06-04 16:25   ` George Dunlap
2014-06-05 13:31     ` Ian Campbell
2014-06-04 13:44 ` [PATCH v1 2/5] libxc/trace: Add xc_tbuf_set_cpu_mask_array a variant of xc_tbuf_set_cpu_mask (v3) Konrad Rzeszutek Wilk
2014-06-04 16:45   ` George Dunlap
2014-06-04 16:52     ` George Dunlap
2014-06-13 17:52       ` Konrad Rzeszutek Wilk
2014-06-05 12:49   ` Ian Campbell
2014-06-13 18:30     ` Konrad Rzeszutek Wilk
2014-06-04 13:44 ` [PATCH v1 3/5] libxc/trace: Fix style Konrad Rzeszutek Wilk
2014-06-04 16:46   ` George Dunlap
2014-06-04 13:44 ` [PATCH v1 4/5] xentrace: Use xc_cpumask_t when setting the cpu mask (v4) Konrad Rzeszutek Wilk
2014-06-04 17:01   ` George Dunlap
2014-06-05 12:55     ` Ian Campbell
2014-06-04 13:44 ` [PATCH v1 5/5] xentrace: Implement cpu mask range parsing of human values (-C) Konrad Rzeszutek Wilk
2014-06-04 17:18   ` George Dunlap [this message]
2014-06-13 19:57     ` Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=538F54FF.3070005@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).