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 RDT plugin: add support for groups of PIDs. #2891

Merged
merged 18 commits into from
Apr 4, 2019

Conversation

wandralx
Copy link
Contributor

@wandralx wandralx commented Aug 6, 2018

ChangeLog: intel_rdt: Add support for groups of PIDs monitoring

intel_rdt plugin takes processes’ names as single items or as groups.
Plugin will reconfigure pqos library when given process is terminated or created.

For each process or group of processes following statistics are collected:

  • LLC occupancy,
  • IPC,
  • MBL and MBR.

rjablonx
rjablonx previously approved these changes Aug 8, 2018
Copy link
Contributor

@rjablonx rjablonx left a comment

Choose a reason for hiding this comment

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

+1, looks good to me

kwiatrox
kwiatrox previously approved these changes Aug 9, 2018
Copy link
Member

@kwiatrox kwiatrox left a comment

Choose a reason for hiding this comment

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

Thank you @wandralx, looks good for me.

@wandralx
Copy link
Contributor Author

@rpv-tomsk any thoughts/comments? when can I expect PR to be accepted? Thank you!

@wandralx
Copy link
Contributor Author

@rubenk any thoughts/comments? when can I expect PR to be accepted? Thank you!

@rpv-tomsk
Copy link
Contributor

Can I check this plugin on Core2Duo CPU ?

# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Core(TM)2 Duo CPU     E8200  @ 2.66GHz
stepping        : 6
cpu MHz         : 2662.464
cache size      : 6144 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht nx constant_tsc aperfmperf pni ssse3 sse4_1 hypervisor
bogomips        : 5324.92
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

@wandralx
Copy link
Contributor Author

@rpv-tomsk thank you for your interest!

Unfortunately no, to be able to check this plugin, you need one of Intel(R) Xeon(R) processors.

For detailed info about required hardware and kernel versions please see README file:
https://github.com/intel/intel-cmt-cat

For info about /proc/cpuinfo flag bits please see:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/x86/intel_rdt_ui.txt

Copy link
Contributor

@rpv-tomsk rpv-tomsk left a comment

Choose a reason for hiding this comment

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

Hi!

Thank you for your big work on Collectd.

I think this plugin and this update is very interesting and useful.

While looking into code, I found ways to do its code more clear and optimized, I hope.

I propose you to rework this utility and plugin:

Use dynamical array and realloc() instead of linked list of pids and rework types:

typedef struct pids_list_s {
  pid_t **pids;
  size_t size;
  size_t allocated;  //only (re)allocate when needed.
} pids_list_t;

typedef struct proc_pids_s {
  proc_comm_t proccess_name;
  pids_list_t *prev;
  pids_list_t *curr;
} proc_pids_t;

So, functions will be simplier, with less arguments:

-int pids_list_diff(pids_list_t *prev, pids_list_t *curr, pids_list_t **added,
-                   size_t *added_num, pids_list_t **removed,
-                   size_t *removed_num) {
+int proc_pids_diff(const proc_pids_t *proc, pids_list_t *added, pids_list_t *removed)

-pids_list_add_pids_list()
+pids_list_clone()

-fetch_pids_for_procs()
+update_proc_pids(proc_pids_t **proc_pids, size_t proc_pids_num); //Use global array and call this only once per read cycle

... and so on...

In plugin code:

*) Move pqos_mon_data into rdt_name_group_s.
*) Update structure a bit:

struct rdt_name_group_s {
  char *desc;                             -- This will to to `plugin_instance`
  //char **names;                      -- Remove in favour of `process_name` of `proc_pids_t`.
  proc_pids_t *proc_pids_array;  -- Remove `_array` suffix here
  size_t proc_pids_num;             -- Was `num_names` before renaming
  size_t monitored_pids_count;  -- Unsure if these two needs to be touched.
  enum pqos_mon_event events;
};

