Fetch per-numa memory usage from the OS.#17
Fetch per-numa memory usage from the OS.#17kilobyte wants to merge 2 commits intobratpiorka:masterfrom
Conversation
bratpiorka
left a comment
There was a problem hiding this comment.
this is not strictly related to hot poc - could you extend print_memtier_memory() with this info?
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kilobyte)
src/numus.c
Outdated
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #define MAX_NODES 1024 /* kernel max */ |
There was a problem hiding this comment.
Maybe it would be a better idea to use CONFIG_NODES_SHIFT or some other #def ?
What about this code?
src/numus.c
Outdated
| } | ||
|
|
||
| if (maxnode && !pagesize) | ||
| return fprintf(stderr, "Pages used but no page size\n"), false; |
There was a problem hiding this comment.
return without fclose(f)
| else if (tok[0] == 'N' && tok[1] >= '0' && tok[1] <= '9') { | ||
| int node = atoi(tok + 1); | ||
| if (node >= MAX_NODES) | ||
| continue; | ||
| if (maxnode + 1 >= MAX_NODES) | ||
| continue; |
There was a problem hiding this comment.
some comments would be welcome, the code could be more readable
| if (!valp) { | ||
| /* flags */ | ||
| if (!strcmp(tok, "stack")) | ||
| goto skip_mapping; |
There was a problem hiding this comment.
wouldn't simple '''break''' have the same effect?
kilobyte
left a comment
There was a problem hiding this comment.
The values are global, not sure if it's good to print them there. On the other hand, if we marked that as global...
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @maciekpac and @PatKamin)
src/numus.c, line 7 at r1 (raw file):
Previously, maciekpac wrote…
Maybe it would be a better idea to use CONFIG_NODES_SHIFT or some other #def ?
What about this code?
CONFIG_NODES_SHIFT is a settable piece of kernel config, and thus can't be used outside of the kernel itself. I don't see a #define for the max in the kernel's uapi either.
src/numus.c, line 41 at r1 (raw file):
Previously, maciekpac wrote…
wouldn't simple '''break''' have the same effect?
Alas, we're in a deeper while.
src/numus.c, line 53 at r1 (raw file):
Previously, maciekpac wrote…
some comments would be welcome, the code could be more readable
I've added some.
src/numus.c, line 61 at r1 (raw file):
Previously, maciekpac wrote…
return without fclose(f)
Done.
bratpiorka
left a comment
There was a problem hiding this comment.
ok but otherwise this code wouldn't be used and tested at all
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @maciekpac and @PatKamin)
PatKamin
left a comment
There was a problem hiding this comment.
Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @kilobyte and @maciekpac)
src/numus.c, line 7 at r2 (raw file):
#include <stdlib.h> #define MAX_NODES 1024 /* kernel max */
Perhaps you could use numa_num_possible_nodes() from numa library.
src/numus.c, line 75 at r2 (raw file):
} for (int i = 0; i < maxnode; i++) numamem[num[i]].used += count[i] * pagesize;
size_t += long * unsigned long long
kilobyte
left a comment
There was a problem hiding this comment.
Done.
Reviewable status: 1 of 4 files reviewed, 6 unresolved discussions (waiting on @bratpiorka, @maciekpac, and @PatKamin)
src/numus.c, line 7 at r2 (raw file):
Previously, PatKamin (Patryk Kaminski) wrote…
Perhaps you could use numa_num_possible_nodes() from numa library.
In this version, the struct is static thus I'm using a compile-time value (that matches kernel max) — but once we get to polishing this code for outside usage, that's exactly the function we should use. Thanks for researching this bit, I've put it in a comment so it's not forgotten.
src/numus.c, line 75 at r2 (raw file):
Previously, PatKamin (Patryk Kaminski) wrote…
size_t += long * unsigned long long
count[i] is size_t, pagesize is uint64_t, both unsigned. Am I missing something?
I've just changed pagesize to size_t for consistency, but that's the same effective type.
PatKamin
left a comment
There was a problem hiding this comment.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @kilobyte and @maciekpac)
src/numus.c, line 75 at r2 (raw file):
Previously, kilobyte (Adam Borowski) wrote…
count[i]is size_t,pagesizeis uint64_t, both unsigned. Am I missing something?
I've just changed pagesize to size_t for consistency, but that's the same effective type.
Indeed. I wrongly assumed that count[i] is long because you use atol() when assigning it's value.
src/numus.c, line 62 at r3 (raw file):
continue; num[maxnode] = node; count[maxnode] = atol(valp);
atol() return long whereas count[maxnode] is an ull.
maciekpac
left a comment
There was a problem hiding this comment.
Reviewed 1 of 2 files at r1, 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @kilobyte and @PatKamin)
src/numus.c, line 62 at r3 (raw file):
Previously, PatKamin (Patryk Kaminski) wrote…
atol()return long whereascount[maxnode]is an ull.
up
kilobyte
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @PatKamin)
src/numus.c, line 75 at r2 (raw file):
Previously, PatKamin (Patryk Kaminski) wrote…
Indeed. I wrongly assumed that
count[i]is long because you useatol()when assigning it's value.
→ strtoul()
src/numus.c, line 62 at r3 (raw file):
Previously, maciekpac wrote…
up
Changed to unchecked strtoul().
PatKamin
left a comment
There was a problem hiding this comment.
Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kilobyte)
A simplified version, without assigning kinds, etc.
|
Rebased. |
maciekpac
left a comment
There was a problem hiding this comment.
Reviewed 1 of 2 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kilobyte)
This change is