public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "sunil.k.pandey" <skpandey@sc.intel.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [committed] openmp: Fix handling of numa_domains(1)
Date: Mon, 18 Oct 2021 15:03:08 +0200	[thread overview]
Message-ID: <20211018130308.GA304296@tucnak> (raw)
In-Reply-To: <20211015192634.69CD8286470F@gskx-2.sc.intel.com>

On Fri, Oct 15, 2021 at 12:26:34PM -0700, sunil.k.pandey wrote:
> 4764049dd620affcd3e2658dc7f03a6616370a29 is the first bad commit
> commit 4764049dd620affcd3e2658dc7f03a6616370a29
> Author: Jakub Jelinek <jakub@redhat.com>
> Date:   Fri Oct 15 16:25:25 2021 +0200
> 
>     openmp: Fix up handling of OMP_PLACES=threads(1)
> 
> caused
> 
> FAIL: libgomp.c/places-10.c execution test

Reproduced on gcc112 in CompileFarm (my ws isn't NUMA).
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.

Fixed thusly, tested on powerpc64le-linux, committed to trunk.

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.

--- libgomp/config/linux/affinity.c.jj	2021-10-15 16:28:30.374460522 +0200
+++ libgomp/config/linux/affinity.c	2021-10-18 14:44:51.559667127 +0200
@@ -401,7 +401,7 @@ gomp_affinity_init_numa_domains (unsigne
 	    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");


	Jakub


  reply	other threads:[~2021-10-18 13:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 19:26 [r12-4438 Regression] FAIL: libgomp.c/places-10.c execution test on Linux/x86_64 sunil.k.pandey
2021-10-18 13:03 ` Jakub Jelinek [this message]
2021-11-11 13:14   ` [committed] openmp: Fix handling of numa_domains(1) Thomas Schwinge
2022-03-17 16:16     ` [PATCH] openmp: Fix up gomp_affinity_init_numa_domains Jakub Jelinek
2022-03-18  7:21       ` Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018130308.GA304296@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=skpandey@sc.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).