From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 283463885C2A for ; Mon, 22 Jun 2020 21:15:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 283463885C2A 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-109-Hy6rxLvnPcCc55JJrz3AJQ-1; Mon, 22 Jun 2020 17:14:55 -0400 X-MC-Unique: Hy6rxLvnPcCc55JJrz3AJQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3946A0C03; Mon, 22 Jun 2020 21:14:53 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-185.ams2.redhat.com [10.36.112.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 153212B580; Mon, 22 Jun 2020 21:14:52 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: "H.J. Lu via Libc-alpha" , Joseph Myers Subject: Re: V3: [PATCH] x86: Install [BZ #26124] References: <20200617193100.1115529-1-hjl.tools@gmail.com> <87mu50rccl.fsf@oldenburg2.str.redhat.com> <87o8pbpiuy.fsf@oldenburg2.str.redhat.com> <87ftamg7ez.fsf@oldenburg2.str.redhat.com> Date: Mon, 22 Jun 2020 23:14:51 +0200 In-Reply-To: (H. J. Lu's message of "Mon, 22 Jun 2020 13:53:27 -0700") Message-ID: <87a70ug5v8.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2020 21:15:11 -0000 * H. J. Lu: > I changed the manual to > > @deftypefn Macro int HAS_CPU_FEATURE (@var{name}) > This macro returns a nonzero value (true) if the processor has the feature > @var{name}. > @end deftypefn > > @deftypefn Macro int CPU_FEATURE_USABLE (@var{name}) > This macro returns a nonzero value (true) if the processor feature > @var{name} is supported by the operating system. Does this mean that it's necessary to check both before using the feature? This is what the description implies to me. If CPU_FEATURE_USABLE implies HAS_CPU_FEATURE (so it's not necessary to check both), then I don't see the use case for HAS_CPU_FEATURE. To me, exposing both liks like a trap for programmers: they might check CPU support only, but not operating system support. That's trap that we have fallen into with glibc itself at least once. >> >> struct cpu_features (even in its reduced form) is fairly large. We will >> >> never be able to reduce its size again if it becomes public ABI. >> > >> > Fixed by >> > >> > struct cpu_features >> > { >> > struct cpu_features_basic basic; >> > unsigned int *usable_p; >> > struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX]; >> > }; >> >> I think the cpuid member is the fat part. But the pointer indirection >> allows us to grow the *usable_p part without having to duplicate the >> backing storage for __x86_get_cpu_features, so it is an improvement. >> >> > __builtin_cpu_supports is equivalent to CPU_FEATURE_USABLE and it >> > doesn't support HAS_CPU_FEATURE which does provide useful information. >> >> I'm still puzzled as to why you aren't extending the existing function. >> > > I am working on it: > > https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546522.html > > But it is very unlikely to support HAS_CPU_FEATURE and > works with all GCCs. On the other hand, it's easier for our users to upgrade GCC than to update glibc. Thanks, Florian