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

numactl: add support for new 'prefer-many-nodes' policy #122

Merged
merged 13 commits into from
Dec 9, 2021

Conversation

ftang1
Copy link
Contributor

@ftang1 ftang1 commented Nov 15, 2021

Linux kernel 5.15 has merged a new memory policy "MPOL_PREFERRED_MANY", which allows user to specified multiple nodes as the preferred list to first allocate memory from, and till there is no available memory on those nodes, it will fallback to all other memory nodes in system.

This patchset adds the support in numactl/libnuma, and user can chose this policy by:

numactl [--preferred-many= | -P ]

And with older kernel, it will return with warning message:
"numactl: preferred-many requested without kernel support"

Copy link
Contributor

@andikleen andikleen left a comment

Choose a reason for hiding this comment

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

Assert is not the right way to check for allocation failure
Seems to have a memory leak on tmp?

Copy link
Contributor

@andikleen andikleen left a comment

Choose a reason for hiding this comment

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

Please use preferred-many and use the same in the print output

@andikleen
Copy link
Contributor

I don't see any additions to the test suite? Need test coverage

@ftang1
Copy link
Contributor Author

ftang1 commented Nov 25, 2021

Andi, thanks for the reviews! and sorry for the delay, I just saw these messages (my github email is a gmail account, which I don't check frequently).

Will address you comments.

Ben Widawsky and others added 13 commits November 27, 2021 17:11
As seen in the comment, memsize was originally duplicated to make
numademo independent. It was added here:

	commit f4e30c1 (tag: v0.9)
	Author: Andi Kleen <ak@suse.de>
	Date:   Tue Jan 3 12:37:28 2006 -0800

	Import numactl 0.9

As such, it's not entirely clear why util couldn't be linked against.
I'm doing this now so I can use find_first() in a future patch, instead
of duplicating that.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Originally, the way to prefer the local node was to specify
MPOL_PREFERRED with no mask (prior to that MPOL_DEFAULT had that
implicit behavior). However, MPOL_LOCAL interface was added in v3.10
which does the same thing.

	commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
	Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
	Date:   Thu Oct 25 14:16:28 2012 +0200

	mm: mempolicy: Make MPOL_LOCAL a real policy

This patch helps readability, local policy use the MPOL_LOCAL.

Unlike MPOL_PREFERRED_MANY, MPOL_LOCAL has existed for 8 years, so we
don't bother trying to detect if it's there automatically.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
This refactor makes the next patch a little cleaner.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
This helps converge code for supporting upcoming MPOL_PREFERRED_MANY
interface.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
This patch attempts to improve the experience for users who wish to use
new numactl with an old kernel. It helps autodetect whether or not the
new preferred interface is there and then can dynamically enable/disable
usage internally.

Doing this allows it to be used by the v1.1 interface.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
[use 'preferred-many' name as suggested by Andi]
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
For now this will just fall back to single node with warning when
needed.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
This will help consolidate preferred and preferred-many usage.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Probably should squash stuff in with this.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
There is problem when running "make test/prefered":

"
  CCLD     test/prefered
/usr/bin/ld: ./.libs/libnuma.so: undefined reference to `find_first'
collect2: error: ld returned 1 exit status
make: *** [Makefile:979: test/prefered] Error 1
"
Fixing it by modifying Makefile and perfered.c

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
@ftang1 ftang1 requested a review from andikleen November 28, 2021 09:47
@andikleen andikleen merged commit bf0a0af into numactl:master Dec 9, 2021
@andikleen
Copy link
Contributor

Thanks merged!

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.

2 participants