source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/ibm-linux/Trace-plat.h @ 177

Last change on this file since 177 was 16, checked in by rock, 17 years ago
File size: 11.3 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2001 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS mmfslinux kernel module.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)03       1.21  src/avs/fs/mmfs/ts/kernext/ibm-linux/Trace-plat.h, mmfs, avs_rgpfs24, rgpfs240610b 7/1/04 11:13:25 */
34/*
35 * Linux-specific trace definitions
36 *
37 */
38
39#ifndef _h_Trace_plat
40#define _h_Trace_plat
41
42#ifndef _h_Trace
43#error Platform header (XXX-plat.h) should not be included directly
44#endif
45
46#ifdef GPFS_PRINTF
47#  ifdef __KERNEL__
48#    ifdef __cplusplus
49       extern "C"
50       {
51         int printk(const char * fmt, ...)
52                    __attribute__ ((format (printf, 1, 2)));
53       }
54#    else  /* !__cplusplus */
55       extern int printk(const char * fmt, ...)
56                         __attribute__ ((format (printf, 1, 2)));
57#    endif  /* __cplusplus */
58#  endif  /* __KERNEL__ */
59#endif  /* GPFS_PRINTF */
60
61
62/* Maximum number of trace classes */
63#define MAX_TRACE_CLASSES 54
64
65
66#ifdef _KERNEL
67#  define GPFS_NOTICE "<5>"
68#endif
69
70/* Define a global test for whether or not tracing is on.  On Linux, there
71   is no way to efficiently test this, so assume tracing is always on. */
72# define _GBL_TRC_IS_ON 1
73
74
75/* In the daemon, trace macros always reference the trace flags through
76   the pointer TraceFlagsP.  There is a copy of this pointer in the GPFS
77   daemon, that initially points to PrivateTraceFlagsArray.  After the
78   shared segment has been initialized, the contents of this array are
79   copied into Shared.traceFlags and TraceFlagsP is changed to point to
80   this shared copy.  In the kernel, TraceFlagsP is an array of trace
81   levels.  This is kept in sync with Shared.traceFlags by the
82   kxSetTraceLevel kernel call whenever 'mmfsadm trace foo n' changes
83   any trace flags.  */
84#ifdef DEFINE_TRACE_GBL_VARS
85# ifdef _KERNEL
86    char TraceFlagsP[MAX_TRACE_CLASSES] = { 0 };
87# else
88    char PrivateTraceFlagsArray[MAX_TRACE_CLASSES] = { 0 };
89    char* TraceFlagsP = PrivateTraceFlagsArray;
90# endif
91#else
92# ifdef _KERNEL
93    extern char TraceFlagsP[MAX_TRACE_CLASSES];
94# else
95    extern char PrivateTraceFlagsArray[MAX_TRACE_CLASSES];
96    extern char* TraceFlagsP;
97# endif
98#endif  /* DEFINE_TRACE_GBL_VARS */
99
100
101/* Define macros for code that is generated before and after the actual
102   trace call.  If FAR_TRACE is #defined, the actual call to the trace
103   subroutine will be placed far away from the test of whether or not
104   tracing is turned on.  When tracing is turned off, this technique
105   reduces the number of I-cache misses, thereby improving performance
106   significantly (5-10%).  Use of the FAR_TRACE option is not compatible
107   with -g, and requires compiler options -fno-exceptions and
108   -fno-defer-pop to insure that correct code is generated. */
109#ifdef FAR_TRACE
110# if defined(GPFS_ARCH_I386)
111#   define _TR_BEFORE __asm__(                                \
112                        " jmp 2f\n"                           \
113                        ".section .text.trace,\"ax\"\n"       \
114                        "2:\n"                                \
115                      );
116#   define _TR_AFTER  __asm__(                                \
117                        " jmp 1f\n"                           \
118                        ".previous\n"                         \
119                        "1:\n"                                \
120                      );
121# elif defined(GPFS_ARCH_IA64)
122/* Changing sections in the middle of a function is apparently a
123   fairly bad thing to do for IA64 (screws up unwinding information,
124   probably the debugging information, and also insn binding) and causes
125   the gnu assembler to spew when optimizations are turned on.
126   The gcc __buildin_expect(x,0) directive may be an alternative
127   in the future, but this currently doesn't provide any performance
128   enhancements with gcc 3.2, so we'll do nothing for now. */
129#if 0
130#   define _TR_BEFORE __asm__(                                \
131                        " (p0) br.cond.sptk.few 2f\n"         \
132                        ".section .text.trace,\"ax\"\n"       \
133                        "2:\n"                                \
134                      );
135#   define _TR_AFTER  __asm__(                                \
136                        " (p0) br.cond.sptk.many 1f\n"        \
137                        ".previous\n"                         \
138                        "1:\n"                                \
139                      );
140#endif
141#   define _TR_BEFORE
142#   define _TR_AFTER
143# else
144#   define _TR_BEFORE
145#   define _TR_AFTER
146# endif  /* GPFS_ARCH_I386 */
147#else
148# define _TR_BEFORE
149# define _TR_AFTER
150#endif  /* FAR_TRACE */
151
152
153#ifdef _KERNEL
154# define PDEBUG(_c, _l, _fmt, args...) \
155    if (_TRACE_IS_ON(_c, _l)) printk( GPFS_NOTICE "kp %X:" _fmt, cxiGetThreadId() ,## args); else NOOP
156#else
157#     ifdef __cplusplus
158  extern "C" int ktrace(const char *fmt, ...);
159#     else  /* !__cplusplus */
160  extern  int ktrace(const char *fmt, ...);
161#     endif
162# define PDEBUG(_c, _l, _fmt, args...) \
163    if (_TRACE_IS_ON(_c, _l)) ktrace(_fmt, args); else NOOP
164#endif  /* _KERNEL */
165
166
167/* Special values for pos field in _STrace calls */
168#define _TR_FORMAT_I 250   /* all integer arguments */
169#define _TR_FORMAT_F 251   /* all integer arguments, plus the last argument
170                              is a float */
171#define _TR_FORMAT_X 252   /* preformatted string from TRACEnX */
172
173
174#ifndef GPFS_PRINTF
175
176/* NOTE: following _TRACExxx macros are used by the tracing facility but
177   should NOT be explicitly used in the gpfs source code. These are
178   intended to keep trcid.h from getting too large. */
179
180/* Define the trace hook macros used by the generated code in trcid.h for
181   all-integer calls */
182#define _TRACE0D(hw)           _STrace(hw, 0, _TR_FORMAT_I, 1)
183#define _TRACE1D(hw, args...)  _STrace(hw, 1, _TR_FORMAT_I,##args)
184#define _TRACE2D(hw, args...)  _STrace(hw, 2, _TR_FORMAT_I,##args)
185#define _TRACE3D(hw, args...)  _STrace(hw, 3, _TR_FORMAT_I,##args)
186#define _TRACE4D(hw, args...)  _STrace(hw, 4, _TR_FORMAT_I,##args)
187#define _TRACE5D(hw, args...)  _STrace(hw, 5, _TR_FORMAT_I,##args)
188#define _TRACE6D(hw, args...)  _STrace(hw, 6, _TR_FORMAT_I,##args)
189#define _TRACE7D(hw, args...)  _STrace(hw, 7, _TR_FORMAT_I,##args)
190#define _TRACE8D(hw, args...)  _STrace(hw, 8, _TR_FORMAT_I,##args)
191#define _TRACE9D(hw, args...)  _STrace(hw, 9, _TR_FORMAT_I,##args)
192#define _TRACE10D(hw, args...) _STrace(hw, 10, _TR_FORMAT_I,##args)
193#define _TRACE11D(hw, args...) _STrace(hw, 11, _TR_FORMAT_I,##args)
194#define _TRACE12D(hw, args...) _STrace(hw, 12, _TR_FORMAT_I,##args)
195
196#define _TRACE13D(hw, args...) _STrace(hw, 13, _TR_FORMAT_I,##args)
197#define _TRACE14D(hw, args...) _STrace(hw, 14, _TR_FORMAT_I,##args)
198#define _TRACE15D(hw, args...) _STrace(hw, 15, _TR_FORMAT_I,##args)
199#define _TRACE16D(hw, args...) _STrace(hw, 16, _TR_FORMAT_I,##args)
200#define _TRACE17D(hw, args...) _STrace(hw, 17, _TR_FORMAT_I,##args)
201#define _TRACE18D(hw, args...) _STrace(hw, 18, _TR_FORMAT_I,##args)
202#define _TRACE19D(hw, args...) _STrace(hw, 19, _TR_FORMAT_I,##args)
203#define _TRACE20D(hw, args...) _STrace(hw, 20, _TR_FORMAT_I,##args)
204
205#ifdef LTRACE_FUTURE
206#define TRCGENT(0, hookid, trcid, len, trcTemp) (void)0
207#endif
208
209/* non blocking versions */
210#define _TRACE0D_NB(hw)           _STraceNB(hw, 0, _TR_FORMAT_I, 1)
211#define _TRACE1D_NB(hw, args...)  _STraceNB(hw, 1, _TR_FORMAT_I,##args)
212#define _TRACE2D_NB(hw, args...)  _STraceNB(hw, 2, _TR_FORMAT_I,##args)
213#define _TRACE3D_NB(hw, args...)  _STraceNB(hw, 3, _TR_FORMAT_I,##args)
214#define _TRACE4D_NB(hw, args...)  _STraceNB(hw, 4, _TR_FORMAT_I,##args)
215#define _TRACE5D_NB(hw, args...)  _STraceNB(hw, 5, _TR_FORMAT_I,##args)
216#define _TRACE6D_NB(hw, args...)  _STraceNB(hw, 6, _TR_FORMAT_I,##args)
217#define _TRACE7D_NB(hw, args...)  _STraceNB(hw, 7, _TR_FORMAT_I,##args)
218#define _TRACE8D_NB(hw, args...)  _STraceNB(hw, 8, _TR_FORMAT_I,##args)
219#define _TRACE9D_NB(hw, args...)  _STraceNB(hw, 9, _TR_FORMAT_I,##args)
220#define _TRACE10D_NB(hw, args...) _STraceNB(hw, 10, _TR_FORMAT_I,##args)
221#define _TRACE11D_NB(hw, args...) _STraceNB(hw, 11, _TR_FORMAT_I,##args)
222#define _TRACE12D_NB(hw, args...) _STraceNB(hw, 12, _TR_FORMAT_I,##args)
223
224#define _TRACE13D_NB(hw, args...) _STraceNB(hw, 13, _TR_FORMAT_I,##args)
225#define _TRACE14D_NB(hw, args...) _STraceNB(hw, 14, _TR_FORMAT_I,##args)
226#define _TRACE15D_NB(hw, args...) _STraceNB(hw, 15, _TR_FORMAT_I,##args)
227#define _TRACE16D_NB(hw, args...) _STraceNB(hw, 16, _TR_FORMAT_I,##args)
228#define _TRACE17D_NB(hw, args...) _STraceNB(hw, 17, _TR_FORMAT_I,##args)
229#define _TRACE18D_NB(hw, args...) _STraceNB(hw, 18, _TR_FORMAT_I,##args)
230#define _TRACE19D_NB(hw, args...) _STraceNB(hw, 19, _TR_FORMAT_I,##args)
231#define _TRACE20D_NB(hw, args...) _STraceNB(hw, 20, _TR_FORMAT_I,##args)
232
233#define _TRACE1F(hw, args...) _STrace(hw, 0, _TR_FORMAT_F,##args)
234#define _TRACE2F(hw, args...) _STrace(hw, 1, _TR_FORMAT_F,##args)
235#define _TRACE3F(hw, args...) _STrace(hw, 2, _TR_FORMAT_F,##args)
236#define _TRACE4F(hw, args...) _STrace(hw, 3, _TR_FORMAT_F,##args)
237#define _TRACE5F(hw, args...) _STrace(hw, 4, _TR_FORMAT_F,##args)
238#define _TRACE6F(hw, args...) _STrace(hw, 5, _TR_FORMAT_F,##args)
239#define _TRACE7F(hw, args...) _STrace(hw, 6, _TR_FORMAT_F,##args)
240#define _TRACE8F(hw, args...) _STrace(hw, 7, _TR_FORMAT_F,##args)
241#define _TRACE9F(hw, args...) _STrace(hw, 8, _TR_FORMAT_F,##args)
242
243#define _TRACE1F_NB(hw, args...) _STraceNB(hw, 0, _TR_FORMAT_F,##args)
244#define _TRACE2F_NB(hw, args...) _STraceNB(hw, 1, _TR_FORMAT_F,##args)
245#define _TRACE3F_NB(hw, args...) _STraceNB(hw, 2, _TR_FORMAT_F,##args)
246#define _TRACE4F_NB(hw, args...) _STraceNB(hw, 3, _TR_FORMAT_F,##args)
247#define _TRACE5F_NB(hw, args...) _STraceNB(hw, 4, _TR_FORMAT_F,##args)
248#define _TRACE6F_NB(hw, args...) _STraceNB(hw, 5, _TR_FORMAT_F,##args)
249#define _TRACE7F_NB(hw, args...) _STraceNB(hw, 6, _TR_FORMAT_F,##args)
250#define _TRACE8F_NB(hw, args...) _STraceNB(hw, 7, _TR_FORMAT_F,##args)
251#define _TRACE9F_NB(hw, args...) _STraceNB(hw, 8, _TR_FORMAT_F,##args)
252
253#endif /* GPFS_PRINTF */
254
255#endif  /* _h_Trace_plat */
Note: See TracBrowser for help on using the repository browser.