Skip to content

Commit 383a7d9

Browse files
committed
allow: now allowed on shmem-adopted topologies
A shmem topology may now be shared between different cgroups, one only has to call hwloc_topology_allow(LOCAL) to update the list of allowed CPUs and memory after adopting the shmem topo. The source process must have built the original topology with INCLUDE_DISALLOWED. This was disabled previously because allow(LOCAL) is supposed to add "LinuxCgroup" to the info attrs, which was not possible until we added topo infos in 3.0. Signed-off-by: Brice Goglin <[email protected]>
1 parent 74a02b5 commit 383a7d9

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Version 3.0.0
6161
+ HWLOC_PCI_<domain>_<bus>_LOCALCPUS environment variables,
6262
superseded with a single HWLOC_PCI_LOCALITY since 2.0.
6363
* Misc
64+
+ hwloc_topology_allow() is now possible on shmem-adopted topology.
65+
This allows to share a topology between processes in different
66+
Linux cgroups, etc.
6467
+ XML format switches to 3.0 by default. Exporting to 2.x is
6568
possible with the new V2 XML export flag.
6669

hwloc/topology.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4588,11 +4588,6 @@ hwloc_topology_allow(struct hwloc_topology *topology,
45884588
if (!(topology->state & HWLOC_TOPOLOGY_STATE_IS_LOADED))
45894589
goto einval;
45904590

4591-
if (topology->adopted_shmem_addr) {
4592-
errno = EPERM;
4593-
goto error;
4594-
}
4595-
45964591
if (!(topology->flags & HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED))
45974592
goto einval;
45984593

include/hwloc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,10 @@ enum hwloc_allow_flags_e {
26882688
*
26892689
* \return 0 on success, -1 on error.
26902690
*
2691+
* \note This function is allowed on an adopted topology (see \ref hwlocality_shmem).
2692+
* The flag ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED is required on the original
2693+
* topology (before sharing).
2694+
*
26912695
* \note Removing objects from a topology should rather be performed with
26922696
* hwloc_topology_restrict().
26932697
*/

include/hwloc/shmem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ HWLOC_DECLSPEC int hwloc_shmem_topology_write(hwloc_topology_t topology,
9898
* However the topology is read-only.
9999
* For instance, it cannot be modified with hwloc_topology_restrict()
100100
* and object userdata pointers cannot be changed.
101+
* The only exception is hwloc_topology_allow() which may be used to expose
102+
* a different set of allowed CPUs and memory. This requires that the original
103+
* topology (before sharing) was loaded with flag ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED.
101104
*
102105
* The segment of the file pointed by descriptor \p fd,
103106
* starting at offset \p fileoffset, and of length \p length (in bytes),

0 commit comments

Comments
 (0)