lustre: libcfs: tracefile cleanups
v4 cover lustre: libcfs: tracefile cleanups
The 4th version of a patch series aimed to cleanup the lustre tracefile handling. This set is mainly a repost of the 3rd set with the addition of a bug fix, patch number 2, that added proper range checking for the debugfs parameter debug_mb. The 6th patch has been updated based on Andreas Dilger's feedback to resolve the brokeness of cfs_print_to_console(). This patch series has been reposted to allow anyone interested in testing the the major changes are in the 6th and 7th patch which was rebased due to changes in the code.
James Simmons (6):
lustre: libcfs: properly handle failure paths in cfs_tracefile_init_arch()
lustre: libcfs: fix cfs_print_to_console()
lustre: libcfs: remove cfs_trace_refill_stack()
lustre: libcfs: move cfs_trace_data data to tracefile.c
lustre: libcfs: cleanup tracefile.h
lustre: libcfs: format macros in tracefile.h
NeilBrown (8):
lustre: libcfs: move tracefile locking from linux-tracefile.c to tracefile.c
lustre: libcfs: always range-check libcfs_debug_mb setting.
lustre: libcfs: open code cfs_trace_max_debug_mb() into cfs_trace_set_debug_mb()
lustre: libcfs: move tcd locking across to tracefile.c
lustre: libcfs: merge linux-tracefile.c into tracefile.c
lustre: libcfs: fold cfs_tracefile_*_arch into their only callers.
lustre: libcfs: renamed CFS_TCD_TYPE_MAX to CFS_TCD_TYPE_CNT
lustre: libcfs: discard TCD_MAX_TYPES
drivers/staging/lustre/lnet/libcfs/Makefile | 2 +- drivers/staging/lustre/lnet/libcfs/debug.c | 22 +- .../staging/lustre/lnet/libcfs/linux-tracefile.c | 258 ------------------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 279 +++++++++++++++++---- drivers/staging/lustre/lnet/libcfs/tracefile.h | 117 +-------- 5 files changed, 255 insertions(+), 423 deletions(-) delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
Signature · 1 line
1.8.3.1
PATCH v4 1/14 lustre: libcfs: move tracefile locking from linux-tracefile.c to tracefile.c
From: NeilBrown <[email protected]>
There is no value in keeping it separate.
--- .../staging/lustre/lnet/libcfs/linux-tracefile.c | 22 ------------------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 25 +++++++++++----------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 5 ----- 3 files changed, 13 insertions(+), 39 deletions(-)
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c +0 -22
@@ -47,8 +47,6 @@char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ]; -static DECLARE_RWSEM (cfs_tracefile_sem); -int cfs_tracefile_init_arch (void ) {int i;
@@ -109,26 +107,6 @@ void cfs_tracefile_fini_arch(void) } } -void cfs_tracefile_read_lock (void ) -{ -down_read (&cfs_tracefile_sem); -} - -void cfs_tracefile_read_unlock (void ) -{ -up_read (&cfs_tracefile_sem); -} - -void cfs_tracefile_write_lock (void ) -{ -down_write (&cfs_tracefile_sem); -} - -void cfs_tracefile_write_unlock (void ) -{ -up_write (&cfs_tracefile_sem); -} -enum cfs_trace_buf_type cfs_trace_buf_idx_get (void ) {if (in_irq ())
drivers/staging/lustre/lnet/libcfs/tracefile.c +13 -12
@@ -59,6 +59,7 @@static int thread_running;static atomic_t cfs_tage_allocated =ATOMIC_INIT (0 ); +static DECLARE_RWSEM (cfs_tracefile_sem);struct page_collection {struct list_head pc_pages;
@@ -711,7 +712,7 @@ int cfs_tracefile_dump_all_pages(char *filename)mm_segment_t __oldfs;int rc; -cfs_tracefile_write_lock (); +down_write (&cfs_tracefile_sem); filp =filp_open (filename,O_CREAT |O_EXCL |O_WRONLY |O_LARGEFILE ,0600 );
@@ -759,7 +760,7 @@ int cfs_tracefile_dump_all_pages(char *filename) close:filp_close (filp,NULL ); out: -cfs_tracefile_write_unlock (); +up_write (&cfs_tracefile_sem);return rc; }
@@ -873,12 +874,12 @@ int cfs_trace_daemon_command(char *str) {int rc =0 ; -cfs_tracefile_write_lock (); +down_write (&cfs_tracefile_sem);if (!strcmp (str,"stop" )) { -cfs_tracefile_write_unlock (); +up_write (&cfs_tracefile_sem);cfs_trace_stop_thread (); -cfs_tracefile_write_lock (); +down_write (&cfs_tracefile_sem);memset (cfs_tracefile,0 ,sizeof (cfs_tracefile)); }else if (!strncmp (str,"size=" ,5 )) {
@@ -905,7 +906,7 @@ int cfs_trace_daemon_command(char *str)cfs_trace_start_thread (); } -cfs_tracefile_write_unlock (); +up_write (&cfs_tracefile_sem);return rc; }
@@ -950,12 +951,12 @@ int cfs_trace_set_debug_mb(int mb) mb /=num_possible_cpus (); pages = mb << (20 -PAGE_SHIFT ); -cfs_tracefile_write_lock (); +down_write (&cfs_tracefile_sem);cfs_tcd_for_each (tcd, i, j) tcd->tcd_max_pages = (pages * tcd->tcd_pages_factor) /100 ; -cfs_tracefile_write_unlock (); +up_write (&cfs_tracefile_sem);return 0 ; }
@@ -967,12 +968,12 @@ int cfs_trace_get_debug_mb(void)struct cfs_trace_cpu_data *tcd;int total_pages =0 ; -cfs_tracefile_read_lock (); +down_read (&cfs_tracefile_sem);cfs_tcd_for_each (tcd, i, j) total_pages += tcd->tcd_max_pages; -cfs_tracefile_read_unlock (); +up_read (&cfs_tracefile_sem);return (total_pages >> (20 -PAGE_SHIFT )) +1 ; }
@@ -1002,7 +1003,7 @@ static int tracefiled(void *arg) goto end_loop; filp =NULL ; -cfs_tracefile_read_lock (); +down_read (&cfs_tracefile_sem);if (cfs_tracefile[0 ]) { filp = filp_open(cfs_tracefile, O_CREAT | O_RDWR | O_LARGEFILE,
@@ -1014,7 +1015,7 @@ static int tracefiled(void *arg) rc); } } -cfs_tracefile_read_unlock (); +up_read (&cfs_tracefile_sem);if (!filp) {put_pages_on_daemon_list (&pc);__LASSERT (list_empty (&pc.pc_pages));
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -5
@@ -65,11 +65,6 @@ enum cfs_trace_buf_type {int cfs_tracefile_init_arch (void );void cfs_tracefile_fini_arch (void ); -void cfs_tracefile_read_lock (void ); -void cfs_tracefile_read_unlock (void ); -void cfs_tracefile_write_lock (void ); -void cfs_tracefile_write_unlock (void ); -int cfs_tracefile_dump_all_pages (char *filename);void cfs_trace_debug_print (void );void cfs_trace_flush_pages (void );
Signature · 1 line
1.8.3.1
PATCH v4 2/14 lustre: libcfs: always range-check libcfs_debug_mb setting.
In reply to James SimmonsFrom: NeilBrown <[email protected]>
When the libcfs_debug_mb module parameter is set
at module-load time it isn't range-checked. When
it is set via sysfs it is. This inconsistency
makes the code harder to follow.
It is quite safe to call cfs_trace_set_debug_mb()
and cfs_trace_get_debug_mb() before the module
is initialized as cfs_tcd_for_each() does nothing
before initializtion.
So change cfs_trace_set_debug_mb() - which does
range checking - to returned the ranged checked number (it currently always returns zero) and use that as the new value, unless cfs_trace_get_debug_mb() now returns a non-zero value.
--- drivers/staging/lustre/lnet/libcfs/debug.c | 16 +++++++--------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-)
drivers/staging/lustre/lnet/libcfs/debug.c +7 -9
@@ -67,17 +67,15 @@ static int libcfs_param_debug_mb_set(const char *val,if (rc <0 )return rc; -if (!*((unsigned int *)kp->arg)) { - *((unsigned int *)kp->arg) = num; -return 0 ; - } - - rc =cfs_trace_set_debug_mb (num); + num =cfs_trace_set_debug_mb (num); -if (!rc) - *((unsigned int *)kp->arg) =cfs_trace_get_debug_mb (); + *((unsigned int *)kp->arg) = num; + num =cfs_trace_get_debug_mb (); +if (num) +/* This value is more precise */ + *((unsigned int *)kp->arg) = num; -return rc; +return 0 ; }/* While debug_mb setting look like unsigned int, in fact
drivers/staging/lustre/lnet/libcfs/tracefile.c +1 -1
@@ -958,7 +958,7 @@ int cfs_trace_set_debug_mb(int mb)up_write (&cfs_tracefile_sem); -return 0 ; +return mb; }int cfs_trace_get_debug_mb (void )
Signature · 1 line
1.8.3.1
PATCH v4 3/14 lustre: libcfs: open code cfs_trace_max_debug_mb() into cfs_trace_set_debug_mb()
In reply to James SimmonsFrom: NeilBrown <[email protected]>
This function in used twice.
In libcfs_debug_init() the usage is pointless as the only place that set libcfs_debug_mb ensures that it does not exceed the maximum. So checking again can never help.
So open-code the small function into the only other place that it is used - in cfs_trace_set_debug_mb(), which is used to set libcfs_debug_mb.
--- drivers/staging/lustre/lnet/libcfs/debug.c | 6 +++--- drivers/staging/lustre/lnet/libcfs/linux-tracefile.c | 7 ------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 3 ++- drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 - 4 files changed, 5 insertions(+), 12 deletions(-)
drivers/staging/lustre/lnet/libcfs/debug.c +3 -3
@@ -409,10 +409,10 @@ int libcfs_debug_init(unsigned long bufsize) sizeof(libcfs_debug_file_path_arr)); } -/* If libcfs_debug_mb is set to an invalid value or uninitialized -* then just make the total buffers smp_num_cpus * TCD_MAX_PAGES +/* If libcfs_debug_mb is uninitialized then just make the +* total buffers smp_num_cpus * TCD_MAX_PAGES */ -if (max >cfs_trace_max_debug_mb () || max <num_possible_cpus ()) { +if (max <num_possible_cpus ()) { max =TCD_MAX_PAGES ; }else { max = max /num_possible_cpus ();
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c +0 -7
@@ -227,10 +227,3 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, hdr->ph_line_num, fn, len, buf); } } - -int cfs_trace_max_debug_mb (void ) -{ -int total_mb = (totalram_pages >> (20 -PAGE_SHIFT )); - -return max (512 , (total_mb *80 ) /100 ); -}
drivers/staging/lustre/lnet/libcfs/tracefile.c +2 -1
@@ -933,7 +933,8 @@ int cfs_trace_set_debug_mb(int mb)int i;int j;int pages; -int limit =cfs_trace_max_debug_mb (); +int total_mb = (totalram_pages >> (20 -PAGE_SHIFT )); +int limit =max (512 , (total_mb *80 ) /100 );struct cfs_trace_cpu_data *tcd;if (mb <num_possible_cpus ()) {
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -1
@@ -88,7 +88,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,void libcfs_register_panic_notifier (void );void libcfs_unregister_panic_notifier (void );extern int libcfs_panic_in_progress; -int cfs_trace_max_debug_mb (void );#define TCD_MAX_PAGES (5 << (20 - PAGE_SHIFT))#define TCD_STOCK_PAGES (TCD_MAX_PAGES)
Signature · 1 line
1.8.3.1
PATCH v4 4/14 lustre: libcfs: move tcd locking across to tracefile.c
In reply to James SimmonsFrom: NeilBrown <[email protected]>
No need to have this in linux-tracefile.c
--- .../staging/lustre/lnet/libcfs/linux-tracefile.c | 35 ------------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 59 ++++++++++++++++++++++ drivers/staging/lustre/lnet/libcfs/tracefile.h | 28 ---------- 3 files changed, 59 insertions(+), 63 deletions(-)
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c +0 -35
@@ -116,41 +116,6 @@ enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)return CFS_TCD_TYPE_PROC ; } -/* -* The walking argument indicates the locking comes from all tcd types -* iterator and we must lock it and dissable local irqs to avoid deadlocks -* with other interrupt locks that might be happening. See LU-1311 -* for details. -*/ -int cfs_trace_lock_tcd (struct cfs_trace_cpu_data *tcd,int walking) - __acquires(&tcd->tc_lock) -{ -__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_MAX ); -if (tcd->tcd_type ==CFS_TCD_TYPE_IRQ ) -spin_lock_irqsave (&tcd->tcd_lock, tcd->tcd_lock_flags); -else if (tcd->tcd_type ==CFS_TCD_TYPE_SOFTIRQ ) -spin_lock_bh (&tcd->tcd_lock); -else if (unlikely (walking)) -spin_lock_irq (&tcd->tcd_lock); -else -spin_lock (&tcd->tcd_lock); -return 1 ; -} - -void cfs_trace_unlock_tcd (struct cfs_trace_cpu_data *tcd,int walking) - __releases(&tcd->tcd_lock) -{ -__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_MAX ); -if (tcd->tcd_type ==CFS_TCD_TYPE_IRQ ) -spin_unlock_irqrestore (&tcd->tcd_lock, tcd->tcd_lock_flags); -else if (tcd->tcd_type ==CFS_TCD_TYPE_SOFTIRQ ) -spin_unlock_bh (&tcd->tcd_lock); -else if (unlikely (walking)) -spin_unlock_irq (&tcd->tcd_lock); -else -spin_unlock (&tcd->tcd_lock); -} - void cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *msgdata,
drivers/staging/lustre/lnet/libcfs/tracefile.c +59 -0
65 lines not on this page · raw message
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -28
@@ -49,8 +49,6 @@ enum cfs_trace_buf_type { CFS_TCD_TYPE_MAX }; -/* trace file lock routines */ -#define TRACEFILE_NAME_SIZE 1024extern char cfs_tracefile[TRACEFILE_NAME_SIZE ];extern long long cfs_tracefile_size;
@@ -194,11 +192,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, j <num_possible_cpus (); \ j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) -#define cfs_tcd_for_each_type_lock (tcd, i, cpu) \ - for (i = 0; cfs_trace_data[i] && \ - (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ - cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++) -void cfs_set_ptldebug_header (struct ptldebug_header *header,struct libcfs_debug_msg_data *m,unsigned long stack);
@@ -206,9 +199,6 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, const char *buf, int len, const char *file, const char *fn); -int cfs_trace_lock_tcd (struct cfs_trace_cpu_data *tcd,int walking); -void cfs_trace_unlock_tcd (struct cfs_trace_cpu_data *tcd,int walking); -extern char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ];enum cfs_trace_buf_type cfs_trace_buf_idx_get (void );
@@ -221,24 +211,6 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask,return cfs_trace_console_buffers[i][j]; } -static inline struct cfs_trace_cpu_data * -cfs_trace_get_tcd (void ) -{ -struct cfs_trace_cpu_data *tcd = - &(*cfs_trace_data[cfs_trace_buf_idx_get ()])[get_cpu ()].tcd; - -cfs_trace_lock_tcd (tcd,0 ); - -return tcd; -} - -static inline void cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd) -{ -cfs_trace_unlock_tcd (tcd,0 ); - -put_cpu (); -} -int cfs_trace_refill_stock (struct cfs_trace_cpu_data *tcd,gfp_t gfp,struct list_head *stock);
Signature · 1 line
1.8.3.1
PATCH v4 5/14 lustre: libcfs: properly handle failure paths in cfs_tracefile_init_arch()
In reply to James SimmonsIt is considered poor coding style in the linux kernel to call a catch all for cleanup in the initialization function. Also their is no reason to cleanup cfs_trace_console_buffers if they never been allocated. Lets unroll the error handling.
--- drivers/staging/lustre/lnet/libcfs/linux-tracefile.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c +14 -5
@@ -49,9 +49,9 @@int cfs_tracefile_init_arch (void ) { +struct cfs_trace_cpu_data *tcd;int i;int j; -struct cfs_trace_cpu_data *tcd;/* initialize trace_data */ memset (cfs_trace_data,0 ,sizeof (cfs_trace_data));
@@ -61,7 +61,7 @@ int cfs_tracefile_init_arch(void)sizeof (union cfs_trace_data_union ), GFP_KERNEL);if (!cfs_trace_data[i]) - goto out; + goto out_trace_data; }/* arch related info initialized */
@@ -79,13 +79,22 @@ int cfs_tracefile_init_arch(void) GFP_KERNEL);if (!cfs_trace_console_buffers[i][j]) - goto out; + goto out_buffers; }return 0 ; -out: -cfs_tracefile_fini_arch (); +out_buffers: +for (i =0 ; i <num_possible_cpus (); i++) +for (j =0 ; j <3 ; j++) { +kfree (cfs_trace_console_buffers[i][j]); + cfs_trace_console_buffers[i][j] =NULL ; + } +out_trace_data: +for (i =0 ; cfs_trace_data[i]; i++) { +kfree (cfs_trace_data[i]); + cfs_trace_data[i] =NULL ; + }pr_err ("lnet: Not enough memory\n" );return -ENOMEM ; }
Signature · 1 line
1.8.3.1
PATCH v4 6/14 lustre: libcfs: fix cfs_print_to_console()
In reply to James SimmonsThe original code for cfs_print_to_console() used printk() and used tricks to select which printk level to use. Later a cleanup patch landed the just converted printk directly to pr_info which is not exactly correct. Instead of converting back to printk lets move everything to pr_* type functions which simplify the code. This allows us to fold both dbghdr_to_err_string() and the function dbghdr_to_info_string() into cfs_print_to_console().
--- .../staging/lustre/lnet/libcfs/linux-tracefile.c | 69 ++++++++-------------- 1 file changed, 26 insertions(+), 43 deletions(-)
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c +26 -43
@@ -149,55 +149,38 @@ enum cfs_trace_buf_type cfs_trace_buf_idx_get(void) header->ph_extern_pid =0 ; } -static char * -dbghdr_to_err_string (struct ptldebug_header *hdr) -{ -switch (hdr->ph_subsys) { -case S_LND : -case S_LNET : -return "LNetError" ; -default : -return "LustreError" ; - } -} - -static char * -dbghdr_to_info_string (struct ptldebug_header *hdr) -{ -switch (hdr->ph_subsys) { -case S_LND : -case S_LNET : -return "LNet" ; -default : -return "Lustre" ; - } -} -void cfs_print_to_console (struct ptldebug_header *hdr,int mask,const char *buf,int len,const char *file,const char *fn) { -char *prefix ="Lustre" , *ptype =NULL ; - -if (mask &D_EMERG ) { - prefix =dbghdr_to_err_string (hdr); - ptype =KERN_EMERG ; - }else if (mask &D_ERROR ) { - prefix =dbghdr_to_err_string (hdr); - ptype =KERN_ERR ; - }else if (mask &D_WARNING ) { - prefix =dbghdr_to_info_string (hdr); - ptype =KERN_WARNING ; - }else if (mask & (D_CONSOLE | libcfs_printk)) { - prefix =dbghdr_to_info_string (hdr); - ptype =KERN_INFO ; - } +char *prefix ="Lustre" ; + +if (hdr->ph_subsys ==S_LND || hdr->ph_subsys ==S_LNET ) + prefix ="LNet" ;if (mask &D_CONSOLE ) { -pr_info ("%s%s: %.*s" , ptype, prefix, len, buf); +if (mask &D_EMERG ) +pr_emerg ("%sError: %.*s" , prefix, len, buf); +else if (mask &D_ERROR ) +pr_err ("%sError: %.*s" , prefix, len, buf); +else if (mask &D_WARNING ) +pr_warn ("%s: %.*s" , prefix, len, buf); +else if (mask & libcfs_printk) +pr_info ("%s: %.*s" , prefix, len, buf); }else { -pr_info ("%s%s: %d:%d:(%s:%d:%s()) %.*s" , ptype, prefix, - hdr->ph_pid, hdr->ph_extern_pid, file, - hdr->ph_line_num, fn, len, buf); +if (mask &D_EMERG ) +pr_emerg ("%sError: %d:%d:(%s:%d:%s()) %.*s" , prefix, + hdr->ph_pid, hdr->ph_extern_pid, file, + hdr->ph_line_num, fn, len, buf); +else if (mask &D_ERROR ) +pr_err ("%sError: %d:%d:(%s:%d:%s()) %.*s" , prefix, + hdr->ph_pid, hdr->ph_extern_pid, file, + hdr->ph_line_num, fn, len, buf); +else if (mask &D_WARNING ) +pr_warn ("%s: %d:%d:(%s:%d:%s()) %.*s" , prefix, + hdr->ph_pid, hdr->ph_extern_pid, file, + hdr->ph_line_num, fn, len, buf); +else if (mask & (D_CONSOLE | libcfs_printk)) +pr_info ("%s: %.*s" , prefix, len, buf); } }
Signature · 1 line
1.8.3.1
PATCH v4 7/14 lustre: libcfs: merge linux-tracefile.c into tracefile.c
In reply to James SimmonsFrom: NeilBrown <[email protected]>
It's good to keep related code together.
--- drivers/staging/lustre/lnet/libcfs/Makefile | 2 +- .../staging/lustre/lnet/libcfs/linux-tracefile.c | 186 --------------------- drivers/staging/lustre/lnet/libcfs/tracefile.c | 145 ++++++++++++++++ drivers/staging/lustre/lnet/libcfs/tracefile.h | 7 - 4 files changed, 146 insertions(+), 194 deletions(-) delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
drivers/staging/lustre/lnet/libcfs/Makefile +1 -1
@@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LNET) += libcfs.o -libcfs-obj-y += linux-tracefile.o linux-debug.o +libcfs-obj-y += linux-debug.o libcfs-obj-y += linux-crypto.o libcfs-obj-y += linux-crypto-adler.o
drivers/staging/lustre/lnet/libcfs/linux-tracefile.c deleted +0 -186
186 lines not on this page · raw message
drivers/staging/lustre/lnet/libcfs/tracefile.c +145 -0
169 lines not on this page · raw message
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -7
@@ -192,13 +192,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, j <num_possible_cpus (); \ j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) -void cfs_set_ptldebug_header (struct ptldebug_header *header, -struct libcfs_debug_msg_data *m, -unsigned long stack); -void cfs_print_to_console (struct ptldebug_header *hdr,int mask, -const char *buf,int len,const char *file, -const char *fn); -extern char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ];enum cfs_trace_buf_type cfs_trace_buf_idx_get (void );
Signature · 1 line
1.8.3.1
PATCH v4 8/14 lustre: libcfs: remove cfs_trace_refill_stack()
In reply to James SimmonsThe function cfs_trace_refill_stack() is not used anywhere so remove it.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 21 --------------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 3 --- 2 files changed, 24 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +0 -21
@@ -302,27 +302,6 @@ static void cfs_tage_to_tail(struct cfs_trace_page *tage,list_move_tail (&tage->linkage, queue); } -int cfs_trace_refill_stock (struct cfs_trace_cpu_data *tcd,gfp_t gfp, -struct list_head *stock) -{ -int i; - -/* -* XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT) -* from here: this will lead to infinite recursion. -*/ - -for (i =0 ; i + tcd->tcd_cur_stock_pages <TCD_STOCK_PAGES ; ++i) { -struct cfs_trace_page *tage; - - tage =cfs_tage_alloc (gfp); -if (!tage) -break ; -list_add_tail (&tage->linkage, stock); - } -return i; -} -/* return a page that has 'len' bytes left at the end */ static struct cfs_trace_page *cfs_trace_get_tage_try (struct cfs_trace_cpu_data *tcd,unsigned long len)
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -3
@@ -204,9 +204,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,return cfs_trace_console_buffers[i][j]; } -int cfs_trace_refill_stock (struct cfs_trace_cpu_data *tcd,gfp_t gfp, -struct list_head *stock); -void cfs_trace_assertion_failed (const char *str,struct libcfs_debug_msg_data *m);
Signature · 1 line
1.8.3.1
PATCH v4 9/14 lustre: libcfs: move cfs_trace_data data to tracefile.c
In reply to James SimmonsThe macro cfs_tcd_for_each() is only used in tracefile.c so move it from the header tracefile.h along with related material in the header file.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 12 ++++++++++-- drivers/staging/lustre/lnet/libcfs/tracefile.h | 9 --------- 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +10 -2
@@ -49,7 +49,8 @@#include <linux/uaccess.h> #include "tracefile.h" -/* XXX move things up to the top, comment */ +#define TCD_MAX_TYPES 8 + union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned;char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ];
@@ -146,7 +147,14 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking)spin_unlock (&tcd->tcd_lock); } -#define cfs_tcd_for_each_type_lock (tcd, i, cpu) \ +#define cfs_tcd_for_each (tcd, i, j) \ + for (i = 0; cfs_trace_data[i]; i++) \ + for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ + j < num_possible_cpus(); \ + j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) + + +#define cfs_tcd_for_each_type_lock (tcd, i, cpu) \ for (i = 0; cfs_trace_data[i] && \ (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++)
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -9
@@ -183,15 +183,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,char __pad[L1_CACHE_ALIGN (sizeof (struct cfs_trace_cpu_data ))]; }; -#define TCD_MAX_TYPES 8 -extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES ])[NR_CPUS ]; - -#define cfs_tcd_for_each (tcd, i, j) \ - for (i = 0; cfs_trace_data[i]; i++) \ - for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ - j < num_possible_cpus(); \ - j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) -extern char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ];enum cfs_trace_buf_type cfs_trace_buf_idx_get (void );
Signature · 1 line
1.8.3.1
PATCH v4 10/14 lustre: libcfs: cleanup tracefile.h
In reply to James SimmonsWith many things moved into tracefile.c we can cleanup a lot of things in tracefile.h. Move some items that are only used in tracefile.c from tracefile.h into tracefile.c. In tracefile.h we have the ifdef LUSTRE_TRACEFILE_PRIVATE which has several duplicate defines. We can remove those duplicates.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 18 +++++++++++-- drivers/staging/lustre/lnet/libcfs/tracefile.h | 37 -------------------------- 2 files changed, 16 insertions(+), 39 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +16 -2
@@ -37,8 +37,6 @@*/ #define DEBUG_SUBSYSTEM S_LNET -#define LUSTRE_TRACEFILE_PRIVATE -#define pr_fmt (fmt) "Lustre: " fmt#include <linux/ratelimit.h> #include <linux/highmem.h>
@@ -49,8 +47,16 @@#include <linux/uaccess.h> #include "tracefile.h" +#define CFS_TRACE_CONSOLE_BUFFER_SIZE 1024#define TCD_MAX_TYPES 8 +enum cfs_trace_buf_type { +CFS_TCD_TYPE_PROC =0 , +CFS_TCD_TYPE_SOFTIRQ , +CFS_TCD_TYPE_IRQ , +CFS_TCD_TYPE_MAX +}; + union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned;char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ];
@@ -168,6 +174,14 @@ enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)return CFS_TCD_TYPE_PROC ; } +static inline char *cfs_trace_get_console_buffer (void ) +{ +unsigned int i =get_cpu (); +unsigned int j =cfs_trace_buf_idx_get (); + +return cfs_trace_console_buffers[i][j]; +} +static inline struct cfs_trace_cpu_data *cfs_trace_get_tcd (void ) {
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -37
@@ -42,13 +42,6 @@#include <linux/smp.h> #include <linux/libcfs/libcfs.h> -enum cfs_trace_buf_type { -CFS_TCD_TYPE_PROC =0 , -CFS_TCD_TYPE_SOFTIRQ , -CFS_TCD_TYPE_IRQ , -CFS_TCD_TYPE_MAX -}; -#define TRACEFILE_NAME_SIZE 1024extern char cfs_tracefile[TRACEFILE_NAME_SIZE ];extern long long cfs_tracefile_size;
@@ -91,22 +84,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,#define TCD_STOCK_PAGES (TCD_MAX_PAGES)#define CFS_TRACEFILE_SIZE (500 << 20) -#ifdef LUSTRE_TRACEFILE_PRIVATE - -/* - * Private declare for tracefile - */ -#define TCD_MAX_PAGES (5 << (20 - PAGE_SHIFT)) -#define TCD_STOCK_PAGES (TCD_MAX_PAGES) - -#define CFS_TRACEFILE_SIZE (500 << 20) - -/* - * Size of a buffer for sprinting console messages if we can't get a page - * from system - */ -#define CFS_TRACE_CONSOLE_BUFFER_SIZE 1024 - union cfs_trace_data_union { struct cfs_trace_cpu_data { /*
@@ -183,18 +160,6 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,char __pad[L1_CACHE_ALIGN (sizeof (struct cfs_trace_cpu_data ))]; }; -extern char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ]; -enum cfs_trace_buf_type cfs_trace_buf_idx_get (void ); - -static inline char * -cfs_trace_get_console_buffer (void ) -{ -unsigned int i =get_cpu (); -unsigned int j =cfs_trace_buf_idx_get (); - -return cfs_trace_console_buffers[i][j]; -} -void cfs_trace_assertion_failed (const char *str,struct libcfs_debug_msg_data *m);
@@ -216,6 +181,4 @@ void cfs_trace_assertion_failed(const char *str,__LASSERT (page_count (tage->page) >0 ); \ } while (0) -#endif /* LUSTRE_TRACEFILE_PRIVATE */ -#endif /* __LIBCFS_TRACEFILE_H__ */
Signature · 1 line
1.8.3.1
PATCH v4 11/14 lustre: libcfs: fold cfs_tracefile_*_arch into their only callers.
In reply to James SimmonsFrom: NeilBrown <[email protected]>
There is no need to separate "arch" init/fini from the rest, so fold it all in.
This requires some slightly subtle changes to clean-up to make sure we don't walk lists before they are initialized.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 147 +++++++++++-------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 3 - 2 files changed, 63 insertions(+), 87 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +63 -84
@@ -200,82 +200,6 @@ static inline void cfs_trace_put_tcd(struct cfs_trace_cpu_data *tcd)put_cpu (); } -/* percents to share the total debug memory for each type */ -static unsigned int pages_factor[CFS_TCD_TYPE_MAX ] = { -80 ,/* 80% pages for CFS_TCD_TYPE_PROC */ -10 ,/* 10% pages for CFS_TCD_TYPE_SOFTIRQ */ -10 /* 10% pages for CFS_TCD_TYPE_IRQ */ -}; - -int cfs_tracefile_init_arch (void ) -{ -struct cfs_trace_cpu_data *tcd; -int i; -int j; - -/* initialize trace_data */ -memset (cfs_trace_data,0 ,sizeof (cfs_trace_data)); -for (i =0 ; i <CFS_TCD_TYPE_MAX ; i++) { - cfs_trace_data[i] = -kmalloc_array (num_possible_cpus (), -sizeof (union cfs_trace_data_union ), -GFP_KERNEL ); -if (!cfs_trace_data[i]) - goto out_trace_data; - } - -/* arch related info initialized */ -cfs_tcd_for_each (tcd, i, j) { -spin_lock_init (&tcd->tcd_lock); - tcd->tcd_pages_factor = pages_factor[i]; - tcd->tcd_type = i; - tcd->tcd_cpu = j; - } - -for (i =0 ; i <num_possible_cpus (); i++) -for (j =0 ; j <3 ; j++) { - cfs_trace_console_buffers[i][j] = -kmalloc (CFS_TRACE_CONSOLE_BUFFER_SIZE , -GFP_KERNEL ); - -if (!cfs_trace_console_buffers[i][j]) - goto out_buffers; - } - -return 0 ; - -out_buffers: -for (i =0 ; i <num_possible_cpus (); i++) -for (j =0 ; j <3 ; j++) { -kfree (cfs_trace_console_buffers[i][j]); - cfs_trace_console_buffers[i][j] =NULL ; - } -out_trace_data: -for (i =0 ; cfs_trace_data[i]; i++) { -kfree (cfs_trace_data[i]); - cfs_trace_data[i] =NULL ; - } -pr_err ("lnet: Not enough memory\n" ); -return -ENOMEM ; -} - -void cfs_tracefile_fini_arch (void ) -{ -int i; -int j; - -for (i =0 ; i <num_possible_cpus (); i++) -for (j =0 ; j <3 ; j++) { -kfree (cfs_trace_console_buffers[i][j]); - cfs_trace_console_buffers[i][j] =NULL ; - } - -for (i =0 ; cfs_trace_data[i]; i++) { -kfree (cfs_trace_data[i]); - cfs_trace_data[i] =NULL ; - } -} -static inline struct cfs_trace_page *cfs_tage_from_list (struct list_head *list) {
@@ -1334,21 +1258,38 @@ void cfs_trace_stop_thread(void)mutex_unlock (&cfs_trace_thread_mutex); } +/* percents to share the total debug memory for each type */ +static unsigned int pages_factor[CFS_TCD_TYPE_MAX ] = { +80 ,/* 80% pages for CFS_TCD_TYPE_PROC */ +10 ,/* 10% pages for CFS_TCD_TYPE_SOFTIRQ */ +10 /* 10% pages for CFS_TCD_TYPE_IRQ */ +}; +int cfs_tracefile_init (int max_pages) {struct cfs_trace_cpu_data *tcd;int i;int j; -int rc; -int factor; - rc =cfs_tracefile_init_arch (); -if (rc) -return rc; +/* initialize trace_data */ +memset (cfs_trace_data,0 ,sizeof (cfs_trace_data)); +for (i =0 ; i <CFS_TCD_TYPE_MAX ; i++) { + cfs_trace_data[i] = +kmalloc_array (num_possible_cpus (), +sizeof (union cfs_trace_data_union ), +GFP_KERNEL ); +if (!cfs_trace_data[i]) + goto out_trace_data; + } +/* arch related info initialized */ cfs_tcd_for_each (tcd, i, j) { -/* tcd_pages_factor is initialized int tracefile_init_arch. */ - factor = tcd->tcd_pages_factor; +int factor = pages_factor[i]; + +spin_lock_init (&tcd->tcd_lock); + tcd->tcd_pages_factor = factor; + tcd->tcd_type = i; + tcd->tcd_cpu = j;INIT_LIST_HEAD (&tcd->tcd_pages);INIT_LIST_HEAD (&tcd->tcd_stock_pages);INIT_LIST_HEAD (&tcd->tcd_daemon_pages);
@@ -1360,7 +1301,31 @@ int cfs_tracefile_init(int max_pages) tcd->tcd_shutting_down =0 ; } +for (i =0 ; i <num_possible_cpus (); i++) +for (j =0 ; j <3 ; j++) { + cfs_trace_console_buffers[i][j] = +kmalloc (CFS_TRACE_CONSOLE_BUFFER_SIZE , +GFP_KERNEL ); + +if (!cfs_trace_console_buffers[i][j]) + goto out_buffers; + } +return 0 ; + +out_buffers: +for (i =0 ; i <num_possible_cpus (); i++) +for (j =0 ; j <3 ; j++) { +kfree (cfs_trace_console_buffers[i][j]); + cfs_trace_console_buffers[i][j] =NULL ; + } +out_trace_data: +for (i =0 ; cfs_trace_data[i]; i++) { +kfree (cfs_trace_data[i]); + cfs_trace_data[i] =NULL ; + } +pr_err ("lnet: Not enough memory\n" ); +return -ENOMEM ; }static void trace_cleanup_on_all_cpus (void )
@@ -1372,6 +1337,9 @@ static void trace_cleanup_on_all_cpus(void)for_each_possible_cpu (cpu) {cfs_tcd_for_each_type_lock (tcd, i, cpu) { +if (!tcd->tcd_pages_factor) +/* Not initialised */ +continue ; tcd->tcd_shutting_down =1 ; list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages,
@@ -1390,12 +1358,23 @@ static void trace_cleanup_on_all_cpus(void)static void cfs_trace_cleanup (void ) {struct page_collection pc; +int i; +int j;INIT_LIST_HEAD (&pc.pc_pages);trace_cleanup_on_all_cpus (); -cfs_tracefile_fini_arch (); +for (i =0 ; i <num_possible_cpus (); i++) +for (j =0 ; j <3 ; j++) { +kfree (cfs_trace_console_buffers[i][j]); + cfs_trace_console_buffers[i][j] =NULL ; + } + +for (i =0 ; cfs_trace_data[i]; i++) { +kfree (cfs_trace_data[i]); + cfs_trace_data[i] =NULL ; + } }void cfs_tracefile_exit (void )
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -3
@@ -53,9 +53,6 @@void libcfs_run_debug_log_upcall (char *file); -int cfs_tracefile_init_arch (void ); -void cfs_tracefile_fini_arch (void ); -int cfs_tracefile_dump_all_pages (char *filename);void cfs_trace_debug_print (void );void cfs_trace_flush_pages (void );
Signature · 1 line
1.8.3.1
PATCH v4 12/14 lustre: libcfs: renamed CFS_TCD_TYPE_MAX to CFS_TCD_TYPE_CNT
In reply to James SimmonsFrom: NeilBrown <[email protected]>
The possible TCD types are 0, 1, 2.
So the MAX is 2.
The count of the number of types is 3.
CFS_TCD_TYPE_MAX is 3 - obviously wrong.
So rename it to CFS_TCD_TYPE_CNT.
Also there are 2 places where "3" is used rather
than the macro - fix them.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +8 -8
@@ -54,12 +54,12 @@ enum cfs_trace_buf_type {CFS_TCD_TYPE_PROC =0 ,CFS_TCD_TYPE_SOFTIRQ ,CFS_TCD_TYPE_IRQ , -CFS_TCD_TYPE_MAX +CFS_TCD_TYPE_CNT }; union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned; -char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_MAX ]; +char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_CNT ];char cfs_tracefile[TRACEFILE_NAME_SIZE ];long long cfs_tracefile_size =CFS_TRACEFILE_SIZE ;static struct tracefiled_ctl trace_tctl;
@@ -127,7 +127,7 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc,int cfs_trace_lock_tcd (struct cfs_trace_cpu_data *tcd,int walking) __acquires(&tcd->tc_lock) { -__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_MAX ); +__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_CNT );if (tcd->tcd_type ==CFS_TCD_TYPE_IRQ )spin_lock_irqsave (&tcd->tcd_lock, tcd->tcd_lock_flags);else if (tcd->tcd_type ==CFS_TCD_TYPE_SOFTIRQ )
@@ -142,7 +142,7 @@ int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking)void cfs_trace_unlock_tcd (struct cfs_trace_cpu_data *tcd,int walking) __releases(&tcd->tcd_lock) { -__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_MAX ); +__LASSERT (tcd->tcd_type <CFS_TCD_TYPE_CNT );if (tcd->tcd_type ==CFS_TCD_TYPE_IRQ )spin_unlock_irqrestore (&tcd->tcd_lock, tcd->tcd_lock_flags);else if (tcd->tcd_type ==CFS_TCD_TYPE_SOFTIRQ )
@@ -1259,7 +1259,7 @@ void cfs_trace_stop_thread(void) }/* percents to share the total debug memory for each type */ -static unsigned int pages_factor[CFS_TCD_TYPE_MAX ] = { +static unsigned int pages_factor[CFS_TCD_TYPE_CNT ] = {80 ,/* 80% pages for CFS_TCD_TYPE_PROC */ 10 ,/* 10% pages for CFS_TCD_TYPE_SOFTIRQ */ 10 /* 10% pages for CFS_TCD_TYPE_IRQ */
@@ -1273,7 +1273,7 @@ int cfs_tracefile_init(int max_pages)/* initialize trace_data */ memset (cfs_trace_data,0 ,sizeof (cfs_trace_data)); -for (i =0 ; i <CFS_TCD_TYPE_MAX ; i++) { +for (i =0 ; i <CFS_TCD_TYPE_CNT ; i++) { cfs_trace_data[i] = kmalloc_array(num_possible_cpus(), sizeof(union cfs_trace_data_union),
@@ -1302,7 +1302,7 @@ int cfs_tracefile_init(int max_pages) }for (i =0 ; i <num_possible_cpus (); i++) -for (j =0 ; j <3 ; j++) { +for (j =0 ; j <CFS_TCD_TYPE_CNT ; j++) { cfs_trace_console_buffers[i][j] =kmalloc (CFS_TRACE_CONSOLE_BUFFER_SIZE ,GFP_KERNEL );
@@ -1366,7 +1366,7 @@ static void cfs_trace_cleanup(void)trace_cleanup_on_all_cpus ();for (i =0 ; i <num_possible_cpus (); i++) -for (j =0 ; j <3 ; j++) { +for (j =0 ; j <CFS_TCD_TYPE_CNT ; j++) {kfree (cfs_trace_console_buffers[i][j]); cfs_trace_console_buffers[i][j] =NULL ; }
Signature · 1 line
1.8.3.1
PATCH v4 13/14 lustre: libcfs: discard TCD_MAX_TYPES
In reply to James SimmonsFrom: NeilBrown <[email protected]>
As well as CFS_TCD_TYPE_CNT we have TCD_MAX_TYPES which has a larger value but a similar meaning. Discard it and just use CFS_TCD_TYPE_CNT.
Two places relied on the fact that TCD_MAX_TYPES was larger and so there would be NULLs at the end of the array. Change them to check the array size properly.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +4 -5
@@ -48,7 +48,6 @@#include "tracefile.h" #define CFS_TRACE_CONSOLE_BUFFER_SIZE 1024 -#define TCD_MAX_TYPES 8enum cfs_trace_buf_type {CFS_TCD_TYPE_PROC =0 ,
@@ -57,7 +56,7 @@ enum cfs_trace_buf_type {CFS_TCD_TYPE_CNT }; -union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned; +union cfs_trace_data_union (*cfs_trace_data[CFS_TCD_TYPE_CNT])[NR_CPUS] __cacheline_aligned;char *cfs_trace_console_buffers[NR_CPUS ][CFS_TCD_TYPE_CNT ];char cfs_tracefile[TRACEFILE_NAME_SIZE ];
@@ -154,14 +153,14 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) }#define cfs_tcd_for_each (tcd, i, j) \ - for (i = 0; cfs_trace_data[i]; i++) \ + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) \ for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ j < num_possible_cpus(); \ j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)#define cfs_tcd_for_each_type_lock (tcd, i, cpu) \ - for (i = 0; cfs_trace_data[i] && \ + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i] && \ (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++)
@@ -1371,7 +1370,7 @@ static void cfs_trace_cleanup(void) cfs_trace_console_buffers[i][j] =NULL ; } -for (i =0 ; cfs_trace_data[i]; i++) { +for (i =0 ; i <CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) {kfree (cfs_trace_data[i]); cfs_trace_data[i] =NULL ; }
Signature · 1 line
1.8.3.1
PATCH v4 14/14 lustre: libcfs: format macros in tracefile.h
In reply to James SimmonsThe __LASSERT_* macros are ugly and hard to read. This patch beautifies them.
--- drivers/staging/lustre/lnet/libcfs/tracefile.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/lustre/lnet/libcfs/tracefile.h +12 -12
@@ -161,21 +161,21 @@ void cfs_trace_assertion_failed(const char *str, struct libcfs_debug_msg_data *m);/* ASSERTION that is safe to use within the debug system */ -#define __LASSERT (cond) \ -do { \ +#define __LASSERT (cond) \ +do { \ if (unlikely(!(cond))) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_EMERG, NULL); \ - cfs_trace_assertion_failed("ASSERTION("#cond") failed", \ - &msgdata); \ - } \ + LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_EMERG, NULL); \ + cfs_trace_assertion_failed("ASSERTION("#cond") failed", \ + &msgdata); \ + } \ } while (0) -#define __LASSERT_TAGE_INVARIANT (tage) \ -do { \ - __LASSERT(tage); \ - __LASSERT(tage->page); \ - __LASSERT(tage->used <= PAGE_SIZE); \ - __LASSERT(page_count(tage->page) > 0); \ +#define __LASSERT_TAGE_INVARIANT (tage) \ +do { \ + __LASSERT(tage); \ + __LASSERT(tage->page); \ + __LASSERT(tage->used <= PAGE_SIZE); \ + __LASSERT(page_count(tage->page) > 0); \ } while (0)#endif /* __LIBCFS_TRACEFILE_H__ */
Signature · 1 line
1.8.3.1
v4 cover lustre: libcfs: tracefile cleanups
In reply to James SimmonsQuoted 17 lines · James Simmons
The 4th version of a patch series aimed to cleanup the lustre tracefile handling. This set is mainly a repost of the 3rd set with the addition of a bug fix, patch number 2, that added proper range checking for the debugfs parameter
debug_mb. The 6th patch has been updated based on Andreas Dilger's feedback to resolve the brokeness ofcfs_print_to_console(). This patch series has been reposted to allow anyone interested in testing the the major changes are in the 6th and 7th patch which was rebased due to changes in the code.James Simmons (6):
lustre: libcfs: properly handle failure paths incfs_tracefile_init_arch()
lustre: libcfs: fixcfs_print_to_console()
lustre: libcfs: removecfs_trace_refill_stack()
lustre: libcfs: movecfs_trace_datadata totracefile.c
lustre: libcfs: cleanuptracefile.h
lustre: libcfs: format macros intracefile.h
Quoted 9 lines
NeilBrown (8):
lustre: libcfs: move tracefile locking fromlinux-tracefile.ctotracefile.c
lustre: libcfs: always range-checklibcfs_debug_mbsetting.
lustre: libcfs: open codecfs_trace_max_debug_mb()intocfs_trace_set_debug_mb()
lustre: libcfs: move tcd locking across totracefile.c
lustre: libcfs: mergelinux-tracefile.cintotracefile.c
lustre: libcfs: fold cfs_tracefile_*_arch into their only callers.
lustre: libcfs: renamedCFS_TCD_TYPE_MAXtoCFS_TCD_TYPE_CNT
lustre: libcfs: discardTCD_MAX_TYPES
Thanks.
I've applied these now, included them in the 'lustre' branch, and pushed it all out.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180725/d6bca0ff/attachment.sig>