From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dormouse.ash.relay.mailchannels.net (dormouse.ash.relay.mailchannels.net [23.83.222.50]) by sourceware.org (Postfix) with ESMTPS id 7140E385742A for ; Tue, 17 May 2022 03:34:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7140E385742A 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 A837B121413; Tue, 17 May 2022 03:34:55 +0000 (UTC) Received: from pdx1-sub0-mail-a304.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 184011212B3; Tue, 17 May 2022 03:34:55 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1652758495; a=rsa-sha256; cv=none; b=2QGBf1bvTBn10Xz9XZzEVpivN5MiEBYZSUP3RQclxIudCNA2CB0O59YUquALo/yB3Z4qoN USFK9Ap286qxaCPrG+6DOgtwbmO3TnZn4er8WmvKITro2+XNDXpDSC2s81m5KsAyJiHzbg ULCTZ6ORN5W3VTfO6wLjzbvaAywMSdGbn+LfZ/oKI2Ubt26U86tDMkxvfPg28dKTfzjVWR 2PPqItE/0RU0T3i4cNiMsUxLgz/Nmw5tVBgQf0E7CzWX5vQkv+IDgSwMBaHts/x/vXZJ7k /bBzGSsgbSA3YiWbwxe67pHsyyT9CVPqVsk2WFPO9cJEp8Efj95uJZfj++mIOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1652758495; 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=rH0YU69uxUE+3iH9l8aA+wsOPg8Eut/KiID4qs9jE4Q=; b=iGMRAjis7tdNQTS2n0DdrC21tjK+DTJR+cqqmlZOepDGmE3LelxlmsKJRCnyJNFTCSTEsq CD5EwRLgExSBVhysu8ZNmKX4NAkVs6hzzjjh44hLc6vVqttZzv1wXc/Ltz/3kuoQACeiSW 0peoki/Qj6jftmzKVoApaNPCpcU8urwlUGF8PoUX9Gi1QEricCnTQLvk5homgT/Z1p3LfB +bKwWUE35s3Q4cPsqMgpR0A0p5FSPqYiMG53MxwnYk8FhkkpvM1JfFyEl3V2dAQ7UYyuwa xaHouT864WHuj7vd1K5wjqpY7uYxMMdQLofxuPm8Xk0YC60ZGl5wdDFsvw2KvQ== ARC-Authentication-Results: i=1; rspamd-6fcfc4d76-knsrf; 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-Suffer-Lyrical: 4189a71e430bf169_1652758495488_2099954602 X-MC-Loop-Signature: 1652758495488:3612130997 X-MC-Ingress-Time: 1652758495487 Received: from pdx1-sub0-mail-a304.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); Tue, 17 May 2022 03:34:55 +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-a304.dreamhost.com (Postfix) with ESMTPSA id 4L2MF94mcMzZW; Mon, 16 May 2022 20:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1652758494; bh=rH0YU69uxUE+3iH9l8aA+wsOPg8Eut/KiID4qs9jE4Q=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=btUrOFabgf7fnFUFV9zxw5OiX4Rcm+SzQLkT+oiQ9B9nourrfq6LEhvMFvep5KSdB WWoWjMZ4+xSlh051CRUUcta+L65rLQsPmWTnRLgiHglh7cK7++Sf8OpGHzSrRHzUfA d218llYxEJfuVlZF25ZQTS6iT0OUWs00yG4+hIwR5LwE8q9dWdBcqp1XaQixYuCvhy EkTFFkRqn/xQv+SLW3R7NiU44ox0OLuMyILhfom8MAYNvGJ7sn9sIGz1XANq8FQ0zB vnfyh832Ge43xnXhVKl/9FjDa7QjD7w9Lly1fQQNDKTbdbWFPjOtAujXvSbOhda04A N8DJfrETH/3Xg== Message-ID: <5dd79fed-d97f-b03a-e4c6-f79e4c72cc40@gotplt.org> Date: Tue, 17 May 2022 09:04:48 +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 v9 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> <20220516203004.38687-1-goldstein.w.n@gmail.com> From: Siddhesh Poyarekar In-Reply-To: <20220516203004.38687-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.7 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: Tue, 17 May 2022 03:35:02 -0000 On 17/05/2022 01:59, 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 | 37 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 39 insertions(+), 11 deletions(-) > create mode 100644 elf/dl-new-hash.h LGTM. Reviewed-by: Siddhesh Poyarekar > 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..b7a91ecc07 > --- /dev/null > +++ b/elf/dl-new-hash.h > @@ -0,0 +1,37 @@ > +/* _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 > +/* For __always_inline. */ > +#include > + > +static __always_inline uint32_t > +__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 */