kern/151304: patch - definitions of variables tested by ASSERT_ATOMIC_LOAD_PTR

Svatopluk Kraus onwahe at gmail.com
Fri Oct 8 12:30:02 UTC 2010


>Number:         151304
>Category:       kern
>Synopsis:       patch - definitions of variables tested by ASSERT_ATOMIC_LOAD_PTR
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 08 12:30:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Svatopluk Kraus
>Release:        current
>Organization:
>Environment:
coldfire port
>Description:
A macro ASSERT_ATOMIC_LOAD_PTR() hits in colfire port I work on. It is possibly due to use of GNU GCC (4.5.1) compiler -Os option (size optimalization). The macro is applied on four places:

sys/kern/kern_lock.c
sys/kern/kern_mutex.c
sys/kern/kern_rwlock.c
sys/kern/kern_sx.c

and tests entries in four structures:

volatile uintptr_t lk_lock -> struct lock -> sys/sys/_lockmgr.h
volatile uintptr_t mtx_lock -> struct mtx -> sys/sys/_mutex.h
volatile uintptr_t rw_lock -> struct rwlock -> sys/sys/_rwlock.h
volatile uintptr_t sx_lock -> struct sx -> sys/sys/_sx.h
>How-To-Repeat:

>Fix:
I patch the entries definitions in structures by align attribute, I believe it is better than to do nothing. Moreover, it solved my problem.

Patch attached with submission follows:

Index: sys/sys/_rwlock.h
===================================================================
--- sys/sys/_rwlock.h   (revision 213567)
+++ sys/sys/_rwlock.h   (working copy)
@@ -37,7 +37,7 @@
  */
 struct rwlock {
        struct lock_object      lock_object;
-       volatile uintptr_t      rw_lock;
+       volatile uintptr_t      rw_lock __aligned(4);
 };

 #endif /* !_SYS__RWLOCK_H_ */
Index: sys/sys/_sx.h
===================================================================
--- sys/sys/_sx.h       (revision 213567)
+++ sys/sys/_sx.h       (working copy)
@@ -36,7 +36,7 @@
  */
 struct sx {
        struct lock_object      lock_object;
-       volatile uintptr_t      sx_lock;
+       volatile uintptr_t      sx_lock __aligned(4);
 };

 #endif /* !_SYS__SX_H_ */
Index: sys/sys/_lockmgr.h
===================================================================
--- sys/sys/_lockmgr.h  (revision 213567)
+++ sys/sys/_lockmgr.h  (working copy)
@@ -37,7 +37,7 @@

 struct lock {
        struct lock_object      lock_object;
-       volatile uintptr_t      lk_lock;
+       volatile uintptr_t      lk_lock __aligned(4);
        u_int                   lk_exslpfail;
        int                     lk_timo;
        int                     lk_pri;
Index: sys/sys/_mutex.h
===================================================================
--- sys/sys/_mutex.h    (revision 213567)
+++ sys/sys/_mutex.h    (working copy)
@@ -35,8 +35,8 @@
  * Sleep/spin mutex.
  */
 struct mtx {
-       struct lock_object      lock_object;    /* Common lock properties. */
-       volatile uintptr_t      mtx_lock;       /* Owner and flags. */
+       struct lock_object      lock_object;            /* Common lock properties. */
+       volatile uintptr_t      mtx_lock __aligned(4);  /* Owner and flags. */
 };

 #endif /* !_SYS__MUTEX_H_ */



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list