Whamcloud - gitweb
* Landed portals:b_port_step as follows...
[fs/lustre-release.git] / lnet / libcfs / tracefile.h
1 #ifndef __LIBCFS_TRACEFILE_H__
2 #define __LIBCFS_TRACEFILE_H__
3
4 #include <libcfs/libcfs.h>
5
6 int tracefile_dump_all_pages(char *filename);
7 void trace_debug_print(void);
8 void trace_flush_pages(void);
9 int trace_start_thread(void);
10 void trace_stop_thread(void);
11 int tracefile_init(void);
12 void tracefile_exit(void);
13 int trace_write_daemon_file(struct file *file, const char *buffer,
14                             unsigned long count, void *data);
15 int trace_read_daemon_file(char *page, char **start, off_t off, int count,
16                            int *eof, void *data);
17 int trace_write_debug_mb(struct file *file, const char *buffer,
18                          unsigned long count, void *data);
19 int trace_read_debug_mb(char *page, char **start, off_t off, int count,
20                         int *eof, void *data);
21 int trace_dk(struct file *file, const char *buffer, unsigned long count,
22              void *data);
23
24 #ifdef LUSTRE_TRACEFILE_PRIVATE
25 /*
26  * Private declare for tracefile
27  */
28 #define TCD_MAX_PAGES (5 << (20 - PAGE_SHIFT))
29
30 #define TRACEFILE_SIZE (500 << 20)
31
32 union trace_data_union {
33         struct trace_cpu_data {
34                 struct list_head        tcd_pages;
35                 unsigned long           tcd_cur_pages;
36
37                 struct list_head        tcd_daemon_pages;
38                 unsigned long           tcd_cur_daemon_pages;
39
40                 unsigned long           tcd_max_pages;
41                 int                     tcd_shutting_down;
42         } tcd;
43         char __pad[SMP_CACHE_BYTES];
44 };
45
46 struct page_collection {
47         struct list_head        pc_pages;
48         spinlock_t              pc_lock;
49         int                     pc_want_daemon_pages;
50 };
51
52 struct tracefiled_ctl {
53         struct completion       tctl_start;
54         struct completion       tctl_stop;
55         cfs_waitq_t             tctl_waitq; 
56         pid_t                   tctl_pid;
57         atomic_t                tctl_shutdown;
58 };
59
60 /*
61  * small data-structure for each page owned by tracefiled.
62  */
63 struct trace_page {
64         /*
65          * page itself
66          */
67         cfs_page_t      *page;
68         /*
69          * linkage into one of the lists in trace_data_union or
70          * page_collection
71          */
72         struct list_head linkage;
73         /*
74          * number of bytes used within this page
75          */
76         unsigned int     used;
77         /*
78          * cpu that owns this page
79          */
80         int              cpu;
81 };
82
83 extern void set_ptldebug_header(struct ptldebug_header *header,
84                            int subsys, int mask, const int line,
85                            unsigned long stack);
86 extern void print_to_console(struct ptldebug_header *hdr, int mask,
87                              char *buf, int len, char *file, const char *fn);
88 extern struct trace_cpu_data * __trace_get_tcd (unsigned long *flags);
89 extern void __trace_put_tcd (struct trace_cpu_data *tcd, unsigned long flags);
90
91 #define trace_get_tcd(f)        __trace_get_tcd(&(f))
92 #define trace_put_tcd(t, f)     __trace_put_tcd(t, f)
93
94 #endif  /* LUSTRE_TRACEFILE_PRIVATE */
95
96 #endif /* __PORTALS_TRACEFILE_H */