Skip to contentSkip to conversation

opensm/osm_log.h: osm_log_is_active should return true for syslog

PATCH In review Yevgeny Kliteynik 2 participants 4 messages May 11, 2010 – May 17, 2010 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/osm_log.h: osm_log_is_active should return true for syslog

osm_log() always logs messages that came with OSM_LOG_SYS level, so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be printed with OSM_LOG macro, instead of using osm_log() directly.

---
 opensm/include/opensm/osm_log.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
opensm/include/opensm/osm_log.h +1 -1
index b2f105a..a494bc3 100644
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
 static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
 					  IN osm_log_level_t level)
 {
-	return ((p_log->level & level) != 0);
+	return (((OSM_LOG_SYS | p_log->level) & level) != 0);
 }
 
 /*
Signature · 6 lines
1.5.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4BE91DF9.4020902-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#2 lore raw
Quoted 16 lines · Yevgeny Kliteynik

osm_log() always logs messages that came with OSM_LOG_SYS level, so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be printed with OSM_LOG macro, instead of using osm_log() directly.

---
 opensm/include/opensm/osm_log.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
opensm/include/opensm/osm_log.h +0 -0
index b2f105a..a494bc3 100644

opensm/include/opensm/osm_log.h static inline void osm_log_set_level(IN osm_log_t * p_log, · line 359

Quoted 6 lines
opensm/include/opensm/osm_log.h +1 -1
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
 static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
 					  IN osm_log_level_t level)
 {
-	return ((p_log->level & level) != 0);
+	return (((OSM_LOG_SYS | p_log->level) & level) != 0);
 }

What about to set OSM_LOG_SYS bits in p_log->level at stage of initialization and to remove all subsequent explicit checks? Like this (against master):

opensm/opensm/osm_log.c +2 -2
index 54c2f36..bd4a200 100644
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
 #endif				/* __WIN__ */
 
 	/* If this is a call to syslog - always print it */
-	if (!(verbosity & (OSM_LOG_SYS | p_log->level)))
+	if (!(verbosity & p_log->level))
 		return;
 
 	va_start(args, p_str);
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush,
 				IN unsigned long max_size,
 				IN boolean_t accum_log_file)
 {
-	p_log->level = log_flags;
+	p_log->level = log_flags | OSM_LOG_SYS;
 	p_log->flush = flush;
 	p_log->count = 0;
 	p_log->max_size = max_size << 20; /* convert size in MB to bytes */

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 42 lines · Sasha Khapyorsky
Quoted 16 lines · Yevgeny Kliteynik

osm_log() always logs messages that came with OSM_LOG_SYS level, so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be printed with OSM_LOG macro, instead of using osm_log() directly.

---
  opensm/include/opensm/osm_log.h |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
opensm/include/opensm/osm_log.h +0 -0
index b2f105a..a494bc3 100644

opensm/include/opensm/osm_log.h static inline void osm_log_set_level(IN osm_log_t * p_log, · line 359

Quoted 6 lines
opensm/include/opensm/osm_log.h +1 -1
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
  static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
  					  IN osm_log_level_t level)
  {
-	return ((p_log->level&  level) != 0);
+	return (((OSM_LOG_SYS | p_log->level)&  level) != 0);
  }

What about to set OSM_LOG_SYS bits in p_log->level at stage of initialization and to remove all subsequent explicit checks? Like this (against master):

opensm/opensm/osm_log.c +1 -1
index 54c2f36..bd4a200 100644
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
  #endif				/* __WIN__ */
 
  	/* If this is a call to syslog - always print it */
-	if (!(verbosity&  (OSM_LOG_SYS | p_log->level)))
+	if (!(verbosity&  p_log->level))
  		return;
 
  	va_start(args, p_str);

opensm/opensm/osm_log.c ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush, · line 309

Quoted 5 lines
opensm/opensm/osm_log.c +1 -1
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush,
  				IN unsigned long max_size,
  				IN boolean_t accum_log_file)
  {
-	p_log->level = log_flags;
+	p_log->level = log_flags | OSM_LOG_SYS;

Sure, that should do the trick too.
Want me to send a patch, or will you do it?

-- Yevgeny

Quoted 7 lines
opensm/opensm/osm_log.c +0 -0
  	p_log->flush = flush;
  	p_log->count = 0;
  	p_log->max_size = max_size<<  20; /* convert size in MB to bytes */

Sasha

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4BE9A006.8030707-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#5 lore raw
Quoted 44 lines · Yevgeny Kliteynik
Quoted 43 lines · Sasha Khapyorsky
Quoted 17 lines · Yevgeny Kliteynik

osm_log() always logs messages that came with OSM_LOG_SYS level, so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be printed with OSM_LOG macro, instead of using osm_log() directly.

---
opensm/include/opensm/osm_log.h | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
opensm/include/opensm/osm_log.h +0 -0
index b2f105a..a494bc3 100644

opensm/include/opensm/osm_log.h static inline void osm_log_set_level(IN osm_log_t · line 360

Quoted 7 lines
opensm/include/opensm/osm_log.h +1 -1
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t
 * p_log,
 static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
 IN osm_log_level_t level)
 {
- return ((p_log->level& level) != 0);
+ return (((OSM_LOG_SYS | p_log->level)& level) != 0);
 }

What about to set OSM_LOG_SYS bits in p_log->level at stage of initialization and to remove all subsequent explicit checks? Like this (against master):

opensm/opensm/osm_log.c +1 -1
index 54c2f36..bd4a200 100644
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN
 osm_log_level_t verbosity,
 #endif /* __WIN__ */
 
 /* If this is a call to syslog - always print it */
- if (!(verbosity& (OSM_LOG_SYS | p_log->level)))
+ if (!(verbosity& p_log->level))
 return;
 
Quoted 11 lines

opensm/opensm/osm_log.c ib_api_status_t osm_log_init_v2(IN osm_log_t * · line 310

Quoted 8 lines

va_start(args, p_str);

opensm/opensm/osm_log.c +1 -1
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t *
 p_log, IN boolean_t flush,
 IN unsigned long max_size,
 IN boolean_t accum_log_file)
 {
- p_log->level = log_flags;
+ p_log->level = log_flags | OSM_LOG_SYS;

Sure, that should do the trick too.
Want me to send a patch, or will you do it?

OK, no answer, never mind.
I'll post the patch shortly.

-- Yevgeny

Quoted 7 lines

-- Yevgeny

Quoted 5 lines
opensm/opensm/osm_log.c +0 -0
 p_log->flush = flush;
 p_log->count = 0;

p_log->max_size = max_size<< 20; /* convert size in MB to bytes */

Quoted 8 lines
Quoted 2 lines

Sasha

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html