*) Create global dynamical array of proc_pids_t. That will be passed to update_proc_pids(), so /proc will be parsed only once. When doing oconfig_to_ngroups(), proc_pids_t should be allocated, and put into two arrays - one global, and one in ngroup.
*) In update_proc_pids() you can just swap prev/curr->pids pointers and prev/curr->size, and set curr->size = 0 before new pids added into curr.
*) When adding new pids into pids_list_t do realloc() only when needed, by checking allocated field.
*) In read_pids_data() iterate by ngroups as before.
*) In rdt_refresh_ngroup() you can use arrays of pid_t directly, pids_list_to_array() will not be needed.


And so on. There is wide field for optimization and refactoring, so I can't write all details here w/o writing the code. 

What can you say about such rework?

Unfortunately, I have no equipment to test this plugins, all available Xeon processors are too old.

DEBUG(RDT_PLUGIN ": Available events to monitor: %#x", events);

rdt->num_ngroups = n;
for (int i = 0; i < n; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation does not take into account that one option can be used in config several times.
Validation can be put into rdt_config(), after all options are processed in 'for' cycle. Other changes may also be required.

Copy link
Contributor

Choose a reason for hiding this comment

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

This helper function is called by rdt_config only

Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation does not take into account that one option can be used in config several times.

Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation does not take into account that one option can be used in config several times.

Yes, currently we support only single Processes or Cores option. We plan to extend that in the future.

int init_result = initialize_proc_pids(
procs_names_array, procs_names_array_size, proc_pids_array);
if (0 != init_result)
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

closedir(proc_dir) is missing here.

continue;
}

/* Try to find comm in input procs array (proc_pids_array has same names) */
Copy link
Contributor

Choose a reason for hiding this comment

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

proc_pids_array has same names - that is unclear.

If names are the same, why do we need to copy they in initialize_proc_pids() in each cycle?
You can just do direct compare with procs_names_array[i] and you even need not to have proccess_name in proc_pids_s then. And, as there is only one field in that structure, then that structure is not needed too.

But I have another proposal to rework this utility and plugin.

