unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell via Libc-alpha <libc-alpha@sourceware.org>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>, libc-alpha@sourceware.org
Cc: fweimer@redhat.com
Subject: Re: [PATCH v8 02/10] Remove __after_morecore_hook
Date: Sat, 17 Jul 2021 18:03:47 -0400	[thread overview]
Message-ID: <a0b93977-c829-8b85-ada5-f11f9e6a6c66@redhat.com> (raw)
In-Reply-To: <20210713073845.504356-3-siddhesh@sourceware.org>

On 7/13/21 3:38 AM, Siddhesh Poyarekar wrote:
> Remove __after_morecore_hook from the API and finalize the symbol so
> that it can no longer be used in new applications.  Old applications
> using __after_morecore_hook will find that their hook is no longer
> called.

OK for 2.34.

Tested without regression on x86_64 and i686.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  malloc/hooks.c  |  5 +++++
>  malloc/malloc.c | 22 +---------------------
>  malloc/malloc.h |  3 ---
>  3 files changed, 6 insertions(+), 24 deletions(-)
> 
> diff --git a/malloc/hooks.c b/malloc/hooks.c
> index daa5c7cfae..45c91d6502 100644
> --- a/malloc/hooks.c
> +++ b/malloc/hooks.c
> @@ -17,6 +17,11 @@
>     License along with the GNU C Library; see the file COPYING.LIB.  If
>     not, see <https://www.gnu.org/licenses/>.  */
>  
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34)
> +void weak_variable (*__after_morecore_hook) (void) = NULL;
> +compat_symbol (libc, __after_morecore_hook, __after_morecore_hook, GLIBC_2_0);

OK.

> +#endif
> +
>  /* Hooks for debugging versions.  The initial hooks just call the
>     initialization routine, then do the normal work. */
>  
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 154f6b460c..24e7854a0e 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -2041,8 +2041,6 @@ void *weak_variable (*__realloc_hook)
>  void *weak_variable (*__memalign_hook)
>    (size_t __alignment, size_t __size, const void *)
>    = memalign_hook_ini;
> -void weak_variable (*__after_morecore_hook) (void) = NULL;
> -

OK.

>  /* This function is called from the arena shutdown hook, to free the
>     thread cache (if it exists).  */
>  static void tcache_thread_shutdown (void);
> @@ -2668,14 +2666,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
>            LIBC_PROBE (memory_sbrk_more, 2, brk, size);
>          }
>  
> -      if (brk != (char *) (MORECORE_FAILURE))
> -        {
> -          /* Call the `morecore' hook if necessary.  */
> -          void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -          if (__builtin_expect (hook != NULL, 0))
> -            (*hook)();
> -        }
> -      else

OK.

> +      if (brk == (char *) (MORECORE_FAILURE))
>          {
>            /*
>               If have mmap, try using it as a backup when MORECORE fails or
> @@ -2814,13 +2805,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
>                        correction = 0;
>                        snd_brk = (char *) (MORECORE (0));
>                      }
> -                  else
> -                    {
> -                      /* Call the `morecore' hook if necessary.  */
> -                      void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -                      if (__builtin_expect (hook != NULL, 0))
> -                        (*hook)();
> -                    }

OK.

>                  }
>  
>                /* handle non-contiguous cases */
> @@ -2979,10 +2963,6 @@ systrim (size_t pad, mstate av)
>         */
>  
>        MORECORE (-extra);
> -      /* Call the `morecore' hook if necessary.  */
> -      void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -      if (__builtin_expect (hook != NULL, 0))
> -        (*hook)();

OK.

>        new_brk = (char *) (MORECORE (0));
>  
>        LIBC_PROBE (memory_sbrk_less, 2, new_brk, extra);
> diff --git a/malloc/malloc.h b/malloc/malloc.h
> index c1c0896d29..634b7db868 100644
> --- a/malloc/malloc.h
> +++ b/malloc/malloc.h
> @@ -179,9 +179,6 @@ extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,
>                                                         size_t __size,
>                                                         const void *)
>  __MALLOC_DEPRECATED;
> -extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void)
> -  __MALLOC_DEPRECATED;

OK.

> -
>  
>  __END_DECLS
>  #endif /* malloc.h */
> 


-- 
Cheers,
Carlos.


  reply	other threads:[~2021-07-17 22:05 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  7:38 [PATCH v8 00/10] malloc hooks removal Siddhesh Poyarekar via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 01/10] Make mcheck tests conditional on GLIBC_2.24 or earlier Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 02/10] Remove __after_morecore_hook Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03   ` Carlos O'Donell via Libc-alpha [this message]
2021-07-13  7:38 ` [PATCH v8 03/10] Remove __morecore and __default_morecore Siddhesh Poyarekar via Libc-alpha
2021-07-14  7:01   ` Siddhesh Poyarekar
2021-07-14 12:54     ` Guillaume Morin
2021-07-14 14:13       ` Siddhesh Poyarekar
2021-07-14 16:42         ` Guillaume Morin
2021-07-14 17:15           ` Carlos O'Donell via Libc-alpha
2021-07-14 17:42             ` Adhemerval Zanella via Libc-alpha
2021-07-14 18:37               ` Guillaume Morin
2021-07-14 18:48               ` Siddhesh Poyarekar
2021-07-14 18:31             ` Guillaume Morin
2021-07-14 17:32           ` Siddhesh Poyarekar
2021-07-14 18:25             ` Guillaume Morin
2021-07-14 18:43               ` Siddhesh Poyarekar
2021-07-14 18:51                 ` Guillaume Morin
2021-07-17 22:03   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 04/10] Move malloc hooks into a compat DSO Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 05/10] mcheck: Wean away from malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-13 15:47   ` H.J. Lu via Libc-alpha
2021-07-14  2:44     ` Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 06/10] Simplify __malloc_initialized Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 07/10] mtrace: Wean away from malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 08/10] glibc.malloc.check: " Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 09/10] Remove " Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13  7:38 ` [PATCH v8 10/10] mcheck Fix malloc_usable_size [BZ #22057] Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04   ` Carlos O'Donell via Libc-alpha
2021-07-13 14:48 ` [PATCH v8 00/10] malloc hooks removal H.J. Lu via Libc-alpha
2021-07-13 15:41   ` Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03 ` Carlos O'Donell via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0b93977-c829-8b85-ada5-f11f9e6a6c66@redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=siddhesh@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).