From eaa5bbf4b8703e3794943f27d3fb9c1265dfd418 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 30 Jan 2007 19:18:06 +0000 Subject: 2007-01-30 Martin Hunt * io.c (_stp_vlog): Use dynamic percpu allocations instead of very wasteful static allocations. * print.c (_stp_print_init): Do percpu allocations for io.c. (_stp_print_cleanup): Free percpu allocations. * string.c (_stp_sprintf): Overflow check needed to be >= instead of >. --- runtime/print.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'runtime/print.c') diff --git a/runtime/print.c b/runtime/print.c index d305dee8..8ddafab8 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -1,6 +1,6 @@ /* -*- linux-c -*- * Print Functions - * Copyright (C) 2005, 2006 Red Hat Inc. + * Copyright (C) 2005, 2006, 2007 Red Hat Inc. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -12,8 +12,9 @@ #define _PRINT_C_ #include "string.h" -#include "io.c" #include "vsprintf.c" +#include "io.c" + /** @file print.c * Printing Functions. @@ -50,12 +51,20 @@ typedef struct __stp_pbuf { void *Stp_pbuf = NULL; +/* create percpu print and io buffers */ int _stp_print_init (void) { Stp_pbuf = alloc_percpu(_stp_pbuf); if (unlikely(Stp_pbuf == 0)) return -1; - _stp_allocated_memory += sizeof(_stp_pbuf) * num_online_cpus(); + + /* now initialize IO buffer used in io.c */ + Stp_lbuf = alloc_percpu(_stp_lbuf); + if (unlikely(Stp_lbuf == 0)) { + free_percpu(Stp_pbuf); + return -1; + } + _stp_allocated_memory += (sizeof(_stp_pbuf)+sizeof(_stp_lbuf)) * num_online_cpus(); return 0; } @@ -63,6 +72,8 @@ void _stp_print_cleanup (void) { if (Stp_pbuf) free_percpu(Stp_pbuf); + if (Stp_lbuf) + free_percpu(Stp_lbuf); } /** Send the print buffer to the transport now. -- cgit