From patchwork Mon Feb 5 12:06:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 25794 Received: (qmail 71158 invoked by alias); 5 Feb 2018 12:06:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 70753 invoked by uid 89); 5 Feb 2018 12:06:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=11297 X-HELO: mail-ot0-f178.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Z67nqs++FhnUmGxOWWIj+R8NOsz+OtVMAWoXiBMkIzE=; b=E/YR6YsXP8Hngn/452FM2v34bsAvepkbUnofTXIZRdtttldoUTsVAXKcMA3qtQusyd PX9KKOEMzZAqzAgMReQdvyKqfRUoPZvGyVKIbabotY0YCwOROeW07BvTwpaH9+2+5EkW ok7XrOfvNIWR7YQIbXnaO4QKWcQGJh7MReA9PQMVCkMicPqt51qujONyyjtmK3cm1Koz eiZU9nMsrTRAdWaRWgwdeQuCZRZ8CfksjRcMBdm6Yl7btIKLyiSfNR6OG2Nib5hO9/s4 kv8sr87v9KLRq9L9ViE1+gJFky+nqwmaqEMZeXmxewSILN5iVUVcer4ZhD8Pe01JeNFK OkUA== X-Gm-Message-State: AKwxytfEBIy55dNtBCWSQ+JwHOeJ3OSsppbCOPFrb4vPViAd04QMvu4w 6crxOUkk1wWKFwxjGUzOExe/mw1gnK5Av0BEa+4= X-Google-Smtp-Source: AH8x224MRFoCkz4AMXrYmI2OAF+to3GvZd8GcqH2MaAwa2jBZlLb2iSD1w3rU3pYbhYPINvhisBhE9nhQIG/NUoXVTc= X-Received: by 10.157.21.119 with SMTP id z52mr17923251otz.234.1517832382074; Mon, 05 Feb 2018 04:06:22 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180202174246.GA12457@gmail.com> References: <20180202174246.GA12457@gmail.com> From: "H.J. Lu" Date: Mon, 5 Feb 2018 04:06:21 -0800 Message-ID: Subject: Re: [PATCH] x86-64: Use __glibc_likely/__glibc_likely in dl-machine.h To: GNU C Library On Fri, Feb 2, 2018 at 9:42 AM, H.J. Lu wrote: > OK for master? > > H.J. > --- > * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Replace > __builtin_expect with __glibc_likely and __glibc_likely. > (elf_machine_lazy_rel): Likewise. > --- > sysdeps/x86_64/dl-machine.h | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h > index f525600071..5d45ca5342 100644 > --- a/sysdeps/x86_64/dl-machine.h > +++ b/sysdeps/x86_64/dl-machine.h > @@ -310,10 +310,9 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, > : (ElfW(Addr)) sym_map->l_addr + sym->st_value); > > if (sym != NULL > - && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, > - 0) > - && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1) > - && __builtin_expect (!skip_ifunc, 1)) > + && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC) > + && __glibc_likely (sym->st_shndx != SHN_UNDEF) > + && __glibc_likely (!skip_ifunc)) > { > # ifndef RTLD_BOOTSTRAP > if (sym_map != map > @@ -500,8 +499,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, > break; > memcpy (reloc_addr_arg, (void *) value, > MIN (sym->st_size, refsym->st_size)); > - if (__builtin_expect (sym->st_size > refsym->st_size, 0) > - || (__builtin_expect (sym->st_size < refsym->st_size, 0) > + if (__glibc_unlikely (sym->st_size > refsym->st_size) > + || (__glibc_unlikely (sym->st_size < refsym->st_size) > && GLRO(dl_verbose))) > { > fmt = "\ > @@ -554,7 +553,8 @@ elf_machine_lazy_rel (struct link_map *map, > /* Check for unexpected PLT reloc type. */ > if (__glibc_likely (r_type == R_X86_64_JUMP_SLOT)) > { > - if (__builtin_expect (map->l_mach.plt, 0) == 0) > + /* Prelinked has been deprecated. */ > + if (__glibc_likely (map->l_mach.plt == 0)) > *reloc_addr += l_addr; > else > *reloc_addr = > -- > 2.14.3 > This is what I am checking in. From 84fb880a14b55e3212826d9b03b78a372306dfa6 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 2 Feb 2018 09:40:02 -0800 Subject: [PATCH] x86-64: Use __glibc_likely/__glibc_likely in dl-machine.h The differences in elf/dl-reloc.os are --- before 2018-02-05 03:52:32.803125207 -0800 +++ after 2018-02-05 03:52:14.913711879 -0800 @@ -1129,7 +1129,7 @@ _dl_relocate_object: leaq __PRETTY_FUNCTION__.9767(%rip), %rcx leaq .LC11(%rip), %rsi leaq .LC12(%rip), %rdi - movl $540, %edx + movl $539, %edx call __GI___assert_fail .p2align 4,,10 .p2align 3 * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Replace __builtin_expect with __glibc_likely and __glibc_likely. (elf_machine_lazy_rel): Likewise. --- sysdeps/x86_64/dl-machine.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index f525600071..5d45ca5342 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -310,10 +310,9 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, : (ElfW(Addr)) sym_map->l_addr + sym->st_value); if (sym != NULL - && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, - 0) - && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1) - && __builtin_expect (!skip_ifunc, 1)) + && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC) + && __glibc_likely (sym->st_shndx != SHN_UNDEF) + && __glibc_likely (!skip_ifunc)) { # ifndef RTLD_BOOTSTRAP if (sym_map != map @@ -500,8 +499,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, break; memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); - if (__builtin_expect (sym->st_size > refsym->st_size, 0) - || (__builtin_expect (sym->st_size < refsym->st_size, 0) + if (__glibc_unlikely (sym->st_size > refsym->st_size) + || (__glibc_unlikely (sym->st_size < refsym->st_size) && GLRO(dl_verbose))) { fmt = "\ @@ -554,7 +553,8 @@ elf_machine_lazy_rel (struct link_map *map, /* Check for unexpected PLT reloc type. */ if (__glibc_likely (r_type == R_X86_64_JUMP_SLOT)) { - if (__builtin_expect (map->l_mach.plt, 0) == 0) + /* Prelinked has been deprecated. */ + if (__glibc_likely (map->l_mach.plt == 0)) *reloc_addr += l_addr; else *reloc_addr = -- 2.14.3