From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bumble.birch.relay.mailchannels.net (bumble.birch.relay.mailchannels.net [23.83.209.25]) by sourceware.org (Postfix) with ESMTPS id C71003857363 for ; Mon, 16 May 2022 13:57:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C71003857363 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6704F6C2556; Mon, 16 May 2022 13:57:04 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4DD2A6C27AF; Mon, 16 May 2022 13:57:03 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1652709423; a=rsa-sha256; cv=none; b=U5Sunw0JDygxAyV4RSYzaAuGTrM4PnoWMphTZHTThzUqDNeHx1xSUaGhBf/G1B45w1DG5p nZAzrWgQaov8diS3TaaVvpRrXOm9vdcpEw0L2Lvll2KacIHc0Dkka9hs1uG3fi53eVhak7 yTv3XptqXt9AfOhVmQV8hREjOeBD0I8mG4VM4FoBb69GqtE3I7Cj038bkLX23vVBYHwZ9L 3ZjvwXmbkWbrbvm6GAHf4b0bi9kXW9oqmRFOa7fSZX/piyVXG+qndesPAfKYrEj+k1sDkm o8SJiVR+CiQxFCH5Y8d+IAQtxDcXiyZxKF0KeHh4vr4Wvfd03+V7Z7puERqBcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1652709423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/KH9uU7v4+2iJHMubOz2uS9L4qYkjg8FSq2GzRlpD1M=; b=7wooEcCWOWXwaPr5zjOVUWS5Uo1IFMV/YAaat248VYabDNM+MDw2tQajc1mFjX9CxZuqiM mL4lMUWxj0G0nRFY41UqyBtr+9wP2D3e/ZO5Mlpqti0Ds09JBSL9tpZxkpuueL/WgHWcqt Y0P6/pPdX46tjkfYgEfPaTFaCIXOWuMC9dSKwsFQWNeV9y9Fze5t7S4lqPmpdR0ib0GogN ANtKVa+w16i9JdHWk+3w2UTuPgRZd1D8qvCWW00OblWbhbHLioyysI0vg/eAoV0yYHzWw4 1S+2ltQdnc7+moPr2/gCGWt8jc82RHxpGmwtuXe3Mfel6Yw6Ud11LuYnvPYP1w== ARC-Authentication-Results: i=1; rspamd-6fcfc4d76-qb8m4; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Slimy-Tart: 3b373d22007a20b0_1652709423964_1782998928 X-MC-Loop-Signature: 1652709423964:2858808157 X-MC-Ingress-Time: 1652709423964 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.55.220 (trex/6.7.1); Mon, 16 May 2022 13:57:03 +0000 Received: from [192.168.1.174] (unknown [1.186.223.88]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4L215V0933z1PY; Mon, 16 May 2022 06:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1652709422; bh=/KH9uU7v4+2iJHMubOz2uS9L4qYkjg8FSq2GzRlpD1M=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=VmydIHb6iFIQOSubNDlWuWFn+Mlb4xe5/l5UHgWqiwU8gd1wcfudq5clsOc801u7Y /zPS5qSIBf2Mj1MOsXvvDIZBcSdZQsh4CD6DgsqPtELvZT0h4cA6DbpGPZZJEh6Fcb c/0COuRbEJg+L9MT9BBIXRiEPPzGB0QwQRcrJCZ+ZOsg9WrfD6cdxLS1E8+VE2vNGk fencFsCOx2HRSiNjwjDb/9p6m35qK90RBmY9/sgHFD5Pau7nC6JLroqVotVhgNWxOU PrljjXGX4UA5Y3ueYaYjZpgTdAAkebyqXGhwuOQS0UWReoLtXpF9OjpTlvdAn/MlWd s1lHsgoeSAPGw== Message-ID: <09d1e275-17dd-3a75-bc8e-fb3d5b15f5a5@gotplt.org> Date: Mon, 16 May 2022 19:26:57 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v8 1/6] elf: Refactor dl_new_hash so it can be tested / benchmarked Content-Language: en-US To: Noah Goldstein , libc-alpha@sourceware.org References: <20220414041231.926415-1-goldstein.w.n@gmail.com> <20220511030635.154689-1-goldstein.w.n@gmail.com> From: Siddhesh Poyarekar In-Reply-To: <20220511030635.154689-1-goldstein.w.n@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3036.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 13:57:08 -0000 On 11/05/2022 08:36, Noah Goldstein via Libc-alpha wrote: > No change to the code other than moving the function to > dl-new-hash.h. Changed name so its now in the reserved namespace. > --- > elf/dl-lookup.c | 13 ++----------- > elf/dl-new-hash.h | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 37 insertions(+), 11 deletions(-) > create mode 100644 elf/dl-new-hash.h > > diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c > index 989b073e4f..a42f6d5390 100644 > --- a/elf/dl-lookup.c > +++ b/elf/dl-lookup.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -558,16 +559,6 @@ skip: > } > > > -static uint32_t > -dl_new_hash (const char *s) > -{ > - uint32_t h = 5381; > - for (unsigned char c = *s; c != '\0'; c = *++s) > - h = h * 33 + c; > - return h; > -} > - > - > /* Add extra dependency on MAP to UNDEF_MAP. */ > static int > add_dependency (struct link_map *undef_map, struct link_map *map, int flags) > @@ -816,7 +807,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, > const struct r_found_version *version, > int type_class, int flags, struct link_map *skip_map) > { > - const unsigned int new_hash = dl_new_hash (undef_name); > + const unsigned int new_hash = _dl_new_hash (undef_name); > unsigned long int old_hash = 0xffffffff; > struct sym_val current_value = { NULL, NULL }; > struct r_scope_elem **scope = symbol_scope; > diff --git a/elf/dl-new-hash.h b/elf/dl-new-hash.h > new file mode 100644 > index 0000000000..40d88c81f9 > --- /dev/null > +++ b/elf/dl-new-hash.h > @@ -0,0 +1,35 @@ > +/* _dl_new_hash for elf symbol lookup > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef _DL_NEW_HASH_H > +#define _DL_NEW_HASH_H 1 > + > +#include > + > +static inline uint32_t This has only one caller and ISTM that it's always desirable to inline this, so use __always_inline instead. > +__attribute__ ((unused)) > +_dl_new_hash (const char *s) > +{ > + uint32_t h = 5381; > + for (unsigned char c = *s; c != '\0'; c = *++s) > + h = h * 33 + c; > + return h; > +} > + > + > +#endif /* dl-new-hash.h */