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.129.124]) by sourceware.org (Postfix) with ESMTPS id 157C13858D38 for ; Mon, 11 Sep 2023 16:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 157C13858D38 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=1694449175; h=from:from: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=TXsSno54RWM+PnxXpCf6rM/cIJ93hzrKhsaqYd+PCpQ=; b=S4AIYkwdRjpOxDipiWDr5kT1rTaUthGrDGVXA8UOayh+AlLw9CZyhcWW3ymaciTJbmCCZX wKJAN2fXaLDJPhrzy2G3R6/FSKLHFcB3IwZy36gDMq06wQA3HcPTrfHFSEFjhNj1I8ELHi 8Qpl9/btGh+GmcMcguhtAN881s3c6QI= 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-627-C-HDmiRaM3CFjsNL8RlPaw-1; Mon, 11 Sep 2023 12:19:34 -0400 X-MC-Unique: C-HDmiRaM3CFjsNL8RlPaw-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 B7D373C0FC8E; Mon, 11 Sep 2023 16:19:33 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43DA840C6EBF; Mon, 11 Sep 2023 16:19:33 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Netto Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 2/2] x86: Add generic CPUID data dumper to ld.so --list-diagnostics References: <4a77d6294e0023338a8115fad9a3d549c47cae87.1694203757.git.fweimer@redhat.com> Date: Mon, 11 Sep 2023 18:19:32 +0200 In-Reply-To: (Adhemerval Zanella Netto's message of "Mon, 11 Sep 2023 13:08:54 -0300") Message-ID: <87o7i8ptrf.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 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 X-Spam-Status: No, score=-4.9 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 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: * Adhemerval Zanella Netto: >> +void >> +_dl_diagnostics_cpu_kernel (void) >> +{ >> +#if !HAS_CPUID >> + /* CPUID is not supported, so there is nothing to dump. */ >> + if (__get_cpuid_max (0, 0) == 0) >> + return; >> +#endif > > I think we don't support __i486__ anymore, so we can just assume HAS_CPUID > at sysdeps/x86/include/cpu-features.h. We still build an i486 variant in build-many-glibcs.py. > Why not use the interfaces to work on cpuset? > > if (length_reference > 0) > { > int cpu_count = CPU_COUNT_S (length_reference, mask_reference); > for (int i = 0; i < cpu_count; i++) > { > if (CPU_ISSET_S (i, length_reference, mask_reference) > { > CPU_SET_S (i, length_reference, mask_request); > if (INTERNAL_SYSCALL_CALL (sched_setaffinity, 0, > length_reference, mask_request) == 0) > { > _dl_diagnostics_cpuid_collect (&ccd[i & 1]); > _dl_diagnostics_cpuid_report (processor_index, i, > &ccd[processor_index & 1], > &ccd[!(processor_index & 1)]); > ++processor_index; > } > CPU_CLR_S (i, length_reference, mask_request); > } > } > } > > I will iterate over the list twice, but I don't think this would really matter > here. I think the macros are somewhat incompatible with direct system calls. CPU_COUNT_S requires that the tail is zeroed, which the system call doesn't do. Maybe we can memset the whole thing before the sched_getcpu system call. I haven't tried if we can directly rebuild __sched_cpucount for ld.so, either. Thanks, Florian