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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EABD63858CD1 for ; Tue, 10 Oct 2023 07:57:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EABD63858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696924624; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=52v0/YsBxaD8Y+o0Sr3yJfOwlg0t3zENScbeBQWQZbI=; b=EJzQrMjQSDnsMHYAFpyiBVcIJNgSHrP5U/5raVM6zLhU675ehAgj6/Rq9F4GnJ7lQLn+Us mu10VMch9p528t6rPa4IFKUwEDO6ons29/BX//sdvW4/Rhzsdoe3S1sz9q0ilqtVPoZLlk kylmHga93UU1EwTGmyCMwK6mhPZLxus= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-678-PWNGtO7aMc60grUS5Vz5nA-1; Tue, 10 Oct 2023 03:57:03 -0400 X-MC-Unique: PWNGtO7aMc60grUS5Vz5nA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ECBD62999B29; Tue, 10 Oct 2023 07:57:02 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A899540C6EBF; Tue, 10 Oct 2023 07:57:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 39A7ux7V1112145 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 10 Oct 2023 09:57:00 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 39A7uw5f1112144; Tue, 10 Oct 2023 09:56:58 +0200 Date: Tue, 10 Oct 2023 09:56:58 +0200 From: Jakub Jelinek To: Jun Zhang Cc: gcc-patches@gcc.gnu.org, ubizjak@gmail.com, hongtao.liu@intel.com Subject: Re: [PATCH] x86: set spincount 1 for x86 hybrid platform [PR109812] Message-ID: Reply-To: Jakub Jelinek References: <20231010045952.572596-1-jun.zhang@intel.com> MIME-Version: 1.0 In-Reply-To: <20231010045952.572596-1-jun.zhang@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Oct 10, 2023 at 12:59:52PM +0800, Jun Zhang wrote: > include/ChangeLog: > > * omphook.h: define RUNOMPHOOK macro. ChangeLog formatting. The description should start with capital letter. If you add a new file, you should just mention : New file. or something similar. But much more importantly, we don't do hooks like that in libgomp, it should be better a static inline function where the name shows what it is doing (e.g. do_adjust_default_spincount), best in some already existing header (e.g. wait.h), and best at the end of the if (!parse_spincount ("GOMP_SPINCOUNT", &gomp_spin_count_var)) block in env.c. > > libgomp/ChangeLog: > > * env.c (initialize_env): add RUNOMPHOOK macro. > * config/linux/x86/omphook.h: define RUNOMPHOOK macro. > --- > include/omphook.h | 1 + > libgomp/config/linux/x86/omphook.h | 19 +++++++++++++++++++ > libgomp/env.c | 3 +++ > 3 files changed, 23 insertions(+) > create mode 100644 include/omphook.h > create mode 100644 libgomp/config/linux/x86/omphook.h > > diff --git a/include/omphook.h b/include/omphook.h > new file mode 100644 > index 00000000000..2ebe3ad57e6 > --- /dev/null > +++ b/include/omphook.h > @@ -0,0 +1 @@ > +#define RUNOMPHOOK() > diff --git a/libgomp/config/linux/x86/omphook.h b/libgomp/config/linux/x86/omphook.h > new file mode 100644 > index 00000000000..aefb311cc07 > --- /dev/null > +++ b/libgomp/config/linux/x86/omphook.h > @@ -0,0 +1,19 @@ > +#ifdef __x86_64__ > +#include "cpuid.h" > + > +/* only for x86 hybrid platform */ Comments should again start with capital letter and end with dot and 2 spaces before */ > +#define RUNOMPHOOK() \ > + do \ > + { \ > + unsigned int eax, ebx, ecx, edx; \ > + if ((getenv ("GOMP_SPINCOUNT") == NULL) && (wait_policy < 0) \ Spurious ()s around the subcondition, the first shouldn't be tested when placed right, if condition doesn't fit on one line, each subcondition should be on separate line. > + && __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx) \ If we don't have a macro for the CPUID.07H.0H:EDX[15] bit, there should be a comment which says what that bit is. > + && ((edx >> 15) & 1)) \ > + gomp_spin_count_var = 1LL; \ > + if (gomp_throttled_spin_count_var > gomp_spin_count_var) \ > + gomp_throttled_spin_count_var = gomp_spin_count_var; \ The above 2 lines won't be needed if placed right. Jakub