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 E47333858C74 for ; Thu, 13 Jul 2023 07:07:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E47333858C74 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=1689232065; 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=DNEOhyP/MX7XN8QYYtznG41sTP82MpDJkRvJC1wA5P4=; b=ThbH/wkAhbmb63IziqwlqMoIG88z07NEblPIRZLSzg0vXpH3QTezjPnHu3FLe5W9jyQoPY ezI8YIEBlwl/hDkJM5ijS+bkV1JRQF4XtzqDkeQuFJwyr9/zkQuRlqH5iwggdhGEilzO4S iFp+h46/djyDhK010HpM9t9Qjlhhl0U= Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-573-QbXQhV-XNPesWoADuCKmRA-1; Thu, 13 Jul 2023 03:07:42 -0400 X-MC-Unique: QbXQhV-XNPesWoADuCKmRA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2E4D1C17110; Thu, 13 Jul 2023 07:07:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B720EF7820; Thu, 13 Jul 2023 07:07:40 +0000 (UTC) From: Florian Weimer To: Evan Green Cc: libc-alpha@sourceware.org, vineetg@rivosinc.com, slewis@rivosinc.com, palmer@rivosinc.com Subject: Re: [PATCH v5 3/4] riscv: Add ifunc-compatible hwprobe function References: <20230712193629.2880253-1-evan@rivosinc.com> <20230712193629.2880253-4-evan@rivosinc.com> Date: Thu, 13 Jul 2023 09:07:39 +0200 In-Reply-To: <20230712193629.2880253-4-evan@rivosinc.com> (Evan Green's message of "Wed, 12 Jul 2023 12:36:27 -0700") Message-ID: <87h6q82ssk.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.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 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_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 List-Id: * Evan Green: > diff --git a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h > index b27af5cb07..d739371806 100644 > --- a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h > +++ b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h > @@ -67,6 +67,27 @@ extern int __riscv_hwprobe (struct riscv_hwprobe *pairs, size_t pair_count, > __fortified_attr_access (__read_write__, 1, 2) > __fortified_attr_access (__read_only__, 4, 3); > > +extern int __riscv_hwprobe_weak (struct riscv_hwprobe *pairs, size_t pair_count, > + size_t cpu_count, unsigned long int *cpus, > + unsigned int flags) > + __THROW __nonnull ((1)) __wur > + __fortified_attr_access (__read_write__, 1, 2) > + __fortified_attr_access (__read_only__, 4, 3); > + > +# ifdef weak_extern > +weak_extern (__riscv_hwprobe_weak) > +# else > +# pragma weak __riscv_hwprobe_weak > +# endif > + > +extern int __riscv_hwprobe_early (struct riscv_hwprobe *pairs, size_t pair_count, > + size_t cpu_count, unsigned long int *cpus, > + unsigned int flags) > + __THROW __nonnull ((1)) __wur > + __fortified_attr_access (__read_write__, 1, 2) > + __fortified_attr_access (__read_only__, 4, 3) > + __attribute__ ((__visibility__ ("hidden"))); > + > __END_DECLS > > #endif /* sys/hwprobe.h */ I would call the dynamic symbol ___riscv_hwprobe, not __riscv_hwprobe_weak. The weak property is an implementation detail in the C file that goes into libc_nonshared. And ___riscv_hwprobe does not need to be declared in an installed header, I think it's fine to offer __riscv_hwprobe only. Use of INTERNAL_SYSCALL is correct because without relocations, errno will not work, but it needs to match across all implementations. This means using INTERNAL_VSYSCALL instead of INLINE_VSYSCALL. There needs to be manual entry that documents the exact interface conventions. If the function returns 0 on success (no positive return values), it may make sense to negate the result value that comes back from the kernel because that matches what some pthread interfaces use. We probabl use the -EINVAL convention on some external API (it's a big library), but I think it's on the unusual side. Thanks, Florian