]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Fix handling of numa_domains(1)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Oct 2021 06:30:52 +0000 (08:30 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 19 Oct 2021 06:30:52 +0000 (08:30 +0200)
If numa-domains is used with num-places count, sometimes the function
could create more places than requested and crash.  This depended on the
content of /sys/devices/system/node/online file, e.g. if the file
contains
0-1,16-17
and all NUMA nodes contain at least one CPU in the cpuset of the program,
then numa_domains(2) or numa_domains(4) (or 5+) work fine while
numa_domains(1) or numa_domains(3) misbehave.  I.e. the function was able
to stop after reaching limit on the , separators (or trivially at the end),
but not within in the ranges.

2021-10-18  Jakub Jelinek  <jakub@redhat.com>

* config/linux/affinity.c (gomp_affinity_init_numa_domains): Add
&& gomp_places_list_len < count after nfirst <= nlast loop condition.

(cherry picked from commit 3adcf7e104284b4867996b08f37ece50056ee8f6)

libgomp/ChangeLog.omp
libgomp/config/linux/affinity.c

index 12291307b649d256ed8d358eab276ad0eb0aa2a3..157d89b9196506c92ffc75f5b69ee56ea182776c 100644 (file)
@@ -1,3 +1,11 @@
+2021-10-19  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-10-18  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/linux/affinity.c (gomp_affinity_init_numa_domains): Add
+       && gomp_places_list_len < count after nfirst <= nlast loop condition.
+
 2021-10-15  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
index e11906abec4a7f561fe57b90d6169e7bce6b1b76..ce86c5898c16e18843b7a97340620cb48019fd78 100644 (file)
@@ -401,7 +401,7 @@ gomp_affinity_init_numa_domains (unsigned long count, cpu_set_t *copy,
            break;
          q = end;
        }
-      for (; nfirst <= nlast; nfirst++)
+      for (; nfirst <= nlast && gomp_places_list_len < count; nfirst++)
        {
          sprintf (name + prefix_len, "node%lu/cpulist", nfirst);
          f = fopen (name, "r");