Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intel_pmu: add metadata with information about scaling #2398

Merged
merged 3 commits into from Oct 6, 2017

Conversation

serhiyx
Copy link
Contributor

@serhiyx serhiyx commented Aug 16, 2017

In case reported counters were scaled metadata contains information basing on which scaled value was calculated.
If there are more events than counters, the kernel uses time multiplexing. With multiplexing, at the end of the run, the counter is scaled basing on total time enabled vs time running: final_count = raw_count * time_enabled/time_running

Change-Id: I259455d35aac9edef8f05310f199637f3ce09491
Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
src/intel_pmu.c Outdated
@@ -283,6 +285,27 @@ static void pmu_submit_counter(int cpu, char *event, counter_t value) {
plugin_dispatch_values(&vl);
}

meta_data_t *pmu_event_get_meta(struct event *e, int cpu) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great to rename this function to pmu_event_set_meta rather than get... but other than that this looks good to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we call constructors (functions that allocate, initialize and return a foo_t) foo_create. The pmu prefix is fine, which would make this pmu_meta_data_create.

@maryamtahhan maryamtahhan mentioned this pull request Sep 27, 2017
19 tasks
src/intel_pmu.c Outdated
pmu_submit_counter(i, e->event, value);
pmu_submit_counter(i, e->event, value, meta);

if (meta) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the meta_data_destroy handles the null ptr, so the if statement is not required here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that you saw this comment: there is no need to check if meta is non-NULL and imho the code is cleaner without the check, but the decision is up to you.

(A good practice is to reply something along the lines of "ACK; I prefer to keep as-is" to optional comments to show that you considered them.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok
Wanted to keep as-is but if two reviewers say the code will be cleaner I agree :)

src/intel_pmu.c Outdated
@@ -283,6 +285,27 @@ static void pmu_submit_counter(int cpu, char *event, counter_t value) {
plugin_dispatch_values(&vl);
}

meta_data_t *pmu_event_get_meta(struct event *e, int cpu) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const struct event *e

Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @serhiyx.

Thanks @maryamtahhan and @vmytnykx for your review comments, too :) Once the comments are addressed I'm happy to merge.

Best regards,
—octo

src/intel_pmu.c Outdated
@@ -283,6 +285,27 @@ static void pmu_submit_counter(int cpu, char *event, counter_t value) {
plugin_dispatch_values(&vl);
}

meta_data_t *pmu_event_get_meta(struct event *e, int cpu) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we call constructors (functions that allocate, initialize and return a foo_t) foo_create. The pmu prefix is fine, which would make this pmu_meta_data_create.

src/intel_pmu.c Outdated
@@ -283,6 +285,27 @@ static void pmu_submit_counter(int cpu, char *event, counter_t value) {
plugin_dispatch_values(&vl);
}

meta_data_t *pmu_event_get_meta(struct event *e, int cpu) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only ever seem to access e->efd[cpu] – can you pass that instead of e and cpu individually?

Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your update @serhiyx! Two small comments remain – once they're addressed this is good to go :)

Best regards,
—octo

src/intel_pmu.c Outdated
meta_data_t *meta = NULL;

/* create meta data only if value was scaled */
if (e->efd[cpu].val[1] != e->efd[cpu].val[2] && e->efd[cpu].val[2]) {
if (efd->val[1] != efd->val[2] && efd->val[2]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert the logic to remove one level of indentation:

if (efd->val[1] == efd->val[2] || !efd->val[2]) {
  return NULL;
}

meta_data_t *meta = meta_data_create();
/* … */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

src/intel_pmu.c Outdated
pmu_submit_counter(i, e->event, value);
pmu_submit_counter(i, e->event, value, meta);

if (meta) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that you saw this comment: there is no need to check if meta is non-NULL and imho the code is cleaner without the check, but the decision is up to you.

(A good practice is to reply something along the lines of "ACK; I prefer to keep as-is" to optional comments to show that you considered them.)

Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
@octo octo added this to the 5.8 milestone Oct 6, 2017
@octo octo added the Feature label Oct 6, 2017
Copy link
Member

@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @serhiyx!

@octo
Copy link
Member

octo commented Oct 6, 2017

I manually triggered a build all is well: https://ci.collectd.org/job/pull-requests-manual_trigger-aggregation/248/

@octo octo merged commit 6f8e9c1 into collectd:master Oct 6, 2017
@maryamtahhan maryamtahhan deleted the pmu_scaling branch October 11, 2017 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants