MCPcopy Create free account
hub / github.com/apache/mesos / cloneCpusetCpusMems

Function cloneCpusetCpusMems

src/linux/cgroups.cpp:239–266  ·  view source on GitHub ↗

Copies the value of 'cpuset.cpus' and 'cpuset.mems' from a parent cgroup to a child cgroup so the child cgroup can actually run tasks (otherwise it gets the error 'Device or resource busy'). @param hierarchy Path to hierarchy root. @param parentCgroup Path to parent cgroup relative to the hierarchy root. @param childCgroup Path to child cgroup relative to the hierarchy root. @return

Source from the content-addressed store, hash-verified

237// @return Some if the operation succeeds.
238// Error if the operation fails.
239static Try<Nothing> cloneCpusetCpusMems(
240 const string& hierarchy,
241 const string& parentCgroup,
242 const string& childCgroup)
243{
244 Try<string> cpus = cgroups::read(hierarchy, parentCgroup, "cpuset.cpus");
245 if (cpus.isError()) {
246 return Error("Failed to read control 'cpuset.cpus': " + cpus.error());
247 }
248
249 Try<string> mems = cgroups::read(hierarchy, parentCgroup, "cpuset.mems");
250 if (mems.isError()) {
251 return Error("Failed to read control 'cpuset.mems': " + mems.error());
252 }
253
254 Try<Nothing> write =
255 cgroups::write(hierarchy, childCgroup, "cpuset.cpus", cpus.get());
256 if (write.isError()) {
257 return Error("Failed to write control 'cpuset.cpus': " + write.error());
258 }
259
260 write = cgroups::write(hierarchy, childCgroup, "cpuset.mems", mems.get());
261 if (write.isError()) {
262 return Error("Failed to write control 'cpuset.mems': " + write.error());
263 }
264
265 return Nothing();
266}
267
268
269// Removes a cgroup from a given hierachy.

Callers 1

foreachFunction · 0.85

Calls 7

NothingClass · 0.85
readFunction · 0.70
writeFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected