Em Thu, Apr 26, 2012 at 02:15:23PM +0900, Namhyung Kim escreveu:
> The perf_target_errno enumerations are used to indicate
> specific error cases on perf target operations. It'd
> help libperf being a more generic library.
>
> Suggested-by: Arnaldo Carvalho de Melo <[email protected]>
> Signed-off-by: Namhyung Kim <[email protected]>
> + /* UID and SYSTEM are mutually exclusive */
> + if (target->uid_str && target->system_wide) {
> + target->system_wide = false;
> + if (ret == PERF_TARGET__SUCCESS)
> + ret = PERF_TARGET__UID_OVERRIDE_SYSTEM;
> + }
> +
> + return ret;
> }
> diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
> index 1348065ada5e..c3914c8a9890 100644
> --- a/tools/perf/util/target.h
> +++ b/tools/perf/util/target.h
> @@ -12,6 +12,24 @@ struct perf_target {
> bool system_wide;
> };
>
> -void perf_target__validate(struct perf_target *target);
> +enum perf_target_errno {
> + /*
> + * XXX: Just choose an arbitrary big number standard errno can't have
Here I think its better for us to use _negative_ big numbers, because
according to:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
<quote>
Issue 6
The following new requirements on POSIX implementations derive from
alignment with the Single UNIX Specification:
The majority of the error conditions previously marked as extensions are
now mandatory, except for the STREAMS-related error conditions.
Values for errno are now required to be distinct positive values rather
than non-zero values. This change is for alignment with the ISO/IEC
9899:1999 standard.
</quote>
So system errno range is all positive, since our error enumeration is a
superset of the system one, using negative values won't ever clash.
Also it would be better to have it as PERF_ERRNO__PID_OVERRIDE_CPU, etc.
Agreed?
Anybody else with reasons not to use this ernno range scheme?
Ingo?
- Arnaldo
> + */
> + __PERF_TARGET__ERRNO_START = 0x10000,
> +
> + PERF_TARGET__SUCCESS = __PERF_TARGET__ERRNO_START,
> +
> + /* for perf_target__validate() */
> + PERF_TARGET__PID_OVERRIDE_CPU,
> + PERF_TARGET__PID_OVERRIDE_UID,
> + PERF_TARGET__UID_OVERRIDE_CPU,
> + PERF_TARGET__PID_OVERRIDE_SYSTEM,
> + PERF_TARGET__UID_OVERRIDE_SYSTEM,
> +
> + __PERF_TARGET__ERRNO_END
> +};
> +
> +enum perf_target_errno perf_target__validate(struct perf_target *target);
>
> #endif /* _PERF_TARGET_H */
> --
> 1.7.10
Hi,
2012-05-02 (수), 15:59 -0300, Arnaldo Carvalho de Melo:
> Em Thu, Apr 26, 2012 at 02:15:23PM +0900, Namhyung Kim escreveu:
> > The perf_target_errno enumerations are used to indicate
> > specific error cases on perf target operations. It'd
> > help libperf being a more generic library.
> >
> > Suggested-by: Arnaldo Carvalho de Melo <[email protected]>
> > Signed-off-by: Namhyung Kim <[email protected]>
> > + /* UID and SYSTEM are mutually exclusive */
> > + if (target->uid_str && target->system_wide) {
> > + target->system_wide = false;
> > + if (ret == PERF_TARGET__SUCCESS)
> > + ret = PERF_TARGET__UID_OVERRIDE_SYSTEM;
> > + }
> > +
> > + return ret;
> > }
> > diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
> > index 1348065ada5e..c3914c8a9890 100644
> > --- a/tools/perf/util/target.h
> > +++ b/tools/perf/util/target.h
> > @@ -12,6 +12,24 @@ struct perf_target {
> > bool system_wide;
> > };
> >
> > -void perf_target__validate(struct perf_target *target);
> > +enum perf_target_errno {
> > + /*
> > + * XXX: Just choose an arbitrary big number standard errno can't have
>
> Here I think its better for us to use _negative_ big numbers, because
> according to:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
>
> <quote>
> Issue 6
>
> The following new requirements on POSIX implementations derive from
> alignment with the Single UNIX Specification:
>
> The majority of the error conditions previously marked as extensions are
> now mandatory, except for the STREAMS-related error conditions.
>
> Values for errno are now required to be distinct positive values rather
> than non-zero values. This change is for alignment with the ISO/IEC
> 9899:1999 standard.
> </quote>
>
> So system errno range is all positive, since our error enumeration is a
> superset of the system one, using negative values won't ever clash.
>
> Also it would be better to have it as PERF_ERRNO__PID_OVERRIDE_CPU, etc.
>
> Agreed?
>
Agreed and thanks for the info. Will change the name of error constants
too.
Thanks,
Namhyung
> Anybody else with reasons not to use this ernno range scheme?
>
> Ingo?
>
> - Arnaldo
>
> > + */
> > + __PERF_TARGET__ERRNO_START = 0x10000,
> > +
> > + PERF_TARGET__SUCCESS = __PERF_TARGET__ERRNO_START,
> > +
> > + /* for perf_target__validate() */
> > + PERF_TARGET__PID_OVERRIDE_CPU,
> > + PERF_TARGET__PID_OVERRIDE_UID,
> > + PERF_TARGET__UID_OVERRIDE_CPU,
> > + PERF_TARGET__PID_OVERRIDE_SYSTEM,
> > + PERF_TARGET__UID_OVERRIDE_SYSTEM,
> > +
> > + __PERF_TARGET__ERRNO_END
> > +};
> > +
> > +enum perf_target_errno perf_target__validate(struct perf_target *target);
> >
> > #endif /* _PERF_TARGET_H */
> > --
> > 1.7.10
--
Regards,
Namhyung Kim
On 5/2/12 12:59 PM, Arnaldo Carvalho de Melo wrote:
> Also it would be better to have it as PERF_ERRNO__PID_OVERRIDE_CPU, etc.
I thought you wanted subsystem based errno's (PERF_TARGET__XXXXX) versus
one big set (PERF_ERRNO__XXXXX). Did you change your mind?
David
Em Thu, May 03, 2012 at 02:34:20PM -0600, David Ahern escreveu:
> On 5/2/12 12:59 PM, Arnaldo Carvalho de Melo wrote:
> >Also it would be better to have it as PERF_ERRNO__PID_OVERRIDE_CPU, etc.
>
> I thought you wanted subsystem based errno's (PERF_TARGET__XXXXX)
> versus one big set (PERF_ERRNO__XXXXX). Did you change your mind?
Oops, I didn't realize PID being the subsys, then yeah, that is ok.
But that would make it PERF_ERR__TARGET_, as PERF_TARGET__ doesn't
straight away brings back "error enumeration", at least for me :)
But this is getting overly long, ideas?
PERF_ we need, its libperf's "namespace", then ERRNO looks needed too,
heck, make it long:
PERF_ERRNO_TARGET__PID_OVERRIDE_CPU
After all most of the time this will just be inside the function setting
the error and the strerrno function that will convert this to an string,
right?
- Arnaldo
On 5/3/12 2:42 PM, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 03, 2012 at 02:34:20PM -0600, David Ahern escreveu:
>> On 5/2/12 12:59 PM, Arnaldo Carvalho de Melo wrote:
>>> Also it would be better to have it as PERF_ERRNO__PID_OVERRIDE_CPU, etc.
>>
>> I thought you wanted subsystem based errno's (PERF_TARGET__XXXXX)
>> versus one big set (PERF_ERRNO__XXXXX). Did you change your mind?
>
> Oops, I didn't realize PID being the subsys, then yeah, that is ok.
>
> But that would make it PERF_ERR__TARGET_, as PERF_TARGET__ doesn't
> straight away brings back "error enumeration", at least for me :)
>
> But this is getting overly long, ideas?
>
> PERF_ we need, its libperf's "namespace", then ERRNO looks needed too,
> heck, make it long:
>
> PERF_ERRNO_TARGET__PID_OVERRIDE_CPU
>
> After all most of the time this will just be inside the function setting
> the error and the strerrno function that will convert this to an string,
> right?
Agreed, the long macro name shouldn't be visible outside of the depths
of the perf files that set it and convert it to a string.
David