Whamcloud - gitweb
*** empty log message ***
[fs/lustre-release.git] / lnet / libcfs / tracefile.h
index f3568e9..7d43392 100644 (file)
@@ -5,6 +5,10 @@
 
 /* trace file lock routines */
 
+#define TRACEFILE_NAME_SIZE 1024
+extern char      tracefile[TRACEFILE_NAME_SIZE];
+extern long long tracefile_size;
+
 int  tracefile_init_arch(void);
 void tracefile_fini_arch(void);
 
@@ -18,25 +22,36 @@ void trace_debug_print(void);
 void trace_flush_pages(void);
 int trace_start_thread(void);
 void trace_stop_thread(void);
-int tracefile_init(void);
+int tracefile_init(int max_pages);
 void tracefile_exit(void);
-int trace_write_daemon_file(struct file *file, const char *buffer,
-                           unsigned long count, void *data);
-int trace_read_daemon_file(char *page, char **start, off_t off, int count,
-                          int *eof, void *data);
-int trace_write_debug_mb(struct file *file, const char *buffer,
-                        unsigned long count, void *data);
-int trace_read_debug_mb(char *page, char **start, off_t off, int count,
-                       int *eof, void *data);
-int trace_dk(struct file *file, const char *buffer, unsigned long count,
-             void *data);
+
+
+
+int trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
+                        const char *usr_buffer, int usr_buffer_nob);
+int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
+                         const char *knl_str, char *append);
+int trace_allocate_string_buffer(char **str, int nob);
+void trace_free_string_buffer(char *str, int nob);
+int trace_dump_debug_buffer_usrstr(void *usr_str, int usr_str_nob);
+int trace_daemon_command(char *str);
+int trace_daemon_command_usrstr(void *usr_str, int usr_str_nob);
+int trace_set_debug_mb(int mb);
+int trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob);
+int trace_get_debug_mb(void);
 
 extern void libcfs_debug_dumplog_internal(void *arg);
 extern void libcfs_register_panic_notifier(void);
 extern void libcfs_unregister_panic_notifier(void);
 extern int  libcfs_panic_in_progress;
+extern int  trace_max_debug_mb(void);
+
+#define TCD_MAX_PAGES (5 << (20 - CFS_PAGE_SHIFT))
+#define TCD_STOCK_PAGES (TCD_MAX_PAGES)
+#define TRACEFILE_SIZE (500 << 20)
 
 #ifdef LUSTRE_TRACEFILE_PRIVATE
+
 /*
  * Private declare for tracefile
  */
@@ -45,8 +60,8 @@ extern int  libcfs_panic_in_progress;
 
 #define TRACEFILE_SIZE (500 << 20)
 
-/* Size of a buffer for sprinting console messages to in IRQ context (no
- * logging in IRQ context) */
+/* Size of a buffer for sprinting console messages if we can't get a page 
+ * from system */
 #define TRACE_CONSOLE_BUFFER_SIZE   1024
 
 union trace_data_union {
@@ -74,7 +89,8 @@ union trace_data_union {
 
                /*
                 * Maximal number of pages allowed on ->tcd_pages and
-                * ->tcd_daemon_pages each. Always TCD_MAX_PAGES in current
+                * ->tcd_daemon_pages each. 
+                * Always TCD_MAX_PAGES * tcd_pages_factor / 100 in current
                 * implementation.
                 */
                unsigned long           tcd_max_pages;
@@ -105,12 +121,28 @@ union trace_data_union {
                /* number of pages on ->tcd_stock_pages */
                unsigned long           tcd_cur_stock_pages;
 
-               int                     tcd_shutting_down;
-               int                     tcd_cpu;
+               unsigned short          tcd_shutting_down;
+               unsigned short          tcd_cpu;
+               unsigned short          tcd_type;
+               /* The factors to share debug memory. */
+               unsigned short          tcd_pages_factor;
        } tcd;
-       char __pad[SMP_CACHE_BYTES];
+       char __pad[L1_CACHE_ALIGN(sizeof(struct trace_cpu_data))];
 };
 
+#define TCD_MAX_TYPES      8
+extern union trace_data_union (*trace_data[TCD_MAX_TYPES])[NR_CPUS];
+
+#define tcd_for_each(tcd, i, j)                                       \
+    for (i = 0; trace_data[i] != NULL; i++)                           \
+        for (j = 0, ((tcd) = &(*trace_data[i])[j].tcd);               \
+             j < num_possible_cpus(); j++, (tcd) = &(*trace_data[i])[j].tcd)
+
+#define tcd_for_each_type_lock(tcd, i)                                \
+    for (i = 0; trace_data[i] &&                                      \
+         (tcd = &(*trace_data[i])[smp_processor_id()].tcd) &&         \
+         trace_lock_tcd(tcd); trace_unlock_tcd(tcd), i++)
+
 /* XXX nikita: this declaration is internal to tracefile.c and should probably
  * be moved there */
 struct page_collection {
@@ -163,7 +195,11 @@ struct trace_page {
        /*
         * cpu that owns this page
         */
-       int              cpu;
+       unsigned short   cpu;
+       /*
+        * type(context) of this page 
+        */
+       unsigned short   type;
 };
 
 extern void set_ptldebug_header(struct ptldebug_header *header,
@@ -174,6 +210,8 @@ extern void print_to_console(struct ptldebug_header *hdr, int mask, const char *
 
 extern struct trace_cpu_data *trace_get_tcd(void);
 extern void trace_put_tcd(struct trace_cpu_data *tcd);
+extern int trace_lock_tcd(struct trace_cpu_data *tcd);
+extern void trace_unlock_tcd(struct trace_cpu_data *tcd);
 extern char *trace_get_console_buffer(void);
 extern void trace_put_console_buffer(char *buffer);