-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fetch per-numa memory usage from the OS. #17
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return without fclose(f)
src/numus.c
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't simple '''break''' have the same effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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,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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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