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: core groups feature #2681

Merged
merged 7 commits into from
May 18, 2018

Conversation

kwiatrox
Copy link
Member

@kwiatrox kwiatrox commented Feb 9, 2018

New "Cores" option is similar to that available in intel_rdt plugin.
New tool utils_config_cores is added to parse "Cores" option. It is used by intel_pmu and intel_rdt to avoid redundant code.
Having this option will allow to configure monitoring of PMU events only on specific CPUs thus decrease number of opened descriptors and improve performance significantly.

Copy link
Contributor

@maryamtahhan maryamtahhan left a comment

Choose a reason for hiding this comment

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

Changes look good to me - can you please double check why some of the checks failed?

@kwiatrox
Copy link
Member Author

Thanks @maryamtahhan , it looks like for epel6 build saveptr for strtok_r needs to be initialised. Will fix it with next commit.

@kwiatrox
Copy link
Member Author

It seems that Jenkins has problems due to environment issue: "Slave went offline during the build".
I don't see any errors related to PR.

@maryamtahhan
Copy link
Contributor

@kwiatrox can you rebase this against 5.8.0? It looks good to me it would be great if @rpv-tomsk or @octo could review and approve this is a great addition

Having this option will allow to configure monitoring of PMU
events only on specific CPUs thus decrease number of opened
descriptors significantly and avoid 'Too many open files' errors.
New "Cores" option is similar to that available in intel_rdt plugin.
New tool utils_config_cores is added to parse "Cores" option.

Change-Id: I8f792e1f2560c4cf19aee101fdb07c925d682778
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
Use utils_config_cores for core groups configuration so it is
in line with intel_pmu and reduce amount of redundant code.

Change-Id: If02e2eeea8bcf3e0df705ebcd9a6310b549b5ebe
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
Run script contrib/format.sh to format the code.
Replace zu with new collectd macro PRIsz.

Change-Id: I167b1065461e924d7ab260a35f85f5ab162c4165
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
To avoid compilation error on some versions of gcc the
saveptr for strtok_r needs to be initilised to NULL.

Change-Id: I7b30e51ecae33a6994ba7ea181cac0f33eef023f
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
@kwiatrox kwiatrox force-pushed the feat_pmu_cores branch 2 times, most recently from 0a600b5 to 82b0d43 Compare February 19, 2018 11:45
Add definition for PRIsz macro to make code backward compatible with
collectd-5.8 branch.

Change-Id: I880340af5ae883a444563422b3e9975b3693683c
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
@kwiatrox kwiatrox changed the base branch from master to collectd-5.8 February 20, 2018 08:34
@collectd-bot collectd-bot added this to the 5.8 milestone Feb 20, 2018
@kwiatrox
Copy link
Member Author

Code is rebased against 5.8 branch and all checks have passed.

Copy link
Contributor

@vmytnykx vmytnykx left a comment

Choose a reason for hiding this comment

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

A few minor comments....

/**
* collectd - src/utils_config_cores.h
*
* Copyright(c) 2017 Intel Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2018, please check in all new files.

#define UTILS_CONFIG_CORES_H 1

#ifndef PRIsz
#define PRIsz "zu"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the idea of this define? %zu is always used for size_t data type. Why don't use %zu directly in the string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Look at the PR #2512 .

Copy link
Contributor

Choose a reason for hiding this comment

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

Great. So it doesn't make sense to duplicate it here. Just use src/daemon/globals.h.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not backported to 5.8. So it is necessary to be compatible with 5.8 branch. After merge to master it could be deleted. In current state it goes well with both master and 5.8 branches. It is easier to keep this small define than to replace %zu everywhere later on.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, that's fine.

*
* For empty string "" *cgl is not modified and zero is returned.
*/
int config_cores_parse(const oconfig_item_t *ci, core_groups_list_t *cgl);
Copy link
Contributor

Choose a reason for hiding this comment

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

add forward declaration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added include for configfile.h to avoid forward declaration.

ci->values[i].value.string);
goto parse_error;
}
n = str_list_to_nums(str, cores, STATIC_ARRAY_SIZE(cores));
Copy link
Contributor

Choose a reason for hiding this comment

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

size_t n =...

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to define variables at the beginning of scope not on first use. It is used in most of the code. Are there any strong arguments for change?

Copy link
Contributor

Choose a reason for hiding this comment

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

The collectd maintainers suggest to minimize the scope of of declaration of variable as much as possible. E.g. see #1971 (comment) comment. That's the why I suggest to declare it in place where this variable is used first.

Copy link
Contributor

@vmytnykx vmytnykx Feb 22, 2018

Choose a reason for hiding this comment

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

The collectd maintainers suggest to minimize the scope of of declaration of variable as much as possible. E.g. see #1971 (comment) comment. That's the why I suggest to declare it in place where this variable is used first.

rdt_free_cgroups();
ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
return -EINVAL;
}
n = g_rdt->cores.num_cgroups;
Copy link
Contributor

Choose a reason for hiding this comment

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

size_t n = ..

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to define variables at the beginning of scope not on first use. It is used in most of the code and in line with existing implementation. Are there any strong arguments for change?

Copy link
Contributor

Choose a reason for hiding this comment

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

same

Fix minor issues found during review.
Update year to 2018,
add include in utils_config_cores.h to avoid forward
declaration.

Change-Id: I7d657bab7c97d7193d7977ef129181cad13d73d5
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
@kwiatrox
Copy link
Member Author

Hi @rpv-tomsk, are there chances for this change to be merged into 5.8 branch?
It solves the issue #2600 and in general is expected by few people. Let me know if you need anything from my side. Thanks

src/intel_pmu.c Outdated
return;
}
for (size_t j = 0; j < cgroup->num_cores; j++)
snprintf(cores + strlen(cores), cores_size - strlen(cores), " %d",
Copy link
Contributor

Choose a reason for hiding this comment

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

please check for failure

src/intel_pmu.c Outdated
@@ -270,20 +325,17 @@ static int pmu_config(oconfig_item_t *ci) {
return 0;
}

static void pmu_submit_counter(int cpu, char *event, counter_t value,
static void pmu_submit_counter(char *cgroup, char *event, counter_t value,
Copy link
Contributor

Choose a reason for hiding this comment

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

cgroup is not modified, can you make it const?

@rubenk
Copy link
Contributor

rubenk commented May 17, 2018

I've left a few comments inline. Once these are resolved I'll merge.

Just for future reference, new functionality land in master, the stable branches should just receive bug fixes.
I'll make an exception this time since you already did rebase on 5.8.

Check for failure from snprintf.
Make cgroup and event const in pmu_submit_counter.

Change-Id: I5547375da26c3a63b76588b733e844e3199e9bb8
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
@kwiatrox
Copy link
Member Author

@rubenk, thanks for the review and comments. I've committed next patch to resolve them.

@rubenk rubenk merged commit 753955e into collectd:collectd-5.8 May 18, 2018
@rubenk
Copy link
Contributor

rubenk commented May 18, 2018

Thank you @kwiatrox!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants