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

Assign Logical Processors to NUMA nodes #794

Merged
merged 3 commits into from
Feb 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Solaris NUMA nodes
  • Loading branch information
dbwiddis committed Feb 4, 2019
commit 3ffb944b71cea29427398ee718c90a49756bf924
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
Expand Down Expand Up @@ -83,6 +85,7 @@ private void initVars() {
*/
@Override
protected LogicalProcessor[] initProcessorCounts() {
Map<Integer, Integer> numaNodeMap = mapNumaNodes();
List<Kstat> kstats = KstatUtil.kstatLookupAll("cpu_info", -1, null);
Set<String> chipIDs = new HashSet<>();
Set<String> coreIDs = new HashSet<>();
Expand Down Expand Up @@ -120,6 +123,38 @@ protected LogicalProcessor[] initProcessorCounts() {
return logProcs.toArray(new LogicalProcessor[logProcs.size()]);
}

private Map<Integer, Integer> mapNumaNodes() {
Map<Integer, Integer> numaNodeMap = new HashMap<>();
// Get numa node info from lgrpinfo
List<String> lgrpinfo = ExecutingCommand.runNative("lgrpinfo -c leaves");
// Format:
// lgroup 0 (root):
// CPUs 0 1
// CPUs 0-7
// CPUs 0-3 6 7 12 13
int lgroup = 0;
for (String line : lgrpinfo) {
if (line.startsWith("lgroup")) {
lgroup = ParseUtil.getFirstIntValue(line);
continue;
} else if (line.contains("CPUs:")) {
String[] cpuList = ParseUtil.whitespaces.split(line.split(":")[1]);
for (String cpu : cpuList) {
// Will either be individual CPU or hyphen-delimited range
if (cpu.contains("-")) {
int first = ParseUtil.getFirstIntValue(cpu);
int last = ParseUtil.getNthIntValue(line, 2);
for (int i = first; i <= last; i++) {
numaNodeMap.put(i, lgroup);
}
} else {
numaNodeMap.put(ParseUtil.parseIntOrDefault(cpu, 0), lgroup);
}
}
}
}
return numaNodeMap;
}
/**
* {@inheritDoc}
*/
Expand Down