Skip to content

Commit

Permalink
linux+lstopo: disable memory binding in the linux backend on Android
Browse files Browse the repository at this point in the history
get_mempolicy() crashes on some Android (e.g. android10/aarch64/3.18)
and in some versions of the emulator in Android Studio.
It's used by lstopo for getting the current binding, but the Android
app doesn't need this anyway.

Disable the Linux membind hooks instead of just disabling get_*bind()
calls in lstopo.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Oct 6, 2020
1 parent 00cf0ab commit b821b72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 2 additions & 0 deletions hwloc/topology-linux.c
Expand Up @@ -2158,6 +2158,7 @@ hwloc_set_linuxfs_hooks(struct hwloc_binding_hooks *hooks,
hooks->get_thisthread_last_cpu_location = hwloc_linux_get_thisthread_last_cpu_location;
hooks->get_thisproc_last_cpu_location = hwloc_linux_get_thisproc_last_cpu_location;
hooks->get_proc_last_cpu_location = hwloc_linux_get_proc_last_cpu_location;
#ifndef ANDROID /* get_mempolicy crashes on some Android */
hooks->set_thisthread_membind = hwloc_linux_set_thisthread_membind;
hooks->get_thisthread_membind = hwloc_linux_get_thisthread_membind;
hooks->get_area_membind = hwloc_linux_get_area_membind;
Expand All @@ -2170,6 +2171,7 @@ hwloc_set_linuxfs_hooks(struct hwloc_binding_hooks *hooks,
support->membind->bind_membind = 1;
support->membind->interleave_membind = 1;
support->membind->migrate_membind = 1;
#endif
hooks->get_allowed_resources = hwloc_linux_get_allowed_resources_hook;

/* The get_allowed_resources() hook also works in the !thissystem case
Expand Down
4 changes: 0 additions & 4 deletions utils/lstopo/lstopo.c
Expand Up @@ -1469,22 +1469,18 @@ main (int argc, char *argv[])
}

hwloc_bitmap_fill(loutput.cpubind_set);
#ifndef ANDROID
if (loutput.pid_number != -1 && loutput.pid_number != 0)
hwloc_get_proc_cpubind(topology, loutput.pid, loutput.cpubind_set, 0);
else
/* get our binding even if --pid not given, it may be used by --restrict */
hwloc_get_cpubind(topology, loutput.cpubind_set, 0);
#endif

hwloc_bitmap_fill(loutput.membind_set);
#ifndef ANDROID
if (loutput.pid_number != -1 && loutput.pid_number != 0)
hwloc_get_proc_membind(topology, loutput.pid, loutput.membind_set, &policy, HWLOC_MEMBIND_BYNODESET);
else
/* get our binding even if --pid not given, it may be used by --restrict */
hwloc_get_membind(topology, loutput.membind_set, &policy, HWLOC_MEMBIND_BYNODESET);
#endif

loutput.need_pci_domain = lstopo_check_pci_domains(topology);

Expand Down

0 comments on commit b821b72

Please sign in to comment.