Message ID | cover.1701947019.git.fweimer@redhat.com |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF85B385DC07 for <patchwork@sourceware.org>; Thu, 7 Dec 2023 11:05:30 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8D3CF3858C30 for <libc-alpha@sourceware.org>; Thu, 7 Dec 2023 11:05:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D3CF3858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8D3CF3858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701947119; cv=none; b=whxnDO5rEAgObVjB8gE71ziOEgY8NkBMNy+EWQLyDCz3cjocPK6kiAz/ZUyrlOS1/SwpQyfq4bDO6TbdsiVhdSlZVKS3Wn/DSjmjMtY6Tla8PSUgjo/uJutwMUTEWQ473TDuM9KrdjDOWwQmybOe8f9QF4/FlYL5noRSAAySrOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701947119; c=relaxed/simple; bh=6SQl2lntTqy8x5wxLwDz2+782qvVtWAtrRotdqNCO4I=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=bAycAgWdIB7MK2HnrrK+F2dmpmzsGvSIJTTLonhTs5ghpBf2ZgXFOhl4Na9TkRXozHj3q8nEITJLSqkKVjChz7j6jks+ZDQavjcUX+chW0746ay0QWQs1eg46lDley01nIdU1rQD3Qc4LdvOIYbW70l5h4Cwzz9bxadFNUkRrds= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701947118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=OCoz8Dm/TWAVdfWoDNnS/hpFNBspGtmDZZLD4n43srg=; b=MSrWYigVKkKFxI+WHVBlA+H90tjwHTHjG+pystzyct5sfo3NYRiHj9bPKcT1ikHehjLLR3 4FMjxtQX+iR2uYK7Tsfvt2vRuFsQHqqs9hAuUP6eBj+9dEWPuwt3wc8+UOnKohqAJyuRD7 QwSd0IgeBnn1lwxpiR9mhVDTmSSLJbc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-oBbbCwEEO0iSJqk3FFafJQ-1; Thu, 07 Dec 2023 06:05:16 -0500 X-MC-Unique: oBbbCwEEO0iSJqk3FFafJQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4FC0185A780 for <libc-alpha@sourceware.org>; Thu, 7 Dec 2023 11:05:16 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49E7C492BE6 for <libc-alpha@sourceware.org>; Thu, 7 Dec 2023 11:05:16 +0000 (UTC) From: Florian Weimer <fweimer@redhat.com> To: libc-alpha@sourceware.org Subject: [PATCH v2 0/2] Generic x86-64 CPU diagnostics dumper Message-ID: <cover.1701947019.git.fweimer@redhat.com> X-From-Line: 93a0eb152dea367f27e69253b337cfa739fa84ae Mon Sep 17 00:00:00 2001 Date: Thu, 07 Dec 2023 12:05:14 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org |
Series |
Generic x86-64 CPU diagnostics dumper
|
|
Message
Florian Weimer
Dec. 7, 2023, 11:05 a.m. UTC
This is an unchanged repost after a rebase. I hope to get this integrated so that I can work on further CPU compatibility diagnostics. The intent behind those is to give distributions better built-in tools to diagnose compatibility issues after they incorporate CPU-specific optimizations. Thanks, Florian Florian Weimer (2): elf: Wire up _dl_diagnostics_cpu_kernel x86: Add generic CPUID data dumper to ld.so --list-diagnostics elf/Makefile | 1 + elf/dl-diagnostics-cpu-kernel.c | 24 + elf/dl-diagnostics.c | 1 + elf/dl-diagnostics.h | 4 + manual/dynlink.texi | 86 +++- .../linux/x86/dl-diagnostics-cpu-kernel.c | 457 ++++++++++++++++++ 6 files changed, 572 insertions(+), 1 deletion(-) create mode 100644 elf/dl-diagnostics-cpu-kernel.c create mode 100644 sysdeps/unix/sysv/linux/x86/dl-diagnostics-cpu-kernel.c base-commit: 958478889c6a7a12b35b857b9788b7ad8706a01e
Comments
On 07/12/23 08:05, Florian Weimer wrote: > This is an unchanged repost after a rebase. > > I hope to get this integrated so that I can work on further CPU > compatibility diagnostics. The intent behind those is to give > distributions better built-in tools to diagnose compatibility issues > after they incorporate CPU-specific optimizations. What I would expect from ld.so --list-diagnostics was to dump some relevant information used on ifunc and other optimizations selection, with some meaningful text on the queried data from the kernel/CPU and which function would be selected based on the obtained information. Instead, we are moving towards a generic tool that dumps a lot of information that is either not directly relevant or requires some other tool to post-process it. This makes me wonder if it would be better to create a cpuid dumper/parser as a different program instead. > > Thanks, > Florian > > Florian Weimer (2): > elf: Wire up _dl_diagnostics_cpu_kernel > x86: Add generic CPUID data dumper to ld.so --list-diagnostics > > elf/Makefile | 1 + > elf/dl-diagnostics-cpu-kernel.c | 24 + > elf/dl-diagnostics.c | 1 + > elf/dl-diagnostics.h | 4 + > manual/dynlink.texi | 86 +++- > .../linux/x86/dl-diagnostics-cpu-kernel.c | 457 ++++++++++++++++++ > 6 files changed, 572 insertions(+), 1 deletion(-) > create mode 100644 elf/dl-diagnostics-cpu-kernel.c > create mode 100644 sysdeps/unix/sysv/linux/x86/dl-diagnostics-cpu-kernel.c > > > base-commit: 958478889c6a7a12b35b857b9788b7ad8706a01e
* Adhemerval Zanella Netto: > On 07/12/23 08:05, Florian Weimer wrote: >> This is an unchanged repost after a rebase. >> >> I hope to get this integrated so that I can work on further CPU >> compatibility diagnostics. The intent behind those is to give >> distributions better built-in tools to diagnose compatibility issues >> after they incorporate CPU-specific optimizations. > > What I would expect from ld.so --list-diagnostics was to dump some > relevant information used on ifunc and other optimizations selection, > with some meaningful text on the queried data from the kernel/CPU and > which function would be selected based on the obtained information. We don't know what GCC (__builtin_cpu_supports etc.) bases its selection on because it does not use the glibc interfaces. Even if we restricted this to other toolchain usage, we'd end up having to update it alongside GCC changes that add more selection logic. The generic dumper avoids that. Even inside glibc, we have logic that looks at CPUID data that is currently not captured in the dumps. > Instead, we are moving towards a generic tool that dumps a lot of > information that is either not directly relevant or requires some > other tool to post-process it. > > This makes me wonder if it would be better to create a cpuid > dumper/parser as a different program instead. Some people can read these dumps directly (so far, I don't). Even the limited, glibc-specific dumps we have today, which surprised me. Architecture-specific tools already exists, sure. The downside is that every architecture needs a different tool, and we would need to educate users and support staff to request the appropriate data for each architecture. I think in glibc, we are quite well-positioned to note what's important to include for each architecture (because we have such selection logic in glibc for the string functions) and provide an architecture-agnostic interface to capture the data for later analysis by someone with architecture-specific knowledge. Thanks, Florian
On 07/12/23 09:36, Florian Weimer wrote: > * Adhemerval Zanella Netto: > >> On 07/12/23 08:05, Florian Weimer wrote: >>> This is an unchanged repost after a rebase. >>> >>> I hope to get this integrated so that I can work on further CPU >>> compatibility diagnostics. The intent behind those is to give >>> distributions better built-in tools to diagnose compatibility issues >>> after they incorporate CPU-specific optimizations. >> >> What I would expect from ld.so --list-diagnostics was to dump some >> relevant information used on ifunc and other optimizations selection, >> with some meaningful text on the queried data from the kernel/CPU and >> which function would be selected based on the obtained information. > > We don't know what GCC (__builtin_cpu_supports etc.) bases its selection > on because it does not use the glibc interfaces. Even if we restricted > this to other toolchain usage, we'd end up having to update it alongside > GCC changes that add more selection logic. The generic dumper avoids > that. > > Even inside glibc, we have logic that looks at CPUID data that is > currently not captured in the dumps. But my understanding is --list-diagnostics should be limited to own glibc selection; it does not make much sense to trying to sync with other interfaces (__builtin_cpu_supports) if there use a complete different selection interface. > >> Instead, we are moving towards a generic tool that dumps a lot of >> information that is either not directly relevant or requires some >> other tool to post-process it. >> >> This makes me wonder if it would be better to create a cpuid >> dumper/parser as a different program instead. > > Some people can read these dumps directly (so far, I don't). Even the > limited, glibc-specific dumps we have today, which surprised me.> > Architecture-specific tools already exists, sure. The downside is that > every architecture needs a different tool, and we would need to educate > users and support staff to request the appropriate data for each > architecture. I think in glibc, we are quite well-positioned to note > what's important to include for each architecture (because we have such > selection logic in glibc for the string functions) and provide an > architecture-agnostic interface to capture the data for later analysis > by someone with architecture-specific knowledge. Right, but currently --list-diagnostics dumps around 100 lines related to x86 on my system. Although some are straightforward (like cache size), some are really specific to implementation detail, like the x86.cpu_features.features vs x86.cpu_features.preferred and the preferred fields description. Also, such information can be queries either by accessing cpuid itself and/or with x86.h specific ABI (from x86.h). My questioning is if this really required to be on ld.so.
* Adhemerval Zanella Netto: > On 07/12/23 09:36, Florian Weimer wrote: >> * Adhemerval Zanella Netto: >> >>> On 07/12/23 08:05, Florian Weimer wrote: >>>> This is an unchanged repost after a rebase. >>>> >>>> I hope to get this integrated so that I can work on further CPU >>>> compatibility diagnostics. The intent behind those is to give >>>> distributions better built-in tools to diagnose compatibility issues >>>> after they incorporate CPU-specific optimizations. >>> >>> What I would expect from ld.so --list-diagnostics was to dump some >>> relevant information used on ifunc and other optimizations selection, >>> with some meaningful text on the queried data from the kernel/CPU and >>> which function would be selected based on the obtained information. >> >> We don't know what GCC (__builtin_cpu_supports etc.) bases its selection >> on because it does not use the glibc interfaces. Even if we restricted >> this to other toolchain usage, we'd end up having to update it alongside >> GCC changes that add more selection logic. The generic dumper avoids >> that. >> >> Even inside glibc, we have logic that looks at CPUID data that is >> currently not captured in the dumps. > > But my understanding is --list-diagnostics should be limited to own > glibc selection; it does not make much sense to trying to sync with > other interfaces (__builtin_cpu_supports) if there use a complete > different selection interface. I think we should consider the whole GNU toolchain, not just glibc. Just as in other cases. > Right, but currently --list-diagnostics dumps around 100 lines related to > x86 on my system. Although some are straightforward (like cache size), > some are really specific to implementation detail, like the > x86.cpu_features.features vs x86.cpu_features.preferred and the preferred > fields description. Yes, and those are required to diagnose issues with IFUNC selection and other aspects of self-configuration. Even so, the current dumps are insufficient to trace how glibc comes up with the cache information for sysconf. They also do not cover asymmetric reporting across multiple cores. > Also, such information can be queries either by accessing cpuid itself > and/or with x86.h specific ABI (from x86.h). My questioning is if this > really required to be on ld.so. If we don't put it into a cross-architecture project, then we'll have to teach everyone to use the appropriate tool for gathering such data on every architecture. This makes switching between architectures more difficult. I don't think we can get non-x86 CPU support into cpuid <http://www.etallen.com/cpuid.html>. Thanks, Florian