mirror of git://sourceware.org/git/glibc.git
* nscd/nscd.h (MAX_STACK_USE): Define.
* nscd/mem.c (MAX_STACK_USE): Remove definition here. (gc): Initialize stack_used based on allocation in prune_cache. * nscd/cache.c (prune_cache): Use heap for mark array if necessary. Clear array bfore use. * nscd/aicache.c (addhstaiX): Update statistics counter in case memory allocate failed.
This commit is contained in:
parent
609bb0712d
commit
30294ea449
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2007-11-25 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nscd/nscd.h (MAX_STACK_USE): Define.
|
||||||
|
* nscd/mem.c (MAX_STACK_USE): Remove definition here.
|
||||||
|
(gc): Initialize stack_used based on allocation in prune_cache.
|
||||||
|
* nscd/cache.c (prune_cache): Use heap for mark array if necessary.
|
||||||
|
Clear array bfore use.
|
||||||
|
|
||||||
|
* nscd/aicache.c (addhstaiX): Update statistics counter in case
|
||||||
|
memory allocate failed.
|
||||||
|
|
||||||
2007-11-23 Ulrich Drepper <drepper@redhat.com>
|
2007-11-23 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Add open
|
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Add open
|
||||||
|
|
|
@ -339,7 +339,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
|
||||||
= (struct dataset *) mempool_alloc (db,
|
= (struct dataset *) mempool_alloc (db,
|
||||||
total
|
total
|
||||||
+ req->key_len);
|
+ req->key_len);
|
||||||
if (newp != NULL)
|
if (__builtin_expect (newp != NULL, 1))
|
||||||
{
|
{
|
||||||
/* Adjust pointer into the memory block. */
|
/* Adjust pointer into the memory block. */
|
||||||
key_copy = (char *) newp + (key_copy
|
key_copy = (char *) newp + (key_copy
|
||||||
|
@ -349,6 +349,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
|
||||||
total + req->key_len);
|
total + req->key_len);
|
||||||
alloca_used = false;
|
alloca_used = false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
++db->head->addfailed;
|
||||||
|
|
||||||
/* Mark the old record as obsolete. */
|
/* Mark the old record as obsolete. */
|
||||||
dh->usable = false;
|
dh->usable = false;
|
||||||
|
|
22
nscd/cache.c
22
nscd/cache.c
|
@ -36,6 +36,10 @@
|
||||||
#include "dbg_log.h"
|
#include "dbg_log.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Wrapper functions with error checking for standard functions. */
|
||||||
|
extern void *xcalloc (size_t n, size_t s);
|
||||||
|
|
||||||
|
|
||||||
/* Number of times a value is reloaded without being used. UINT_MAX
|
/* Number of times a value is reloaded without being used. UINT_MAX
|
||||||
means unlimited. */
|
means unlimited. */
|
||||||
unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
|
unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
|
||||||
|
@ -278,7 +282,20 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
|
||||||
we don't need to get any lock. It is at all timed assured that the
|
we don't need to get any lock. It is at all timed assured that the
|
||||||
linked lists are set up correctly and that no second thread prunes
|
linked lists are set up correctly and that no second thread prunes
|
||||||
the cache. */
|
the cache. */
|
||||||
bool mark[cnt];
|
bool *mark;
|
||||||
|
size_t memory_needed = cnt * sizeof (bool);
|
||||||
|
bool mark_use_alloca;
|
||||||
|
if (__builtin_expect (memory_needed <= MAX_STACK_USE, 1))
|
||||||
|
{
|
||||||
|
mark = alloca (cnt * sizeof (bool));
|
||||||
|
memset (mark, '\0', memory_needed);
|
||||||
|
mark_use_alloca = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mark = xcalloc (1, memory_needed);
|
||||||
|
mark_use_alloca = false;
|
||||||
|
}
|
||||||
size_t first = cnt + 1;
|
size_t first = cnt + 1;
|
||||||
size_t last = 0;
|
size_t last = 0;
|
||||||
char *const data = table->data;
|
char *const data = table->data;
|
||||||
|
@ -471,6 +488,9 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (__builtin_expect (mark_use_alloca, 0))
|
||||||
|
free (mark);
|
||||||
|
|
||||||
/* Run garbage collection if any entry has been removed or replaced. */
|
/* Run garbage collection if any entry has been removed or replaced. */
|
||||||
if (any)
|
if (any)
|
||||||
gc (table);
|
gc (table);
|
||||||
|
|
10
nscd/mem.c
10
nscd/mem.c
|
@ -74,10 +74,6 @@ sort_he_data (const void *p1, const void *p2)
|
||||||
#define ALLBITS ((((BITMAP_T) 1) << BITS) - 1)
|
#define ALLBITS ((((BITMAP_T) 1) << BITS) - 1)
|
||||||
#define HIGHBIT (((BITMAP_T) 1) << (BITS - 1))
|
#define HIGHBIT (((BITMAP_T) 1) << (BITS - 1))
|
||||||
|
|
||||||
/* Maximum size of stack frames we allow the thread to use. We use
|
|
||||||
80% of the thread stack size. */
|
|
||||||
#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
markrange (BITMAP_T *mark, ref_t start, size_t len)
|
markrange (BITMAP_T *mark, ref_t start, size_t len)
|
||||||
|
@ -129,7 +125,11 @@ gc (struct database_dyn *db)
|
||||||
|
|
||||||
BITMAP_T *mark;
|
BITMAP_T *mark;
|
||||||
bool mark_use_malloc;
|
bool mark_use_malloc;
|
||||||
size_t stack_used = 0;
|
/* In prune_cache we are also using a dynamically allocated array.
|
||||||
|
If the array in the caller is too large we have malloc'ed it. */
|
||||||
|
size_t stack_used = sizeof (bool) * db->head->module;
|
||||||
|
if (__builtin_expect (stack_used > MAX_STACK_USE, 0))
|
||||||
|
stack_used = 0;
|
||||||
size_t memory_needed = ((db->head->first_free / BLOCK_ALIGN + BITS - 1)
|
size_t memory_needed = ((db->head->first_free / BLOCK_ALIGN + BITS - 1)
|
||||||
/ BITS) * sizeof (BITMAP_T);
|
/ BITS) * sizeof (BITMAP_T);
|
||||||
if (memory_needed <= MAX_STACK_USE)
|
if (memory_needed <= MAX_STACK_USE)
|
||||||
|
|
|
@ -58,6 +58,10 @@ typedef enum
|
||||||
/* Stack size for worker threads. */
|
/* Stack size for worker threads. */
|
||||||
#define NSCD_THREAD_STACKSIZE 1024 * 1024 * (sizeof (void *) / 4)
|
#define NSCD_THREAD_STACKSIZE 1024 * 1024 * (sizeof (void *) / 4)
|
||||||
|
|
||||||
|
/* Maximum size of stack frames we allow the thread to use. We use
|
||||||
|
80% of the thread stack size. */
|
||||||
|
#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
|
||||||
|
|
||||||
|
|
||||||
/* Structure describing dynamic part of one database. */
|
/* Structure describing dynamic part of one database. */
|
||||||
struct database_dyn
|
struct database_dyn
|
||||||
|
|
Loading…
Reference in New Issue