2000-04-25  Ulrich Drepper  <drepper@redhat.com>

	* elf/dl-profile.c (_dl_mcount): Try to be thread-safe while not
	setting the state to GMON_PROF_BUSY.
This commit is contained in:
Ulrich Drepper 2000-04-25 07:40:56 +00:00
parent 128e2b0f0e
commit d472655c75
4 changed files with 28 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2000-04-25 Ulrich Drepper <drepper@redhat.com>
* elf/dl-profile.c (_dl_mcount): Try to be thread-safe while not
setting the state to GMON_PROF_BUSY.
2000-04-24 Ulrich Drepper <drepper@redhat.com> 2000-04-24 Ulrich Drepper <drepper@redhat.com>
* elf/dl-profile.c (_dl_start_profile): define all variables which * elf/dl-profile.c (_dl_start_profile): define all variables which

View File

@ -154,11 +154,11 @@ struct here_fromstruct
uint16_t link; uint16_t link;
}; };
static uint16_t *tos; static volatile uint16_t *tos;
static struct here_fromstruct *froms; static struct here_fromstruct *froms;
static size_t fromlimit; static uint32_t fromlimit;
static size_t fromidx; static volatile uint32_t fromidx;
static uintptr_t lowpc; static uintptr_t lowpc;
static size_t textsize; static size_t textsize;
@ -431,12 +431,15 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
void void
_dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
{ {
uint16_t *topcindex; volatile uint16_t *topcindex;
size_t i, fromindex; size_t i, fromindex;
struct here_fromstruct *fromp; struct here_fromstruct *fromp;
#if 0
/* XXX I think this is now not necessary anymore. */
if (! compare_and_swap (&state, GMON_PROF_ON, GMON_PROF_BUSY)) if (! compare_and_swap (&state, GMON_PROF_ON, GMON_PROF_BUSY))
return; return;
#endif
/* Compute relative addresses. The shared object can be loaded at /* Compute relative addresses. The shared object can be loaded at
any address. The value of frompc could be anything. We cannot any address. The value of frompc could be anything. We cannot
@ -491,31 +494,32 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
size_t newfromidx; size_t newfromidx;
to_index = (data[narcs].self_pc to_index = (data[narcs].self_pc
/ (hashfraction * sizeof (*tos))); / (hashfraction * sizeof (*tos)));
newfromidx = fromidx++; newfromidx = exchange_and_add (&fromidx, 1) + 1;
froms[newfromidx].here = &data[narcs]; froms[newfromidx].here = &data[narcs];
froms[newfromidx].link = tos[to_index]; froms[newfromidx].link = tos[to_index];
tos[to_index] = newfromidx; tos[to_index] = newfromidx;
++narcs; atomic_add (&narcs, 1);
} }
/* If we still have no entry stop searching and insert. */ /* If we still have no entry stop searching and insert. */
if (*topcindex == 0) if (*topcindex == 0)
{ {
size_t newarc = 1 + exchange_and_add (narcsp, 1); uint_fast32_t newarc = 1 + exchange_and_add (narcsp, 1);
/* In rare cases it could happen that all entries in FROMS are /* In rare cases it could happen that all entries in FROMS are
occupied. So we cannot count this anymore. */ occupied. So we cannot count this anymore. */
if (newarc >= fromlimit) if (newarc >= fromlimit)
goto done; goto done;
fromp = &froms[*topcindex = fromidx++]; *topcindex = exchange_and_add (&fromidx, 1) + 1;
fromp = &froms[*topcindex];
fromp->here = &data[newarc]; fromp->here = &data[newarc];
data[newarc].from_pc = frompc; data[newarc].from_pc = frompc;
data[newarc].self_pc = selfpc; data[newarc].self_pc = selfpc;
data[newarc].count = 0; data[newarc].count = 0;
fromp->link = 0; fromp->link = 0;
++narcs; atomic_add (&narcs, 1);
break; break;
} }
@ -531,5 +535,8 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
atomic_add (&fromp->here->count, 1); atomic_add (&fromp->here->count, 1);
done: done:
#if 0
/* XXX See above, Shouldn't be necessary anymore. */
state = GMON_PROF_ON; state = GMON_PROF_ON;
#endif
} }

View File

@ -1,3 +1,8 @@
2000-04-25 Ulrich Drepper <drepper@redhat.com>
* sysdeps/i386/i686/pt-machine.h: Do not use "../useldt.h" for
now. First gcc must be fixed (more concrete: libgcc).
2000-04-24 Ulrich Drepper <drepper@redhat.com> 2000-04-24 Ulrich Drepper <drepper@redhat.com>
* pthread.c: Remove special treatement for interrupt handlers on x86. * pthread.c: Remove special treatement for interrupt handlers on x86.

View File

@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions. /* Machine-dependent pthreads configuration and inline functions.
i686 version. i686 version.
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>. Contributed by Richard Henderson <rth@tamu.edu>.
@ -64,4 +64,4 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
/* Use the LDT implementation only if the kernel is fixed. */ /* Use the LDT implementation only if the kernel is fixed. */
#include "../useldt.h" //#include "../useldt.h"