From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 23CA13858400 for ; Mon, 18 Oct 2021 13:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 23CA13858400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-9uxGEGI6MS--s1qJ8FxZvw-1; Mon, 18 Oct 2021 09:03:14 -0400 X-MC-Unique: 9uxGEGI6MS--s1qJ8FxZvw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E0D381CAF9; Mon, 18 Oct 2021 13:03:13 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B53718A42; Mon, 18 Oct 2021 13:03:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 19ID3AMY2431496 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 18 Oct 2021 15:03:10 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 19ID39Cv2431495; Mon, 18 Oct 2021 15:03:09 +0200 Date: Mon, 18 Oct 2021 15:03:08 +0200 From: Jakub Jelinek To: "sunil.k.pandey" Cc: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Fix handling of numa_domains(1) Message-ID: <20211018130308.GA304296@tucnak> Reply-To: Jakub Jelinek References: <20211015192634.69CD8286470F@gskx-2.sc.intel.com> MIME-Version: 1.0 In-Reply-To: <20211015192634.69CD8286470F@gskx-2.sc.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Oct 2021 13:03:21 -0000 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 > 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 * 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