diff options
author | hunt <hunt> | 2006-09-22 01:32:12 +0000 |
---|---|---|
committer | hunt <hunt> | 2006-09-22 01:32:12 +0000 |
commit | 77930524463d7750950ec055c42dbf3703442010 (patch) | |
tree | 78ca8dedb5aa80e2d972086775d13774bd530683 | |
parent | 77c3c4b3a6065638ddf6a6ec45b9694fff40bc0a (diff) | |
download | systemtap-steved-77930524463d7750950ec055c42dbf3703442010.tar.gz systemtap-steved-77930524463d7750950ec055c42dbf3703442010.tar.xz systemtap-steved-77930524463d7750950ec055c42dbf3703442010.zip |
2006-09-21 Martin Hunt <hunt@redhat.com>
PR 3232
* print.c (_stp_print_init): New. Alloc per-cpu buffers.
(_stp_print_cleanup): New. Free per-cpu buffers.
(_stp_print_flush): Use per_cpu_ptr().
* string.c (_stp_sprintf): Ditto.
(_stp_vsprintf): Ditto.
(_stp_string_cat_cstr): Ditto.
(_stp_string_cat_char): Ditto.
-rw-r--r-- | runtime/ChangeLog | 11 | ||||
-rw-r--r-- | runtime/print.c | 19 | ||||
-rw-r--r-- | runtime/string.c | 8 |
3 files changed, 31 insertions, 7 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 8dd6cd52..f9813616 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,14 @@ +2006-09-21 Martin Hunt <hunt@redhat.com> + PR 3232 + * print.c (_stp_print_init): New. Alloc per-cpu buffers. + (_stp_print_cleanup): New. Free per-cpu buffers. + (_stp_print_flush): Use per_cpu_ptr(). + * string.c (_stp_sprintf): Ditto. + (_stp_vsprintf): Ditto. + (_stp_string_cat_cstr): Ditto. + (_stp_string_cat_char): Ditto. + + 2006-09-20 Josh Stone <joshua.i.stone@intel.com> PR 3233 diff --git a/runtime/print.c b/runtime/print.c index 65b2d37f..674bd4a0 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -51,8 +51,21 @@ typedef struct __stp_pbuf { char buf[STP_PRINT_BUF_LEN]; } _stp_pbuf; -DEFINE_PER_CPU(_stp_pbuf, Stp_pbuf); +void *Stp_pbuf = NULL; +int _stp_print_init (void) +{ + Stp_pbuf = alloc_percpu(_stp_pbuf); + if (unlikely(Stp_pbuf == 0)) + return -1; + return 0; +} + +void _stp_print_cleanup (void) +{ + if (Stp_pbuf) + free_percpu(Stp_pbuf); +} /** Send the print buffer to the transport now. * Output accumulates in the print buffer until it @@ -63,7 +76,7 @@ DEFINE_PER_CPU(_stp_pbuf, Stp_pbuf); */ void _stp_print_flush (void) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); /* check to see if there is anything in the buffer */ if (pb->len == 0) @@ -104,7 +117,7 @@ static void * _stp_reserve_bytes (int numbytes) #else static void * _stp_reserve_bytes (int numbytes) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); int size = STP_PRINT_BUF_LEN - pb->len; void * ret; diff --git a/runtime/string.c b/runtime/string.c index a413ad76..4c92f591 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -58,7 +58,7 @@ void _stp_sprintf (String str, const char *fmt, ...) int num; va_list args; if (str == _stp_stdout) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); char *buf = pb->buf + pb->len; int size = STP_PRINT_BUF_LEN - pb->len; va_start(args, fmt); @@ -100,7 +100,7 @@ void _stp_vsprintf (String str, const char *fmt, va_list args) { int num; if (str == _stp_stdout) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); char *buf = pb->buf + pb->len; int size = STP_PRINT_BUF_LEN - pb->len; num = _stp_vsnprintf(buf, size, fmt, args); @@ -138,7 +138,7 @@ void _stp_string_cat_cstr (String str1, const char *str2) { int num = strlen (str2); if (str1 == _stp_stdout) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); int size = STP_PRINT_BUF_LEN - pb->len; if (num > size) { _stp_print_flush(); @@ -173,7 +173,7 @@ void _stp_string_cat_string (String str1, String str2) void _stp_string_cat_char (String str1, const char c) { if (str1 == _stp_stdout) { - _stp_pbuf *pb = &__get_cpu_var(Stp_pbuf); + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); int size = STP_PRINT_BUF_LEN - pb->len; char *buf; |