summaryrefslogtreecommitdiffstats
path: root/runtime/print.c
diff options
context:
space:
mode:
authorhunt <hunt>2007-01-30 19:18:06 +0000
committerhunt <hunt>2007-01-30 19:18:06 +0000
commiteaa5bbf4b8703e3794943f27d3fb9c1265dfd418 (patch)
tree354d34ca2b46ddd86f0f5de26345ce4fc753d6a9 /runtime/print.c
parentd21d36c05265b136246ae2c4ee9b5a38af46f45c (diff)
downloadsystemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.tar.gz
systemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.tar.xz
systemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.zip
2007-01-30 Martin Hunt <hunt@redhat.com>
* 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 >.
Diffstat (limited to 'runtime/print.c')
-rw-r--r--runtime/print.c17
1 files changed, 14 insertions, 3 deletions
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.