int read_result =
read_proc_name(procfs_path, entry, comm, sizeof(proc_comm_t));
if (read_result <= 0) {
ERROR(UTIL_NAME ": Comm file skipped. Read result: %d", read_result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typical system can have processes starting and finishing in unpredictable time.
Race conditions can occur. Logging ERROR for each such case of terminated process is excessive.
I think, no message is required here at all, like in processes plugin.

groups_refresh:
for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
int refresh_result =
rdt_refresh_ngroup(&(g_rdt->ngroups[i]), g_rdt->pngroups[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will call fetch_pids_for_procs() for each configured group, and will scan /proc multiple times.
I think that is suboptimal and I have proposal how to optimize this.

Copy link
Contributor

Choose a reason for hiding this comment

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

proc_pids_update moved before the for loop. Now list of pids is fetched only once.

@octo octo changed the title Added support for pqos library 2.0 feature: monitoring groups of PIDs. Intel RDT plugin: add support for groups of PIDs. Oct 25, 2018
@octo octo added the Feature label Oct 25, 2018
@sunkuranganath
Copy link
Member

Thanks @rpv-tomsk for the review. Working on these internally. Will have few updates very soon.

@rpv-tomsk
Copy link
Contributor

Great news!

mstarzyx and others added 16 commits March 6, 2019 06:06
adds intel_rdt_tests file with unit-tests of newly introduced functions.

Change-Id: I0e26322caa19f57b7d660807646bd437586cd80d
Signed-off-by: Starzyk, MateuszX <mateuszx.starzyk@intel.com>
Add temporary functions to enable further development of rdt plugin.
These stubbed functions will be removed once libpqos extends it's API.

Change-Id: I39dd428e39fd6055774dfc39b4c0690aedee4ebe
Signed-off-by: Starzyk, MateuszX <mateuszx.starzyk@intel.com>
"Processes" option added.

Change-Id: I7f62a51fc06e0c7503caa7860807f1c8e09b2fa1
Signed-off-by: Andralojc, WojciechX <wojciechx.andralojc@intel.com>
Change-Id: I569d72d0f12dca314e865f0b9236dc09a053c5e5
Signed-off-by: Andralojc, WojciechX <wojciechx.andralojc@intel.com>
Change-Id: I677c8215f89c04cedcb4c9e7d630f187a76a6cc7
Signed-off-by: Andralojc, WojciechX <wojciechx.andralojc@intel.com>
Change-Id: Ib5a7d318bde69ee8f496b39ca74b3ee4e58d8f5b
Signed-off-by: Starzyk, MateuszX <mateuszx.starzyk@intel.com>
Refactor certain functions to be testable.

Change-Id: I5adb6ed1b076f0cebc70641f04dd101d4e89b9cc
Signed-off-by: Starzyk, MateuszX <mateuszx.starzyk@intel.com>
Change-Id: I3737a39c40d89a8782ef9c3d8195351f0fdeb278
… static to dynamic

Change-Id: I3936fe78cfcbb4ce053d38ff1a3236c21eac9fd7
Signed-off-by: Michal Aleksinski <michalx.aleksinski@intel.com>
Extract pids config to seperate file.
Extract pids config tests to seperate file.

Change-Id: I2978db56b15a126eced12f40baac631517303e04
Signed-off-by: Mateusz Starzyk <mateuszx.starzyk@intel.com>
Signed-off-by: Wojciech Andralojc <wojciechx.andralojc@intel.com>
Change-Id: I325ea0728dd1eb65776f239b0d7977cc02f9c8db
Change-Id: I161c8df1e6a4c4c4e0dd4e20601323ef7a1c18f5
Change-Id: Ibcf8c2fd6d1b490cbeeef7480c49da84389104f4
Change-Id: Ibb0dc6fe59eb77a217ab3b45ec0c1437bc9eb281
Change-Id: Ia7c9bf5dca2b871b05c9ed3876059e6d34bd943e
Change-Id: Ia932f377c5194240aab910d052e422b99ea542a5
DEBUG(RDT_PLUGIN ": Available events to monitor: %#x", events);

rdt->num_ngroups = n;
for (int i = 0; i < n; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation does not take into account that one option can be used in config several times.

…ds list

Change-Id: Ic99acd51be69d2678f25bdde9ca37011ad24fe99
@kwiatrox
Copy link
Member

kwiatrox commented Mar 7, 2019

Hi @rpv-tomsk, Currently we support only single use of Processes or Cores option. This is the case also for some other plugins. It's a good idea, but maybe we should improve it in the future, not in this PR.
We just would like to include it in 5.9 release.

kwiatrox
kwiatrox previously approved these changes Mar 11, 2019
@sunkuranganath
Copy link
Member

I would go with @kwiatrox suggestion. Could we have this accepted for 5.9 release and have the updates done just after as a new PR?

@rpv-tomsk
Copy link
Contributor

Hi @rpv-tomsk, Currently we support only single use of Processes or Cores option.
This is the case also for some other plugins. It's a good idea, but
maybe we should improve it in the future, not in this PR.
We just would like to include it in 5.9 release.

I just want to include only qualitative code. I think there is no much code changes needed to allow multiple use of Processes option, or to deny such explicitly. This reduces configuration errors.
From my POV "maybe" and "in the future" are not allowed for such small changes.

@sunkuranganath
Copy link
Member

Thanks @rpv-tomsk. We see 5.9 release hasnt happened yet and so we are working on the updates as indicated.

Add a check to avoid placing multiple Cores or Processes options in
intel_rdt configuration in order to avoid misuse and errors.

Change-Id: I82504a650bf9c568862da9f129a84a3079990496
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
@rpv-tomsk
Copy link
Contributor

Hi, Team.

I will not merge none of PR untill it will be possible for me to merge my PR too.

Thanks for your attention.

@mrunge
Copy link
Member

mrunge commented Apr 4, 2019

Thank you all for your contribution.

@mrunge mrunge merged commit f3d8a8a into collectd:master Apr 4, 2019
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

9 participants