CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Apr 10 00:42:29 UTC 2022 Added Files: src/usr.bin/xlint/lint1: README.md Log Message: lint: add quickstart documentation to the implementation of lint To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/xlint/lint1/README.md Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Apr 10 00:42:29 UTC 2022 Added Files: src/usr.bin/xlint/lint1: README.md Log Message: lint: add quickstart documentation to the implementation of lint To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/xlint/lint1/README.md Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/usr.bin/xlint/lint1/README.md diff -u /dev/null src/usr.bin/xlint/lint1/README.md:1.1 --- /dev/null Sun Apr 10 00:42:29 2022 +++ src/usr.bin/xlint/lint1/README.md Sun Apr 10 00:42:29 2022 @@ -0,0 +1,139 @@ +[//]: # ($NetBSD: README.md,v 1.1 2022/04/10 00:42:29 rillig Exp $) + +# Introduction + +To learn how a specific message is triggered, read the corresponding unit +test in `tests/usr.bin/xlint/lint1/msg_???.c`. + +# Features + +## Type checking + +Lint has stricter type checking than most C compilers. +It warns about type conversions that may result in alignment problems, +see the test `msg_135.c` for examples. + +## Control flow analysis + +Lint roughly tracks the control flow inside a single function. +It doesn't follow `goto` statements though. +See the test `msg_193.c` for examples. + +## Error handling + +Lint tries to continue parsing and checking even after seeing errors. +This part of lint is not robust though, so expect some crashes here, +as variables may not be properly initialized or be null pointers. + +# Fundamental types + +Lint mainly analyzes expressions (`tnode_t`), which are formed from operators +(`op_t`) and their operands (`tnode_t`). +Each node has a type (`type_t`) and a few other properties. + +## type_t + +The basic types are `int`, `_Bool`, `unsigned long`, and so on. +A basic type is created by `gettyp(INT)`. +Derived types are created by `block_derive_pointer`, +`block_derive_array` and `block_derive_function`. +(See [below](#memory-management) for the meaning of the prefix `block_`.) + +After a type has been created, it should not be modified anymore. +Ideally all references to types would be `const`, but that's a lot of work. +Until that is implemented, before modifying a type, +it needs to be copied using `block_dup_type` or `expr_dup_type`. + +## tnode_t + +When lint parses an expressions, +it builds a tree of nodes representing the AST. +Each node has an operator, which defines which other members may be accessed. +The operators and their properties are defined in `ops.def`. +Some examples for operators: + +| Operator | Meaning | +|--|-| +| CON | compile-time constant in `tn_val` | +| NAME | references the identifier in `tn_sym` | +| UPLUS| the unary operator `+tn_left` | +| PLUS | the binary operator `tn_left + tn_right`| +| CALL | a function call, typically CALL(LOAD(NAME("function"))) | +| CVT | an implicit conversion or an explicit cast | + +## sym_t + +There is a single symbol table (`symtab`) for the whole translation unit. +This means that the same identifier may appear multiple times. +To distinguish the identifiers, each symbol has a block level. +Symbols from inner scopes are added to the beginning of the table, +so they are found first when looking for the identifier. + +# Memory management + +## Block scope + +The memory that is allocated by the `block_*_alloc` functions is freed at the +end of analyzing the block, that is, after the closing `}`. +See `compound_statement_rbrace:` in `cgram.y`. + +## Expression scope + +The memory that is allocated by the `expr_*_alloc` functions is freed at the +end of analyzing the expression. +See `expr_free_all`. + +# Null pointers + +* Expressions can be null. + * This typically happens in case of syntax errors or other errors. +* The subtype of a pointer, array or function is never null. + +# Common variable names + +| Name | Type | Meaning | +|--|---|--| +| t| `tspec_t` | a simple type such as `INT`, `FUNC`, `PTR` | +| tp | `type_t` | a complete type such as `pointer to array[3] of int` | +| stp | `type_t` | the subtype of a pointer, array or function | +| tn | `tnode_t` | a tree node, mostly used for expressions | +| op | `op_t`| an operator used in an expression| +| ln | `tnode_t` | the left-hand side operand of a binary operator | +| rn | `tnode_t` | the right-hand side operand of a binary operator | +| sym | `sym_t` | a symbol from the symbol table | + +# Abbreviations + +| Abbr | Expanded | +|--|--| +| l| left | +| r| right| +| st | subtype | +| op | operator | + +# Tests + +The tests
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:52:23 UTC 2022 Modified Files: src/sys/kern: uipc_socket.c uipc_socket2.c uipc_usrreq.c src/sys/sys: socketvar.h Log Message: unix(4): Convert membar_exit to membar_release. Use atomic_load_consume or atomic_load_relaxed where necessary. Comment on why unlocked nonatomic access is valid where it is done. To generate a diff of this commit: cvs rdiff -u -r1.301 -r1.302 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.140 -r1.141 src/sys/kern/uipc_socket2.c cvs rdiff -u -r1.201 -r1.202 src/sys/kern/uipc_usrreq.c cvs rdiff -u -r1.164 -r1.165 src/sys/sys/socketvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.301 src/sys/kern/uipc_socket.c:1.302 --- src/sys/kern/uipc_socket.c:1.301 Sat Mar 12 16:06:15 2022 +++ src/sys/kern/uipc_socket.c Sat Apr 9 23:52:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.301 2022/03/12 16:06:15 riastradh Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.302 2022/04/09 23:52:22 riastradh Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.301 2022/03/12 16:06:15 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.302 2022/04/09 23:52:22 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -539,6 +539,10 @@ socreate(int dom, struct socket **aso, i * the lock with another socket, e.g. socketpair(2) case. */ if (lockso) { + /* + * lockso->so_lock should be stable at this point, so + * no need for atomic_load_*. + */ lock = lockso->so_lock; so->so_lock = lock; mutex_obj_hold(lock); Index: src/sys/kern/uipc_socket2.c diff -u src/sys/kern/uipc_socket2.c:1.140 src/sys/kern/uipc_socket2.c:1.141 --- src/sys/kern/uipc_socket2.c:1.140 Sat Oct 2 02:07:41 2021 +++ src/sys/kern/uipc_socket2.c Sat Apr 9 23:52:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket2.c,v 1.140 2021/10/02 02:07:41 thorpej Exp $ */ +/* $NetBSD: uipc_socket2.c,v 1.141 2022/04/09 23:52:23 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.140 2021/10/02 02:07:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.141 2022/04/09 23:52:23 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -134,7 +134,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket2 * * o In order to mutate so_lock, the lock pointed to by the current value * of so_lock must be held: i.e., the socket must be held locked by the - * changing thread. The thread must issue membar_exit() to prevent + * changing thread. The thread must issue membar_release() to prevent * memory accesses being reordered, and can set so_lock to the desired * value. If the lock pointed to by the new value of so_lock is not * held by the changing thread, the socket must then be considered @@ -324,6 +324,9 @@ sonewconn(struct socket *head, bool sore /* * Share the lock with the listening-socket, it may get unshared * once the connection is complete. + * + * so_lock is stable while we hold the socket locked, so no + * need for atomic_load_* here. */ mutex_obj_hold(head->so_lock); so->so_lock = head->so_lock; @@ -537,7 +540,7 @@ sbwait(struct sockbuf *sb) error = cv_timedwait(>sb_cv, lock, sb->sb_timeo); else error = cv_timedwait_sig(>sb_cv, lock, sb->sb_timeo); - if (__predict_false(lock != so->so_lock)) + if (__predict_false(lock != atomic_load_relaxed(>so_lock))) solockretry(so, lock); return error; } @@ -589,6 +592,8 @@ sowakeup(struct socket *so, struct sockb * Reset a socket's lock pointer. Wake all threads waiting on the * socket's condition variables so that they can restart their waits * using the new lock. The existing lock must be held. + * + * Caller must have issued membar_release before this. */ void solockreset(struct socket *so, kmutex_t *lock) @@ -1464,9 +1469,9 @@ void solockretry(struct socket *so, kmutex_t *lock) { - while (lock != so->so_lock) { + while (lock != atomic_load_relaxed(>so_lock)) { mutex_exit(lock); - lock = so->so_lock; + lock = atomic_load_consume(>so_lock); mutex_enter(lock); } } @@ -1475,6 +1480,10 @@ bool solocked(const struct socket *so) { + /* + * Used only for diagnostic assertions, so so_lock should be + * stable at this point, hence on need for atomic_load_*. + */ return mutex_owned(so->so_lock); } @@ -1483,6 +1492,10 @@ solocked2(const struct socket *so1, cons { const kmutex_t *lock; + /* + * Used only for diagnostic assertions, so so_lock should be + * stable at this point, hence on need for atomic_load_*. + */ lock = so1->so_lock; if (lock != so2->so_lock) return false; @@ -1533,7
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:52:23 UTC 2022 Modified Files: src/sys/kern: uipc_socket.c uipc_socket2.c uipc_usrreq.c src/sys/sys: socketvar.h Log Message: unix(4): Convert membar_exit to membar_release. Use atomic_load_consume or atomic_load_relaxed where necessary. Comment on why unlocked nonatomic access is valid where it is done. To generate a diff of this commit: cvs rdiff -u -r1.301 -r1.302 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.140 -r1.141 src/sys/kern/uipc_socket2.c cvs rdiff -u -r1.201 -r1.202 src/sys/kern/uipc_usrreq.c cvs rdiff -u -r1.164 -r1.165 src/sys/sys/socketvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:52:05 UTC 2022 Modified Files: src/sys/kern: sys_select.c Log Message: select(9): Use membar_acquire/release and atomic_store_release. No store-before-load ordering here -- this was obviously always intended to be load-before-load/store all along. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/kern/sys_select.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_select.c diff -u src/sys/kern/sys_select.c:1.58 src/sys/kern/sys_select.c:1.59 --- src/sys/kern/sys_select.c:1.58 Sat Feb 12 15:51:29 2022 +++ src/sys/kern/sys_select.c Sat Apr 9 23:52:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_select.c,v 1.58 2022/02/12 15:51:29 thorpej Exp $ */ +/* $NetBSD: sys_select.c,v 1.59 2022/04/09 23:52:05 riastradh Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020 The NetBSD Foundation, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.58 2022/02/12 15:51:29 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.59 2022/04/09 23:52:05 riastradh Exp $"); #include #include @@ -282,7 +282,7 @@ sel_do_scan(const char *opname, void *fd l->l_selflag = SEL_SCANNING; } ncoll = sc->sc_ncoll; - membar_exit(); + membar_release(); if (opname == selop_select) { error = selscan((char *)fds, nf, ni, retval); @@ -653,7 +653,7 @@ selrecord(lwp_t *selector, struct selinf * barrier to ensure that we access sel_lwp (above) before * other fields - this guards against a call to selclear(). */ - membar_enter(); + membar_acquire(); sip->sel_lwp = selector; SLIST_INSERT_HEAD(>l_selwait, sip, sel_chain); /* Copy the argument, which is for selnotify(). */ @@ -872,9 +872,8 @@ selclear(void) * globally visible. */ next = SLIST_NEXT(sip, sel_chain); - membar_exit(); /* Release the record for another named waiter to use. */ - sip->sel_lwp = NULL; + atomic_store_release(>sel_lwp, NULL); } mutex_spin_exit(lock); }
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:52:05 UTC 2022 Modified Files: src/sys/kern: sys_select.c Log Message: select(9): Use membar_acquire/release and atomic_store_release. No store-before-load ordering here -- this was obviously always intended to be load-before-load/store all along. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/kern/sys_select.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:57 UTC 2022 Modified Files: src/sys/kern: subr_thmap.c Log Message: thmap(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_thmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_thmap.c diff -u src/sys/kern/subr_thmap.c:1.11 src/sys/kern/subr_thmap.c:1.12 --- src/sys/kern/subr_thmap.c:1.11 Fri Apr 1 00:16:40 2022 +++ src/sys/kern/subr_thmap.c Sat Apr 9 23:51:57 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_thmap.c,v 1.11 2022/04/01 00:16:40 riastradh Exp $ */ +/* $NetBSD: subr_thmap.c,v 1.12 2022/04/09 23:51:57 riastradh Exp $ */ /*- * Copyright (c) 2018 Mindaugas Rasiukevicius @@ -112,7 +112,7 @@ #include "utils.h" #endif -THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.11 2022/04/01 00:16:40 riastradh Exp $"); +THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.12 2022/04/09 23:51:57 riastradh Exp $"); #include @@ -121,7 +121,7 @@ THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.1 */ #ifdef _KERNEL #define ASSERT KASSERT -#define atomic_thread_fence(x) membar_exit() /* only used for release order */ +#define atomic_thread_fence(x) membar_release() /* only used for release order */ #define atomic_compare_exchange_weak_explicit_32(p, e, n, m1, m2) \ (atomic_cas_32((p), *(e), (n)) == *(e)) #define atomic_compare_exchange_weak_explicit_ptr(p, e, n, m1, m2) \
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:48 UTC 2022 Modified Files: src/sys/kern: subr_pool.c Log Message: pool(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.281 -r1.282 src/sys/kern/subr_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_pool.c diff -u src/sys/kern/subr_pool.c:1.281 src/sys/kern/subr_pool.c:1.282 --- src/sys/kern/subr_pool.c:1.281 Sun Feb 27 14:16:43 2022 +++ src/sys/kern/subr_pool.c Sat Apr 9 23:51:48 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.281 2022/02/27 14:16:43 riastradh Exp $ */ +/* $NetBSD: subr_pool.c,v 1.282 2022/04/09 23:51:48 riastradh Exp $ */ /* * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018, @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.281 2022/02/27 14:16:43 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.282 2022/04/09 23:51:48 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -2621,7 +2621,7 @@ pool_pcg_put(pcg_t *volatile *head, pcg_ } pcg->pcg_next = o; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif n = atomic_cas_ptr(head, o, pcg); if (o == n) {
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:57 UTC 2022 Modified Files: src/sys/kern: subr_thmap.c Log Message: thmap(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_thmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:48 UTC 2022 Modified Files: src/sys/kern: subr_pool.c Log Message: pool(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.281 -r1.282 src/sys/kern/subr_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:22 UTC 2022 Modified Files: src/sys/kern: subr_ipi.c Log Message: ipi(9): Convert membar_exit/enter to membar_release/acquire. No store-before-load ordering needed here, just need to ensure that in A, ipi_send, ipi receive, B, memory operations in A happen-before memory operations in B. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_ipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_ipi.c diff -u src/sys/kern/subr_ipi.c:1.9 src/sys/kern/subr_ipi.c:1.10 --- src/sys/kern/subr_ipi.c:1.9 Fri Nov 27 20:11:33 2020 +++ src/sys/kern/subr_ipi.c Sat Apr 9 23:51:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_ipi.c,v 1.9 2020/11/27 20:11:33 riastradh Exp $ */ +/* $NetBSD: subr_ipi.c,v 1.10 2022/04/09 23:51:22 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.9 2020/11/27 20:11:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.10 2022/04/09 23:51:22 riastradh Exp $"); #include #include @@ -190,7 +190,7 @@ ipi_mark_pending(u_int ipi_id, struct cp /* Mark as pending and return true if not previously marked. */ if ((atomic_load_acquire(>ci_ipipend[i]) & bitm) == 0) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_or_32(>ci_ipipend[i], bitm); return true; @@ -265,7 +265,7 @@ ipi_trigger_broadcast(u_int ipi_id, bool /* * put_msg: insert message into the mailbox. * - * Caller is responsible for issuing membar_exit first. + * Caller is responsible for issuing membar_release first. */ static inline void put_msg(ipi_mbox_t *mbox, ipi_msg_t *msg) @@ -304,7 +304,7 @@ ipi_cpu_handler(void) } pending = atomic_swap_32(>ci_ipipend[i], 0); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif while ((bit = ffs(pending)) != 0) { const u_int ipi_id = (i << IPI_BITW_SHIFT) | --bit; @@ -342,7 +342,7 @@ ipi_msg_cpu_handler(void *arg __unused) /* Ack the request. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_dec_uint(>_pending); } @@ -365,7 +365,7 @@ ipi_unicast(ipi_msg_t *msg, struct cpu_i msg->_pending = 1; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif put_msg(_mboxes[id], msg); @@ -391,7 +391,7 @@ ipi_multicast(ipi_msg_t *msg, const kcpu local = !!kcpuset_isset(target, cpu_index(self)); msg->_pending = kcpuset_countset(target) - local; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif for (CPU_INFO_FOREACH(cii, ci)) { @@ -429,7 +429,7 @@ ipi_broadcast(ipi_msg_t *msg, bool skip_ msg->_pending = ncpu - 1; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif /* Broadcast IPIs for remote CPUs. */
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:22 UTC 2022 Modified Files: src/sys/kern: subr_ipi.c Log Message: ipi(9): Convert membar_exit/enter to membar_release/acquire. No store-before-load ordering needed here, just need to ensure that in A, ipi_send, ipi receive, B, memory operations in A happen-before memory operations in B. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_ipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:09 UTC 2022 Modified Files: src/sys/kern: subr_copy.c Log Message: ucas(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_copy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_copy.c diff -u src/sys/kern/subr_copy.c:1.15 src/sys/kern/subr_copy.c:1.16 --- src/sys/kern/subr_copy.c:1.15 Fri Feb 11 17:53:28 2022 +++ src/sys/kern/subr_copy.c Sat Apr 9 23:51:09 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_copy.c,v 1.15 2022/02/11 17:53:28 riastradh Exp $ */ +/* $NetBSD: subr_copy.c,v 1.16 2022/04/09 23:51:09 riastradh Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008, 2019 @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.15 2022/02/11 17:53:28 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.16 2022/04/09 23:51:09 riastradh Exp $"); #define __UFETCHSTORE_PRIVATE #define __UCAS_PRIVATE @@ -412,7 +412,7 @@ ucas_critical_cpu_gate(void *arg __unuse * the following atomic_dec_uint into a store-release. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_dec_uint(_critical_pausing_cpus); @@ -449,7 +449,7 @@ ucas_critical_wait(void) * happen before the ucas -- no buffered stores in other CPUs * can clobber it later on, for instance. * - * Matches membar_exit/atomic_dec_uint (store-release) in + * Matches membar_release/atomic_dec_uint (store-release) in * ucas_critical_cpu_gate. */ while (atomic_load_acquire(_critical_pausing_cpus) > 0) {
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:51:09 UTC 2022 Modified Files: src/sys/kern: subr_copy.c Log Message: ucas(9): Convert membar_exit to membar_release. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_copy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:46:19 UTC 2022 Modified Files: src/sys/kern: kern_rwlock.c Log Message: rwlock(9): Convert to membar_acquire/release. Leave an XXX comment where I suspect there might be a missing membar -- to be audited when I have more time to think! To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_rwlock.c diff -u src/sys/kern/kern_rwlock.c:1.65 src/sys/kern/kern_rwlock.c:1.66 --- src/sys/kern/kern_rwlock.c:1.65 Sat Feb 22 21:24:45 2020 +++ src/sys/kern/kern_rwlock.c Sat Apr 9 23:46:19 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock.c,v 1.65 2020/02/22 21:24:45 ad Exp $ */ +/* $NetBSD: kern_rwlock.c,v 1.66 2022/04/09 23:46:19 riastradh Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020 @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.65 2020/02/22 21:24:45 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.66 2022/04/09 23:46:19 riastradh Exp $"); #include "opt_lockdebug.h" @@ -101,12 +101,12 @@ do { \ * Memory barriers. */ #ifdef __HAVE_ATOMIC_AS_MEMBAR -#define RW_MEMBAR_ENTER() -#define RW_MEMBAR_EXIT() +#define RW_MEMBAR_ACQUIRE() +#define RW_MEMBAR_RELEASE() #define RW_MEMBAR_PRODUCER() #else -#define RW_MEMBAR_ENTER() membar_enter() -#define RW_MEMBAR_EXIT() membar_exit() +#define RW_MEMBAR_ACQUIRE() membar_acquire() +#define RW_MEMBAR_RELEASE() membar_release() #define RW_MEMBAR_PRODUCER() membar_producer() #endif @@ -344,7 +344,7 @@ rw_vector_enter(krwlock_t *rw, const krw ~RW_WRITE_WANTED); if (__predict_true(next == owner)) { /* Got it! */ -RW_MEMBAR_ENTER(); +RW_MEMBAR_ACQUIRE(); break; } @@ -396,6 +396,7 @@ rw_vector_enter(krwlock_t *rw, const krw continue; } next = rw_cas(rw, owner, owner | set_wait); + /* XXX membar? */ if (__predict_false(next != owner)) { turnstile_exit(rw); owner = next; @@ -471,7 +472,7 @@ rw_vector_exit(krwlock_t *rw) * proceed to do direct handoff if there are waiters, and if the * lock would become unowned. */ - RW_MEMBAR_EXIT(); + RW_MEMBAR_RELEASE(); for (;;) { newown = (owner - decr); if ((newown & (RW_THREAD | RW_HAS_WAITERS)) == RW_HAS_WAITERS) @@ -585,7 +586,7 @@ rw_vector_tryenter(krwlock_t *rw, const RW_ASSERT(rw, (op != RW_READER && RW_OWNER(rw) == curthread) || (op == RW_READER && RW_COUNT(rw) != 0)); - RW_MEMBAR_ENTER(); + RW_MEMBAR_ACQUIRE(); return 1; }
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:46:19 UTC 2022 Modified Files: src/sys/kern: kern_rwlock.c Log Message: rwlock(9): Convert to membar_acquire/release. Leave an XXX comment where I suspect there might be a missing membar -- to be audited when I have more time to think! To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:46:10 UTC 2022 Modified Files: src/sys/kern: kern_mutex.c Log Message: mutex(9): Convert to membar_acquire/release. Except for setting the waiters bit -- not sure if this is actually required to be store-before-load/store. Seems unlikely -- surely we'd have seen some serious bug by now if not, because membar_enter has failed to guarantee that on x86! -- but I'm leaving it for now until I have time to think enough about it to be sure one way or another. To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/sys/kern/kern_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.98 src/sys/kern/kern_mutex.c:1.99 --- src/sys/kern/kern_mutex.c:1.98 Wed Aug 25 04:13:42 2021 +++ src/sys/kern/kern_mutex.c Sat Apr 9 23:46:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.98 2021/08/25 04:13:42 thorpej Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.99 2022/04/09 23:46:10 riastradh Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.98 2021/08/25 04:13:42 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.99 2022/04/09 23:46:10 riastradh Exp $"); #include #include @@ -169,10 +169,12 @@ do { \ */ #ifdef __HAVE_ATOMIC_AS_MEMBAR #define MUTEX_MEMBAR_ENTER() -#define MUTEX_MEMBAR_EXIT() +#define MUTEX_MEMBAR_ACQUIRE() +#define MUTEX_MEMBAR_RELEASE() #else #define MUTEX_MEMBAR_ENTER() membar_enter() -#define MUTEX_MEMBAR_EXIT() membar_exit() +#define MUTEX_MEMBAR_ACQUIRE() membar_acquire() +#define MUTEX_MEMBAR_RELEASE() membar_release() #endif /* @@ -238,7 +240,7 @@ MUTEX_ACQUIRE(kmutex_t *mtx, uintptr_t c MUTEX_INHERITDEBUG(oldown, mtx->mtx_owner); MUTEX_INHERITDEBUG(newown, oldown); rv = MUTEX_CAS(>mtx_owner, oldown, newown); - MUTEX_MEMBAR_ENTER(); + MUTEX_MEMBAR_ACQUIRE(); return rv; } @@ -256,7 +258,7 @@ MUTEX_RELEASE(kmutex_t *mtx) { uintptr_t newown; - MUTEX_MEMBAR_EXIT(); + MUTEX_MEMBAR_RELEASE(); newown = 0; MUTEX_INHERITDEBUG(newown, mtx->mtx_owner); mtx->mtx_owner = newown;
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:46:10 UTC 2022 Modified Files: src/sys/kern: kern_mutex.c Log Message: mutex(9): Convert to membar_acquire/release. Except for setting the waiters bit -- not sure if this is actually required to be store-before-load/store. Seems unlikely -- surely we'd have seen some serious bug by now if not, because membar_enter has failed to guarantee that on x86! -- but I'm leaving it for now until I have time to think enough about it to be sure one way or another. To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/sys/kern/kern_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:45 UTC 2022 Modified Files: src/sys/kern: vfs_vnode.c Log Message: vfs(9): Add XXX comment about unclear membar_enter. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.142 src/sys/kern/vfs_vnode.c:1.143 --- src/sys/kern/vfs_vnode.c:1.142 Sat Apr 9 23:38:33 2022 +++ src/sys/kern/vfs_vnode.c Sat Apr 9 23:45:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.142 2022/04/09 23:38:33 riastradh Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.143 2022/04/09 23:45:45 riastradh Exp $ */ /*- * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc. @@ -148,7 +148,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.142 2022/04/09 23:38:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.143 2022/04/09 23:45:45 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_pax.h" @@ -273,6 +273,8 @@ _vstate_assert(vnode_t *vp, enum vnode_s /* * Prevent predictive loads from the CPU, but check the state * without loooking first. + * + * XXX what does this pair with? */ membar_enter(); if (state == VS_ACTIVE && refcnt > 0 &&
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:45 UTC 2022 Modified Files: src/sys/kern: vfs_vnode.c Log Message: vfs(9): Add XXX comment about unclear membar_enter. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:37 UTC 2022 Modified Files: src/sys/kern: kern_lwp.c kern_turnstile.c src/sys/sys: lwp.h Log Message: kern: Handle l_mutex with atomic_store_release, atomic_load_consume. - Where the lock is held and known to be correct, no atomic. - In loops to acquire the lock, use atomic_load_relaxed before we restart with atomic_load_consume. Nix membar_exit. (Who knows, using atomic_load_consume here might fix bugs on Alpha!) To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_turnstile.c cvs rdiff -u -r1.214 -r1.215 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.247 src/sys/kern/kern_lwp.c:1.248 --- src/sys/kern/kern_lwp.c:1.247 Thu Mar 10 12:21:25 2022 +++ src/sys/kern/kern_lwp.c Sat Apr 9 23:45:36 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.247 2022/03/10 12:21:25 riastradh Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.248 2022/04/09 23:45:36 riastradh Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020 @@ -217,7 +217,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.247 2022/03/10 12:21:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.248 2022/04/09 23:45:36 riastradh Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -1565,8 +1565,7 @@ lwp_setlock(struct lwp *l, kmutex_t *mtx KASSERT(mutex_owned(oldmtx)); - membar_exit(); - l->l_mutex = mtx; + atomic_store_release(>l_mutex, mtx); return oldmtx; } @@ -1582,8 +1581,7 @@ lwp_unlock_to(struct lwp *l, kmutex_t *m KASSERT(lwp_locked(l, NULL)); old = l->l_mutex; - membar_exit(); - l->l_mutex = mtx; + atomic_store_release(>l_mutex, mtx); mutex_spin_exit(old); } @@ -1593,9 +1591,9 @@ lwp_trylock(struct lwp *l) kmutex_t *old; for (;;) { - if (!mutex_tryenter(old = l->l_mutex)) + if (!mutex_tryenter(old = atomic_load_consume(>l_mutex))) return 0; - if (__predict_true(l->l_mutex == old)) + if (__predict_true(atomic_load_relaxed(>l_mutex) == old)) return 1; mutex_spin_exit(old); } Index: src/sys/kern/kern_turnstile.c diff -u src/sys/kern/kern_turnstile.c:1.41 src/sys/kern/kern_turnstile.c:1.42 --- src/sys/kern/kern_turnstile.c:1.41 Wed Feb 23 21:54:41 2022 +++ src/sys/kern/kern_turnstile.c Sat Apr 9 23:45:36 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_turnstile.c,v 1.41 2022/02/23 21:54:41 andvar Exp $ */ +/* $NetBSD: kern_turnstile.c,v 1.42 2022/04/09 23:45:36 riastradh Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2009, 2019, 2020 @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.41 2022/02/23 21:54:41 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.42 2022/04/09 23:45:36 riastradh Exp $"); #include #include @@ -252,7 +252,7 @@ turnstile_lendpri(lwp_t *cur) * Because we already have another LWP lock (l->l_mutex) held, * we need to play a try lock dance to avoid deadlock. */ - dolock = l->l_mutex != owner->l_mutex; + dolock = l->l_mutex != atomic_load_relaxed(>l_mutex); if (l == owner || (dolock && !lwp_trylock(owner))) { /* * The owner was changed behind us or trylock failed. @@ -299,7 +299,7 @@ turnstile_lendpri(lwp_t *cur) l = owner; } LOCKDEBUG_BARRIER(l->l_mutex, 1); - if (cur->l_mutex != l->l_mutex) { + if (cur->l_mutex != atomic_load_relaxed(>l_mutex)) { lwp_unlock(l); lwp_lock(cur); } @@ -322,7 +322,8 @@ turnstile_unlendpri(turnstile_t *ts) KASSERT(ts->ts_inheritor != NULL); ts->ts_inheritor = NULL; - dolock = l->l_mutex == l->l_cpu->ci_schedstate.spc_lwplock; + dolock = (atomic_load_relaxed(>l_mutex) == + l->l_cpu->ci_schedstate.spc_lwplock); if (dolock) { lwp_lock(l); } Index: src/sys/sys/lwp.h diff -u src/sys/sys/lwp.h:1.214 src/sys/sys/lwp.h:1.215 --- src/sys/sys/lwp.h:1.214 Sat Apr 9 13:38:15 2022 +++ src/sys/sys/lwp.h Sat Apr 9 23:45:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lwp.h,v 1.214 2022/04/09 13:38:15 riastradh Exp $ */ +/* $NetBSD: lwp.h,v 1.215 2022/04/09 23:45:37 riastradh Exp $ */ /* * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010, 2019, 2020 @@ -53,6 +53,7 @@ struct lwp; /* forward declare this for so it can get l_cpu. */ static __inline struct cpu_info *lwp_getcpu(struct lwp *); #include /* curcpu() and cpu_info */ +#include #ifdef _KERNEL_OPT #include "opt_kcov.h" #include "opt_kmsan.h" @@ -407,16 +408,16 @@ void lwp_whatis(uintptr_t, void (*)(cons static __inline void lwp_lock(lwp_t *l) { - kmutex_t *old = l->l_mutex; + kmutex_t *old = atomic_load_consume(>l_mutex); /* * Note: mutex_spin_enter() will have posted a read barrier. * Re-test l->l_mutex. If it has changed, we need to try again. */ mutex_spin_enter(old); - while
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:37 UTC 2022 Modified Files: src/sys/kern: kern_lwp.c kern_turnstile.c src/sys/sys: lwp.h Log Message: kern: Handle l_mutex with atomic_store_release, atomic_load_consume. - Where the lock is held and known to be correct, no atomic. - In loops to acquire the lock, use atomic_load_relaxed before we restart with atomic_load_consume. Nix membar_exit. (Who knows, using atomic_load_consume here might fix bugs on Alpha!) To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_turnstile.c cvs rdiff -u -r1.214 -r1.215 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:23 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: sleepq.c Log Message: rumpkern/sleepq: Convert membar_exit/store to atomic_store_release. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/rump/librump/rumpkern/sleepq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/sleepq.c diff -u src/sys/rump/librump/rumpkern/sleepq.c:1.21 src/sys/rump/librump/rumpkern/sleepq.c:1.22 --- src/sys/rump/librump/rumpkern/sleepq.c:1.21 Sun Nov 1 20:58:38 2020 +++ src/sys/rump/librump/rumpkern/sleepq.c Sat Apr 9 23:45:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: sleepq.c,v 1.21 2020/11/01 20:58:38 christos Exp $ */ +/* $NetBSD: sleepq.c,v 1.22 2022/04/09 23:45:23 riastradh Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.21 2020/11/01 20:58:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.22 2022/04/09 23:45:23 riastradh Exp $"); #include #include @@ -163,7 +163,6 @@ lwp_unlock_to(struct lwp *l, kmutex_t *n KASSERT(mutex_owned(l->l_mutex)); old = l->l_mutex; - membar_exit(); - l->l_mutex = new; + atomic_store_release(>l_mutex, new); mutex_spin_exit(old); }
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:23 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: sleepq.c Log Message: rumpkern/sleepq: Convert membar_exit/store to atomic_store_release. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/rump/librump/rumpkern/sleepq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:14 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: scheduler.c Log Message: rumpkern/scheduler: Use membar_release. ...but add an XXX comment asking for clarity on what it pairs with. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/rump/librump/rumpkern/scheduler.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/scheduler.c diff -u src/sys/rump/librump/rumpkern/scheduler.c:1.52 src/sys/rump/librump/rumpkern/scheduler.c:1.53 --- src/sys/rump/librump/rumpkern/scheduler.c:1.52 Sun Nov 1 20:58:38 2020 +++ src/sys/rump/librump/rumpkern/scheduler.c Sat Apr 9 23:45:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: scheduler.c,v 1.52 2020/11/01 20:58:38 christos Exp $ */ +/* $NetBSD: scheduler.c,v 1.53 2022/04/09 23:45:14 riastradh Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.52 2020/11/01 20:58:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.53 2022/04/09 23:45:14 riastradh Exp $"); #include #include @@ -473,7 +473,7 @@ rump_unschedule_cpu1(struct lwp *l, void if (interlock == rcpu->rcpu_mtx) rumpuser_mutex_enter_nowrap(rcpu->rcpu_mtx); else - membar_exit(); + membar_release(); /* XXX what does this pair with? */ /* Release the CPU. */ old = atomic_swap_ptr(>rcpu_prevlwp, l);
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:14 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: scheduler.c Log Message: rumpkern/scheduler: Use membar_release. ...but add an XXX comment asking for clarity on what it pairs with. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/rump/librump/rumpkern/scheduler.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/net/lib/libshmif
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:02 UTC 2022 Modified Files: src/sys/rump/net/lib/libshmif: if_shmem.c Log Message: if_shmem(4): Use membar_acquire/release for lock acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/rump/net/lib/libshmif/if_shmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/net/lib/libshmif
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:45:02 UTC 2022 Modified Files: src/sys/rump/net/lib/libshmif: if_shmem.c Log Message: if_shmem(4): Use membar_acquire/release for lock acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/rump/net/lib/libshmif/if_shmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/net/lib/libshmif/if_shmem.c diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.83 src/sys/rump/net/lib/libshmif/if_shmem.c:1.84 --- src/sys/rump/net/lib/libshmif/if_shmem.c:1.83 Wed Jul 14 03:16:06 2021 +++ src/sys/rump/net/lib/libshmif/if_shmem.c Sat Apr 9 23:45:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_shmem.c,v 1.83 2021/07/14 03:16:06 ozaki-r Exp $ */ +/* $NetBSD: if_shmem.c,v 1.84 2022/04/09 23:45:02 riastradh Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.83 2021/07/14 03:16:06 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.84 2022/04/09 23:45:02 riastradh Exp $"); #include #include @@ -144,7 +144,7 @@ shmif_lockbus(struct shmif_mem *busmem) } continue; } - membar_enter(); + membar_acquire(); } static void @@ -152,7 +152,7 @@ shmif_unlockbus(struct shmif_mem *busmem { unsigned int old __diagused; - membar_exit(); + membar_release(); old = atomic_swap_32(>shm_lock, LOCK_UNLOCKED); KASSERT(old == LOCK_LOCKED); }
CVS commit: src/sys/external/bsd/ena-com
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:54 UTC 2022 Modified Files: src/sys/external/bsd/ena-com: ena_plat.h Log Message: ena: Convert not-right membar_enter/exit to membar_acquire/release. Only used on non-x86 and non-aarch64, which probably means this branch is never used. (This should really use bus_space_barrier or bus_dmamap_sync.) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/ena-com/ena_plat.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/ena-com/ena_plat.h diff -u src/sys/external/bsd/ena-com/ena_plat.h:1.8 src/sys/external/bsd/ena-com/ena_plat.h:1.9 --- src/sys/external/bsd/ena-com/ena_plat.h:1.8 Sat Apr 9 12:49:36 2022 +++ src/sys/external/bsd/ena-com/ena_plat.h Sat Apr 9 23:44:54 2022 @@ -38,7 +38,7 @@ #if 0 __FBSDID("$FreeBSD: head/sys/contrib/ena-com/ena_plat.h 333453 2018-05-10 09:25:51Z mw $"); #endif -__KERNEL_RCSID(0, "$NetBSD: ena_plat.h,v 1.8 2022/04/09 12:49:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ena_plat.h,v 1.9 2022/04/09 23:44:54 riastradh Exp $"); #include #include @@ -392,8 +392,8 @@ void prefetch(void *x) #define wmb() __asm __volatile("dsb st" ::: "memory") #define mb() __asm __volatile("dsb sy" ::: "memory") #else -#define rmb() membar_enter() -#define wmb() membar_exit() +#define rmb() membar_acquire() +#define wmb() membar_release() #define mb() membar_sync() #endif
CVS commit: src/sys/external/bsd/ena-com
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:54 UTC 2022 Modified Files: src/sys/external/bsd/ena-com: ena_plat.h Log Message: ena: Convert not-right membar_enter/exit to membar_acquire/release. Only used on non-x86 and non-aarch64, which probably means this branch is never used. (This should really use bus_space_barrier or bus_dmamap_sync.) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/ena-com/ena_plat.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:45 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c linux_dma_fence.c linux_dma_fence_chain.c Log Message: drm: Convert membar_enter/exit stragglers to membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/linux/linux_dma_fence.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:45 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c linux_dma_fence.c linux_dma_fence_chain.c Log Message: drm: Convert membar_enter/exit stragglers to membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/linux/linux_dma_fence.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.14 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15 --- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.14 Thu Feb 17 01:38:38 2022 +++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $ */ +/* $NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $"); #include #include @@ -160,10 +160,10 @@ void dma_buf_put(struct dma_buf *dmabuf) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(>db_refcnt) != 0) return; - membar_enter(); + membar_acquire(); dma_resv_poll_fini(>db_resv_poll); mutex_destroy(>db_lock); Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.40 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 Sun Dec 19 12:39:40 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.40 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.40 2022/04/09 23:44:44 riastradh Exp $"); #include #include @@ -245,9 +245,9 @@ dma_fence_context_alloc(unsigned n) } S; uint64_t c; - while (__predict_false(atomic_cas_uint(, 0, 1) != 0)) + while (__predict_false(atomic_swap_uint(, 1))) SPINLOCK_BACKOFF_HOOK; - membar_enter(); + membar_acquire(); c = S.context; S.context += n; atomic_store_release(, 0); Index: src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.3 src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.3 Sun Dec 19 12:39:32 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence_chain.c,v 1.3 2021/12/19 12:39:32 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence_chain.c,v 1.4 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.3 2021/12/19 12:39:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.4 2022/04/09 23:44:44 riastradh Exp $"); #include @@ -262,7 +262,7 @@ dma_fence_chain_walk(struct dma_fence *f break; splice = NULL; } - membar_exit(); /* pairs with dma_fence_get_rcu_safe */ + membar_release(); /* pairs with dma_fence_get_rcu_safe */ if (atomic_cas_ptr(>dfc_prev, prev, splice) == prev) dma_fence_put(prev); /* transferred to splice */ else
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:25 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: ratelimit.h Log Message: linux/ratelimit: Convert to membar_acquire and atomic_store_release. Simplify while here: atomic_swap is enough, no need for atomic_cas. (Maybe drm'll run faster on sparcv8 this way...!) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/include/linux/ratelimit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/include/linux/ratelimit.h diff -u src/sys/external/bsd/drm2/include/linux/ratelimit.h:1.5 src/sys/external/bsd/drm2/include/linux/ratelimit.h:1.6 --- src/sys/external/bsd/drm2/include/linux/ratelimit.h:1.5 Sun Dec 19 11:36:57 2021 +++ src/sys/external/bsd/drm2/include/linux/ratelimit.h Sat Apr 9 23:44:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ratelimit.h,v 1.5 2021/12/19 11:36:57 riastradh Exp $ */ +/* $NetBSD: ratelimit.h,v 1.6 2022/04/09 23:44:25 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -86,14 +86,13 @@ __ratelimit(struct ratelimit_state *r) { int ok; - if (atomic_cas_uint(>rl_lock, 0, 1)) { + if (atomic_swap_uint(>rl_lock, 1)) { ok = false; goto out; } - membar_enter(); + membar_acquire(); ok = ppsratecheck(>rl_lasttime, >rl_curpps, r->rl_maxpps); - membar_exit(); - r->rl_lock = 0; + atomic_store_release(>rl_lock, 0); out: if (!ok) atomic_store_relaxed(>missed, 1);
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:25 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: ratelimit.h Log Message: linux/ratelimit: Convert to membar_acquire and atomic_store_release. Simplify while here: atomic_swap is enough, no need for atomic_cas. (Maybe drm'll run faster on sparcv8 this way...!) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/include/linux/ratelimit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:55 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: llist.h Log Message: linux/llist: Use membar_release and membar_datadep_consumer. No need for membar_acquire here! Loads are all data-dependent. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/include/linux/llist.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:55 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: llist.h Log Message: linux/llist: Use membar_release and membar_datadep_consumer. No need for membar_acquire here! Loads are all data-dependent. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/include/linux/llist.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/include/linux/llist.h diff -u src/sys/external/bsd/drm2/include/linux/llist.h:1.6 src/sys/external/bsd/drm2/include/linux/llist.h:1.7 --- src/sys/external/bsd/drm2/include/linux/llist.h:1.6 Sun Dec 19 11:52:08 2021 +++ src/sys/external/bsd/drm2/include/linux/llist.h Sat Apr 9 23:43:55 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: llist.h,v 1.6 2021/12/19 11:52:08 riastradh Exp $ */ +/* $NetBSD: llist.h,v 1.7 2022/04/09 23:43:55 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ llist_add(struct llist_node *node, struc do { first = head->first; node->next = first; - membar_exit(); + membar_release(); } while (atomic_cas_ptr(>first, first, node) != first); return first == NULL; @@ -96,7 +96,7 @@ llist_del_all(struct llist_head *head) struct llist_node *first; first = atomic_swap_ptr(>first, NULL); - membar_enter(); + membar_datadep_consumer(); return first; }
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:39 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: kref.h Log Message: linux/kref: Fix memory barriers and use membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/include/linux/kref.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/include/linux/kref.h diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.12 src/sys/external/bsd/drm2/include/linux/kref.h:1.13 --- src/sys/external/bsd/drm2/include/linux/kref.h:1.12 Sun Dec 19 11:45:01 2021 +++ src/sys/external/bsd/drm2/include/linux/kref.h Sat Apr 9 23:43:39 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kref.h,v 1.12 2021/12/19 11:45:01 riastradh Exp $ */ +/* $NetBSD: kref.h,v 1.13 2022/04/09 23:43:39 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -58,10 +58,6 @@ kref_get(struct kref *kref) atomic_inc_uint_nv(>kr_count); KASSERTMSG((count > 1), "getting released kref"); - -#ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); -#endif } static inline bool @@ -76,10 +72,6 @@ kref_get_unless_zero(struct kref *kref) } while (atomic_cas_uint(>kr_count, count, (count + 1)) != count); -#ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); -#endif - return true; } @@ -89,7 +81,7 @@ kref_sub(struct kref *kref, unsigned int unsigned int old, new; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif do { @@ -100,6 +92,9 @@ kref_sub(struct kref *kref, unsigned int } while (atomic_cas_uint(>kr_count, old, new) != old); if (new == 0) { +#ifndef __HAVE_ATOMIC_AS_MEMBAR + membar_acquire(); +#endif (*release)(kref); return 1; } @@ -114,7 +109,7 @@ kref_put_lock(struct kref *kref, void (* unsigned int old, new; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif do { @@ -123,6 +118,9 @@ kref_put_lock(struct kref *kref, void (* if (old == 1) { spin_lock(interlock); if (atomic_add_int_nv(>kr_count, -1) == 0) { +#ifndef __HAVE_ATOMIC_AS_MEMBAR +membar_acquire(); +#endif (*release)(kref); return 1; } @@ -149,7 +147,7 @@ kref_put_mutex(struct kref *kref, void ( unsigned int old, new; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif do { @@ -158,6 +156,9 @@ kref_put_mutex(struct kref *kref, void ( if (old == 1) { mutex_lock(interlock); if (atomic_add_int_nv(>kr_count, -1) == 0) { +#ifndef __HAVE_ATOMIC_AS_MEMBAR +membar_acquire(); +#endif (*release)(kref); return 1; }
CVS commit: src/sys/external/bsd/drm2/include/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:39 UTC 2022 Modified Files: src/sys/external/bsd/drm2/include/linux: kref.h Log Message: linux/kref: Fix memory barriers and use membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/include/linux/kref.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/common
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:31 UTC 2022 Modified Files: src/sys/external/bsd/common/include/asm: barrier.h src/sys/external/bsd/common/include/linux: compiler.h src/sys/external/bsd/common/linux: linux_tasklet.c linux_work.c Log Message: linux: Convert various API shims to use membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/common/include/asm/barrier.h cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/common/include/linux/compiler.h cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/common/linux/linux_tasklet.c cvs rdiff -u -r1.60 -r1.61 src/sys/external/bsd/common/linux/linux_work.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/common/include/asm/barrier.h diff -u src/sys/external/bsd/common/include/asm/barrier.h:1.12 src/sys/external/bsd/common/include/asm/barrier.h:1.13 --- src/sys/external/bsd/common/include/asm/barrier.h:1.12 Mon Dec 27 10:41:57 2021 +++ src/sys/external/bsd/common/include/asm/barrier.h Sat Apr 9 23:43:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: barrier.h,v 1.12 2021/12/27 10:41:57 riastradh Exp $ */ +/* $NetBSD: barrier.h,v 1.13 2022/04/09 23:43:30 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -68,8 +68,8 @@ #endif #if defined(MULTIPROCESSOR) && !defined(__HAVE_ATOMIC_AS_MEMBAR) -# define smp_mb__before_atomic() membar_exit() -# define smp_mb__after_atomic() membar_sync() /* XXX acquire */ +# define smp_mb__before_atomic() membar_release() +# define smp_mb__after_atomic() membar_acquire() #else # define smp_mb__before_atomic() __insn_barrier() # define smp_mb__after_atomic() __insn_barrier() Index: src/sys/external/bsd/common/include/linux/compiler.h diff -u src/sys/external/bsd/common/include/linux/compiler.h:1.7 src/sys/external/bsd/common/include/linux/compiler.h:1.8 --- src/sys/external/bsd/common/include/linux/compiler.h:1.7 Thu Feb 17 01:21:02 2022 +++ src/sys/external/bsd/common/include/linux/compiler.h Sat Apr 9 23:43:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: compiler.h,v 1.7 2022/02/17 01:21:02 riastradh Exp $ */ +/* $NetBSD: compiler.h,v 1.8 2022/04/09 23:43:31 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ #define smp_store_release(X, V) do { \ typeof(X) __smp_store_release_tmp = (V); \ - membar_exit(); \ + membar_release(); \ (X) = __write_once_tmp; \ } while (0) Index: src/sys/external/bsd/common/linux/linux_tasklet.c diff -u src/sys/external/bsd/common/linux/linux_tasklet.c:1.10 src/sys/external/bsd/common/linux/linux_tasklet.c:1.11 --- src/sys/external/bsd/common/linux/linux_tasklet.c:1.10 Mon Dec 27 14:57:30 2021 +++ src/sys/external/bsd/common/linux/linux_tasklet.c Sat Apr 9 23:43:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_tasklet.c,v 1.10 2021/12/27 14:57:30 riastradh Exp $ */ +/* $NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $ */ /*- * Copyright (c) 2018, 2020, 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.10 2021/12/27 14:57:30 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $"); #include #include @@ -245,7 +245,7 @@ tasklet_softintr(void *cookie) /* * Check whether it's currently disabled. * - * Pairs with membar_exit in __tasklet_enable. + * Pairs with membar_release in __tasklet_enable. */ if (atomic_load_acquire(>tl_disablecount)) { /* @@ -394,9 +394,9 @@ tasklet_disable_nosync(struct tasklet_st KASSERT(disablecount < UINT_MAX); KASSERT(disablecount != 0); - /* Pairs with membar_exit in __tasklet_enable. */ + /* Pairs with membar_release in __tasklet_enable. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif } @@ -514,9 +514,9 @@ tasklet_trylock(struct tasklet_struct *t } while (atomic_cas_uint(>tl_state, state, state | TASKLET_RUNNING) != state); - /* Pairs with membar_exit in tasklet_unlock. */ + /* Pairs with membar_release in tasklet_unlock. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif return true; @@ -536,11 +536,11 @@ tasklet_unlock(struct tasklet_struct *ta KASSERT(atomic_load_relaxed(>tl_state) & TASKLET_RUNNING); /* - * Pairs with membar_enter in tasklet_trylock and with + * Pairs with membar_acquire in tasklet_trylock and with * atomic_load_acquire in tasklet_unlock_wait. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_and_uint(>tl_state, ~TASKLET_RUNNING); } @@ -556,7 +556,7 @@ void tasklet_unlock_wait(const struct tasklet_struct *tasklet) { - /* Pairs with membar_exit in tasklet_unlock. */ + /* Pairs with membar_release in
CVS commit: src/sys/external/bsd/common
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:31 UTC 2022 Modified Files: src/sys/external/bsd/common/include/asm: barrier.h src/sys/external/bsd/common/include/linux: compiler.h src/sys/external/bsd/common/linux: linux_tasklet.c linux_work.c Log Message: linux: Convert various API shims to use membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/common/include/asm/barrier.h cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/common/include/linux/compiler.h cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/common/linux/linux_tasklet.c cvs rdiff -u -r1.60 -r1.61 src/sys/external/bsd/common/linux/linux_work.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/mips/include
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:20 UTC 2022 Modified Files: src/sys/arch/mips/include: lock.h Log Message: mips: Convert lock.h to membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/mips/include/lock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/include/lock.h diff -u src/sys/arch/mips/include/lock.h:1.22 src/sys/arch/mips/include/lock.h:1.23 --- src/sys/arch/mips/include/lock.h:1.22 Sat Feb 12 17:10:02 2022 +++ src/sys/arch/mips/include/lock.h Sat Apr 9 23:43:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lock.h,v 1.22 2022/02/12 17:10:02 riastradh Exp $ */ +/* $NetBSD: lock.h,v 1.23 2022/04/09 23:43:20 riastradh Exp $ */ /*- * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc. @@ -114,7 +114,7 @@ __cpu_simple_lock_try(__cpu_simple_lock_ * Successful _atomic_cas_uint functions as a load-acquire -- * on MP systems, it issues sync after the LL/SC CAS succeeds; * on non-MP systems every load is a load-acquire so it's moot. - * This pairs with the membar_exit and store sequence in + * This pairs with the membar_release and store sequence in * __cpu_simple_unlock that functions as a store-release * operation. * @@ -153,14 +153,14 @@ __cpu_simple_unlock(__cpu_simple_lock_t { /* - * The membar_exit and then store functions as a store-release - * operation that pairs with the load-acquire operation in - * successful __cpu_simple_lock_try. + * The membar_release and then store functions as a + * store-release operation that pairs with the load-acquire + * operation in successful __cpu_simple_lock_try. * * Can't use atomic_store_release here because that's not * available in userland at the moment. */ - membar_exit(); + membar_release(); *lp = __SIMPLELOCK_UNLOCKED; #ifdef _MIPS_ARCH_OCTEONP
CVS commit: src/sys/arch/mips/include
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:20 UTC 2022 Modified Files: src/sys/arch/mips/include: lock.h Log Message: mips: Convert lock.h to membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/mips/include/lock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/hppa/hppa
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:12 UTC 2022 Modified Files: src/sys/arch/hppa/hppa: ipifuncs.c Log Message: hppa: Convert ipiuncs.c to membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/hppa/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hppa/hppa/ipifuncs.c diff -u src/sys/arch/hppa/hppa/ipifuncs.c:1.6 src/sys/arch/hppa/hppa/ipifuncs.c:1.7 --- src/sys/arch/hppa/hppa/ipifuncs.c:1.6 Sat Feb 12 17:09:07 2022 +++ src/sys/arch/hppa/hppa/ipifuncs.c Sat Apr 9 23:43:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ipifuncs.c,v 1.6 2022/02/12 17:09:07 riastradh Exp $ */ +/* $NetBSD: ipifuncs.c,v 1.7 2022/04/09 23:43:12 riastradh Exp $ */ /* $OpenBSD: ipi.c,v 1.4 2011/01/14 13:20:06 jsing Exp $ */ /* @@ -83,7 +83,7 @@ hppa_ipi_intr(void *arg) /* Handle an IPI. */ ipi_pending = atomic_swap_ulong(>ci_ipi, 0); - membar_enter(); /* matches membar_exit in xc_send_ipi, cpu_ipi */ + membar_acquire(); /* matches membar_release in xc_send_ipi, cpu_ipi */ KASSERT(ipi_pending); @@ -169,7 +169,7 @@ xc_send_ipi(struct cpu_info *ci) KASSERT(kpreempt_disabled()); KASSERT(curcpu() != ci); - membar_exit(); /* matches membar_enter in hppa_ipi_intr */ + membar_release(); /* matches membar_acquire in hppa_ipi_intr */ if (ci) { /* Unicast: remote CPU. */ hppa_ipi_send(ci, HPPA_IPI_XCALL); @@ -185,7 +185,7 @@ cpu_ipi(struct cpu_info *ci) KASSERT(kpreempt_disabled()); KASSERT(curcpu() != ci); - membar_exit(); /* matches membar_enter in hppa_ipi_intr */ + membar_release(); /* matches membar_acquire in hppa_ipi_intr */ if (ci) { /* Unicast: remote CPU. */ hppa_ipi_send(ci, HPPA_IPI_GENERIC);
CVS commit: src/sys/arch/hppa/hppa
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:43:12 UTC 2022 Modified Files: src/sys/arch/hppa/hppa: ipifuncs.c Log Message: hppa: Convert ipiuncs.c to membar_release/acquire. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/hppa/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:42:56 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: ipifuncs.c Log Message: alpha: Convert ipifuncs.c to membar_release/acquire. No semantic change is possible because all of these membars are just mb on alpha -- change just makes the intent clearer. (Only membar_producer is weaker, wmb.) To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/alpha/alpha/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/ipifuncs.c diff -u src/sys/arch/alpha/alpha/ipifuncs.c:1.54 src/sys/arch/alpha/alpha/ipifuncs.c:1.55 --- src/sys/arch/alpha/alpha/ipifuncs.c:1.54 Sat Oct 10 03:05:04 2020 +++ src/sys/arch/alpha/alpha/ipifuncs.c Sat Apr 9 23:42:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ipifuncs.c,v 1.54 2020/10/10 03:05:04 thorpej Exp $ */ +/* $NetBSD: ipifuncs.c,v 1.55 2022/04/09 23:42:56 riastradh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.54 2020/10/10 03:05:04 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.55 2022/04/09 23:42:56 riastradh Exp $"); /* * Interprocessor interrupt handlers. @@ -127,10 +127,12 @@ alpha_ipi_process(struct cpu_info *ci, s while ((pending_ipis = atomic_swap_ulong(>ci_ipis, 0)) != 0) { /* - * Ensure the atomic swap is globally visible before - * we do any of the work. + * Ensure everything prior to setting ci_ipis in + * alpha_send_ipi happens-before everything after + * reading ci_ipis here so we're not working on stale + * inputs. */ - membar_enter(); + membar_acquire(); sc->sc_evcnt_ipi.ev_count++; @@ -159,7 +161,7 @@ alpha_send_ipi(u_long const cpu_id, u_lo * alpha_send_ipi() have completed before informing * the CPU of the work we are asking it to do. */ - membar_exit(); + membar_release(); atomic_or_ulong(_info[cpu_id]->ci_ipis, ipimask); /*
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:42:56 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: ipifuncs.c Log Message: alpha: Convert ipifuncs.c to membar_release/acquire. No semantic change is possible because all of these membars are just mb on alpha -- change just makes the intent clearer. (Only membar_producer is weaker, wmb.) To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/alpha/alpha/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 23:41:22 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c externs1.h func.c lex.c lint1.h tree.c Log Message: lint: distinguish between storage class and declaration kind These types overlap but are not the same. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.392 -r1.393 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.275 -r1.276 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.153 -r1.154 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.149 -r1.150 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.423 -r1.424 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 23:41:22 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c externs1.h func.c lex.c lint1.h tree.c Log Message: lint: distinguish between storage class and declaration kind These types overlap but are not the same. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.392 -r1.393 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.275 -r1.276 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.153 -r1.154 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.149 -r1.150 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.423 -r1.424 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.392 src/usr.bin/xlint/lint1/cgram.y:1.393 --- src/usr.bin/xlint/lint1/cgram.y:1.392 Sat Apr 9 21:19:52 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 23:41:22 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.393 2022/04/09 23:41:22 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.393 2022/04/09 23:41:22 rillig Exp $"); #endif #include @@ -920,7 +920,7 @@ struct_or_union_specifier: /* C99 6.7.2. struct_or_union: /* C99 6.7.2.1 */ T_STRUCT_OR_UNION { symtyp = FTAG; - begin_declaration_level($1 == STRUCT ? MOS : MOU); + begin_declaration_level($1 == STRUCT ? DK_MOS : DK_MOU); dcs->d_offset_in_bits = 0; dcs->d_sou_align_in_bits = CHAR_SIZE; $$ = $1; @@ -1069,7 +1069,7 @@ enum_specifier: /* C99 6.7.2.2 */ enum:/* helper for C99 6.7.2.2 */ T_ENUM { symtyp = FTAG; - begin_declaration_level(ENUM_CONST); + begin_declaration_level(DK_ENUM_CONST); } ; @@ -1329,7 +1329,7 @@ param_list: id_list_lparen: T_LPAREN { block_level++; - begin_declaration_level(PROTO_ARG); + begin_declaration_level(DK_PROTO_ARG); } ; @@ -1380,7 +1380,7 @@ identifier_list: /* C99 6.7.5 */ /* XXX: C99 requires an additional specifier-qualifier-list. */ type_name: /* C99 6.7.6 */ { - begin_declaration_level(ABSTRACT); + begin_declaration_level(DK_ABSTRACT); } abstract_declaration { end_declaration_level(); $$ = $2->s_type; @@ -1460,7 +1460,7 @@ abstract_decl_param_list: /* specific to abstract_decl_lparen: /* specific to lint */ T_LPAREN { block_level++; - begin_declaration_level(PROTO_ARG); + begin_declaration_level(DK_PROTO_ARG); } ; @@ -1674,7 +1674,7 @@ compound_statement_lbrace: T_LBRACE { block_level++; mem_block_level++; - begin_declaration_level(AUTO); + begin_declaration_level(DK_AUTO); } ; @@ -1824,7 +1824,7 @@ do_while_expr: /* see C99 6.8.5 */ for_start: /* see C99 6.8.5 */ T_FOR T_LPAREN { - begin_declaration_level(AUTO); + begin_declaration_level(DK_AUTO); block_level++; } ; @@ -1960,7 +1960,7 @@ function_definition: /* C99 6.9.1 */ } funcdef($1); block_level++; - begin_declaration_level(OLD_STYLE_ARG); + begin_declaration_level(DK_OLD_STYLE_ARG); if (lwarn == LWARN_NONE) $1->s_used = true; } arg_declaration_list_opt { Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.16 src/usr.bin/xlint/lint1/debug.c:1.17 --- src/usr.bin/xlint/lint1/debug.c:1.16 Sat Apr 9 21:19:52 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 23:41:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.17 2022/04/09 23:41:22 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.17 2022/04/09 23:41:22 rillig Exp $"); #endif #include @@ -177,6 +177,23 @@ def_name(def_t def) } const char * +declaration_kind_name(declaration_kind dk) +{ + static const char *const name[] = { + "extern", + "member-of-struct", + "member-of-union", + "enum-constant", + "old-style-function-argument", + "prototype-argument", + "auto", + "abstract", + }; + + return name[dk]; +} + +const char * scl_name(scl_t scl) { static const char *const name[] = { @@ -191,8 +208,6 @@ scl_name(scl_t scl) "enum", "member-of-struct", "member-of-union", - "bool-constant", - "enum-constant", "abstract", "old-style-function-argument", "prototype-argument", @@ -308,7
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:39:18 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: cpu.c Log Message: alpha: Convert cpu_iccb_send from membar_exit to membar_release. XXX Maybe this should really use alpha_mb, since it's not writing to normal MI-type memory so technically the membr_* semantics doesn't apply? To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/arch/alpha/alpha/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/cpu.c diff -u src/sys/arch/alpha/alpha/cpu.c:1.105 src/sys/arch/alpha/alpha/cpu.c:1.106 --- src/sys/arch/alpha/alpha/cpu.c:1.105 Sun Feb 27 14:17:10 2022 +++ src/sys/arch/alpha/alpha/cpu.c Sat Apr 9 23:39:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.105 2022/02/27 14:17:10 riastradh Exp $ */ +/* $NetBSD: cpu.c,v 1.106 2022/04/09 23:39:18 riastradh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.105 2022/02/27 14:17:10 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.106 2022/04/09 23:39:18 riastradh Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -887,7 +887,7 @@ cpu_iccb_send(long cpu_id, const char *m */ strcpy(pcsp->pcs_iccb.iccb_rxbuf, msg); pcsp->pcs_iccb.iccb_rxlen = strlen(msg); - membar_exit(); + membar_release(); atomic_or_ulong(>rpb_rxrdy, cpumask); /* Wait for the message to be received. */
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:39:18 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: cpu.c Log Message: alpha: Convert cpu_iccb_send from membar_exit to membar_release. XXX Maybe this should really use alpha_mb, since it's not writing to normal MI-type memory so technically the membr_* semantics doesn't apply? To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/arch/alpha/alpha/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:39:07 UTC 2022 Modified Files: src/libexec/ld.elf_so: rtld.c Log Message: rtld: Convert membar_exit/enter to membar_release/acquire. These are basic CAS-based locking primitives needing release and acquire semantics, nothing fancy here -- except the membar_sync parts which are questionable but not relevant to the present audit. To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/libexec/ld.elf_so/rtld.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/rtld.c diff -u src/libexec/ld.elf_so/rtld.c:1.210 src/libexec/ld.elf_so/rtld.c:1.211 --- src/libexec/ld.elf_so/rtld.c:1.210 Sat Dec 4 14:39:08 2021 +++ src/libexec/ld.elf_so/rtld.c Sat Apr 9 23:39:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: rtld.c,v 1.210 2021/12/04 14:39:08 skrll Exp $ */ +/* $NetBSD: rtld.c,v 1.211 2022/04/09 23:39:07 riastradh Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -40,7 +40,7 @@ #include #ifndef lint -__RCSID("$NetBSD: rtld.c,v 1.210 2021/12/04 14:39:08 skrll Exp $"); +__RCSID("$NetBSD: rtld.c,v 1.211 2022/04/09 23:39:07 riastradh Exp $"); #endif /* not lint */ #include @@ -1682,7 +1682,7 @@ _rtld_shared_enter(void) /* Yes, so increment use counter */ if (atomic_cas_uint(&_rtld_mutex, cur, cur + 1) != cur) continue; - membar_enter(); + membar_acquire(); return; } /* @@ -1728,7 +1728,7 @@ _rtld_shared_exit(void) * Wakeup LWPs waiting for an exclusive lock if this is the last * LWP on the shared lock. */ - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&_rtld_mutex)) return; membar_sync(); @@ -1750,7 +1750,7 @@ _rtld_exclusive_enter(sigset_t *mask) for (;;) { if (atomic_cas_uint(&_rtld_mutex, 0, locked_value) == 0) { - membar_enter(); + membar_acquire(); break; } waiter = atomic_swap_uint(&_rtld_waiter_exclusive, self); @@ -1774,7 +1774,7 @@ _rtld_exclusive_exit(sigset_t *mask) { lwpid_t waiter; - membar_exit(); + membar_release(); _rtld_mutex = 0; membar_sync(); if ((waiter = _rtld_waiter_exclusive) != 0)
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:39:07 UTC 2022 Modified Files: src/libexec/ld.elf_so: rtld.c Log Message: rtld: Convert membar_exit/enter to membar_release/acquire. These are basic CAS-based locking primitives needing release and acquire semantics, nothing fancy here -- except the membar_sync parts which are questionable but not relevant to the present audit. To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/libexec/ld.elf_so/rtld.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:38:57 UTC 2022 Modified Files: src/common/lib/libc/atomic: atomic_load.c atomic_store.c Log Message: libc/atomic: Fix membars in __atomic_load/store_* stubs. - membar_enter/exit ordering was backwards. - membar_enter doesn't make any sense for load anyway. - Switch to membar_release for store and membar_acquire for load. The only sensible orderings for a simple load or store are acquire or release, respectively, or sequential consistency. This never provided correct sequential consistency before -- we should really make it conditional on memmodel but I don't know offhand what the values of memmodel might be and this is at least better than before. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/atomic/atomic_load.c \ src/common/lib/libc/atomic/atomic_store.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/atomic/atomic_load.c diff -u src/common/lib/libc/atomic/atomic_load.c:1.3 src/common/lib/libc/atomic/atomic_load.c:1.4 --- src/common/lib/libc/atomic/atomic_load.c:1.3 Mon Sep 7 00:52:19 2020 +++ src/common/lib/libc/atomic/atomic_load.c Sat Apr 9 23:38:57 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */ +/* $NetBSD: atomic_load.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $"); +__RCSID("$NetBSD: atomic_load.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $"); #include "atomic_op_namespace.h" @@ -40,9 +40,8 @@ uint ## b ## _t \ __atomic_load_ ## n(const volatile void *ptr, int memmodel) \ { \ uint## b ##_t val; \ - membar_enter(); \ val = *(const volatile uint ## b ## _t *)ptr; \ - membar_exit(); \ + membar_acquire(); \ return val; \ } Index: src/common/lib/libc/atomic/atomic_store.c diff -u src/common/lib/libc/atomic/atomic_store.c:1.3 src/common/lib/libc/atomic/atomic_store.c:1.4 --- src/common/lib/libc/atomic/atomic_store.c:1.3 Mon Sep 7 00:52:19 2020 +++ src/common/lib/libc/atomic/atomic_store.c Sat Apr 9 23:38:57 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */ +/* $NetBSD: atomic_store.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $"); +__RCSID("$NetBSD: atomic_store.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $"); #include "atomic_op_namespace.h" @@ -40,9 +40,8 @@ void \ __atomic_store_ ## n(volatile void *ptr, uint ## b ## _t val, \ int memmodel) \ { \ - membar_enter(); \ + membar_release(); \ *(volatile uint ## b ## _t *)ptr = val; \ - membar_exit(); \ } atomic_store_n(1, 8)
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:38:57 UTC 2022 Modified Files: src/common/lib/libc/atomic: atomic_load.c atomic_store.c Log Message: libc/atomic: Fix membars in __atomic_load/store_* stubs. - membar_enter/exit ordering was backwards. - membar_enter doesn't make any sense for load anyway. - Switch to membar_release for store and membar_acquire for load. The only sensible orderings for a simple load or store are acquire or release, respectively, or sequential consistency. This never provided correct sequential consistency before -- we should really make it conditional on memmodel but I don't know offhand what the values of memmodel might be and this is at least better than before. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/atomic/atomic_load.c \ src/common/lib/libc/atomic/atomic_store.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:38:33 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: pmap.c src/sys/arch/alpha/alpha: pmap.c src/sys/arch/arm/arm32: pmap.c src/sys/arch/hppa/hppa: pmap.c src/sys/arch/ia64/ia64: pmap.c src/sys/arch/powerpc/oea: pmap.c src/sys/arch/sparc/sparc: pmap.c src/sys/arch/sparc64/sparc64: pmap.c src/sys/dev/hyperv: vmbus.c src/sys/dev/marvell: mvxpsec.c src/sys/dev/scsipi: atapiconf.c scsiconf.c scsipi_base.c src/sys/external/bsd/drm2/linux: linux_stop_machine.c src/sys/kern: kern_auth.c kern_exec.c kern_mutex_obj.c kern_resource.c kern_rwlock_obj.c kern_sig.c subr_kcpuset.c sys_futex.c uipc_mbuf.c vfs_cwd.c vfs_mount.c vfs_vnode.c vfs_wapbl.c src/sys/net: if.c src/sys/net/npf: npf_nat.c npf_rproc.c npf_tableset.c src/sys/uvm: uvm_aobj.c uvm_map.c src/sys/uvm/pmap: pmap.c Log Message: sys: Use membar_release/acquire around reference drop. This just goes through my recent reference count membar audit and changes membar_exit to membar_release and membar_enter to membar_acquire -- this should make everything cheaper on most CPUs without hurting correctness, because membar_acquire is generally cheaper than membar_enter. To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/arch/aarch64/aarch64/pmap.c cvs rdiff -u -r1.306 -r1.307 src/sys/arch/alpha/alpha/pmap.c cvs rdiff -u -r1.435 -r1.436 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.115 -r1.116 src/sys/arch/hppa/hppa/pmap.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/ia64/ia64/pmap.c cvs rdiff -u -r1.112 -r1.113 src/sys/arch/powerpc/oea/pmap.c cvs rdiff -u -r1.376 -r1.377 src/sys/arch/sparc/sparc/pmap.c cvs rdiff -u -r1.315 -r1.316 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/marvell/mvxpsec.c cvs rdiff -u -r1.94 -r1.95 src/sys/dev/scsipi/atapiconf.c cvs rdiff -u -r1.300 -r1.301 src/sys/dev/scsipi/scsiconf.c cvs rdiff -u -r1.188 -r1.189 src/sys/dev/scsipi/scsipi_base.c cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_stop_machine.c cvs rdiff -u -r1.80 -r1.81 src/sys/kern/kern_auth.c cvs rdiff -u -r1.516 -r1.517 src/sys/kern/kern_exec.c cvs rdiff -u -r1.8 -r1.9 src/sys/kern/kern_mutex_obj.c cvs rdiff -u -r1.188 -r1.189 src/sys/kern/kern_resource.c cvs rdiff -u -r1.6 -r1.7 src/sys/kern/kern_rwlock_obj.c cvs rdiff -u -r1.403 -r1.404 src/sys/kern/kern_sig.c cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_kcpuset.c cvs rdiff -u -r1.16 -r1.17 src/sys/kern/sys_futex.c cvs rdiff -u -r1.245 -r1.246 src/sys/kern/uipc_mbuf.c cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_cwd.c cvs rdiff -u -r1.92 -r1.93 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.141 -r1.142 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.111 -r1.112 src/sys/kern/vfs_wapbl.c cvs rdiff -u -r1.502 -r1.503 src/sys/net/if.c cvs rdiff -u -r1.51 -r1.52 src/sys/net/npf/npf_nat.c cvs rdiff -u -r1.21 -r1.22 src/sys/net/npf/npf_rproc.c cvs rdiff -u -r1.37 -r1.38 src/sys/net/npf/npf_tableset.c cvs rdiff -u -r1.154 -r1.155 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.392 -r1.393 src/sys/uvm/uvm_map.c cvs rdiff -u -r1.63 -r1.64 src/sys/uvm/pmap/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/pmap.c diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.132 src/sys/arch/aarch64/aarch64/pmap.c:1.133 --- src/sys/arch/aarch64/aarch64/pmap.c:1.132 Sat Apr 2 11:16:06 2022 +++ src/sys/arch/aarch64/aarch64/pmap.c Sat Apr 9 23:38:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.132 2022/04/02 11:16:06 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.133 2022/04/09 23:38:31 riastradh Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.132 2022/04/02 11:16:06 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.133 2022/04/09 23:38:31 riastradh Exp $"); #include "opt_arm_debug.h" #include "opt_cpuoptions.h" @@ -1651,11 +1651,11 @@ pmap_destroy(struct pmap *pm) if (pm == pmap_kernel()) panic("cannot destroy kernel pmap"); - membar_exit(); + membar_release(); refcnt = atomic_dec_uint_nv(>pm_refcnt); if (refcnt > 0) return; - membar_enter(); + membar_acquire(); KASSERT(LIST_EMPTY(>pm_pvlist)); pmap_tlb_asid_release_all(pm); Index: src/sys/arch/alpha/alpha/pmap.c diff -u src/sys/arch/alpha/alpha/pmap.c:1.306 src/sys/arch/alpha/alpha/pmap.c:1.307 --- src/sys/arch/alpha/alpha/pmap.c:1.306 Sat Apr 9 23:36:22 2022 +++ src/sys/arch/alpha/alpha/pmap.c Sat Apr 9 23:38:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.306 2022/04/09 23:36:22 riastradh Exp $ */ +/* $NetBSD: pmap.c,v 1.307 2022/04/09 23:38:31 riastradh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020 @@ -135,7
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:38:33 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: pmap.c src/sys/arch/alpha/alpha: pmap.c src/sys/arch/arm/arm32: pmap.c src/sys/arch/hppa/hppa: pmap.c src/sys/arch/ia64/ia64: pmap.c src/sys/arch/powerpc/oea: pmap.c src/sys/arch/sparc/sparc: pmap.c src/sys/arch/sparc64/sparc64: pmap.c src/sys/dev/hyperv: vmbus.c src/sys/dev/marvell: mvxpsec.c src/sys/dev/scsipi: atapiconf.c scsiconf.c scsipi_base.c src/sys/external/bsd/drm2/linux: linux_stop_machine.c src/sys/kern: kern_auth.c kern_exec.c kern_mutex_obj.c kern_resource.c kern_rwlock_obj.c kern_sig.c subr_kcpuset.c sys_futex.c uipc_mbuf.c vfs_cwd.c vfs_mount.c vfs_vnode.c vfs_wapbl.c src/sys/net: if.c src/sys/net/npf: npf_nat.c npf_rproc.c npf_tableset.c src/sys/uvm: uvm_aobj.c uvm_map.c src/sys/uvm/pmap: pmap.c Log Message: sys: Use membar_release/acquire around reference drop. This just goes through my recent reference count membar audit and changes membar_exit to membar_release and membar_enter to membar_acquire -- this should make everything cheaper on most CPUs without hurting correctness, because membar_acquire is generally cheaper than membar_enter. To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/arch/aarch64/aarch64/pmap.c cvs rdiff -u -r1.306 -r1.307 src/sys/arch/alpha/alpha/pmap.c cvs rdiff -u -r1.435 -r1.436 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.115 -r1.116 src/sys/arch/hppa/hppa/pmap.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/ia64/ia64/pmap.c cvs rdiff -u -r1.112 -r1.113 src/sys/arch/powerpc/oea/pmap.c cvs rdiff -u -r1.376 -r1.377 src/sys/arch/sparc/sparc/pmap.c cvs rdiff -u -r1.315 -r1.316 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/marvell/mvxpsec.c cvs rdiff -u -r1.94 -r1.95 src/sys/dev/scsipi/atapiconf.c cvs rdiff -u -r1.300 -r1.301 src/sys/dev/scsipi/scsiconf.c cvs rdiff -u -r1.188 -r1.189 src/sys/dev/scsipi/scsipi_base.c cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_stop_machine.c cvs rdiff -u -r1.80 -r1.81 src/sys/kern/kern_auth.c cvs rdiff -u -r1.516 -r1.517 src/sys/kern/kern_exec.c cvs rdiff -u -r1.8 -r1.9 src/sys/kern/kern_mutex_obj.c cvs rdiff -u -r1.188 -r1.189 src/sys/kern/kern_resource.c cvs rdiff -u -r1.6 -r1.7 src/sys/kern/kern_rwlock_obj.c cvs rdiff -u -r1.403 -r1.404 src/sys/kern/kern_sig.c cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_kcpuset.c cvs rdiff -u -r1.16 -r1.17 src/sys/kern/sys_futex.c cvs rdiff -u -r1.245 -r1.246 src/sys/kern/uipc_mbuf.c cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_cwd.c cvs rdiff -u -r1.92 -r1.93 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.141 -r1.142 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.111 -r1.112 src/sys/kern/vfs_wapbl.c cvs rdiff -u -r1.502 -r1.503 src/sys/net/if.c cvs rdiff -u -r1.51 -r1.52 src/sys/net/npf/npf_nat.c cvs rdiff -u -r1.21 -r1.22 src/sys/net/npf/npf_rproc.c cvs rdiff -u -r1.37 -r1.38 src/sys/net/npf/npf_tableset.c cvs rdiff -u -r1.154 -r1.155 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.392 -r1.393 src/sys/uvm/uvm_map.c cvs rdiff -u -r1.63 -r1.64 src/sys/uvm/pmap/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:36:22 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: pmap.c Log Message: alpha: Omit needless membar in pmap_reference. If the pmap is published enough for us to obtain a reference to it then there's no membar needed. If it's not then something else is wrong and we can't use pmap_reference here anyway. Membars are needed only on the destruction side to make sure all use, by any thread, happens-before all freeing in the last user thread. To generate a diff of this commit: cvs rdiff -u -r1.305 -r1.306 src/sys/arch/alpha/alpha/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/pmap.c diff -u src/sys/arch/alpha/alpha/pmap.c:1.305 src/sys/arch/alpha/alpha/pmap.c:1.306 --- src/sys/arch/alpha/alpha/pmap.c:1.305 Sat Mar 12 15:32:31 2022 +++ src/sys/arch/alpha/alpha/pmap.c Sat Apr 9 23:36:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.305 2022/03/12 15:32:31 riastradh Exp $ */ +/* $NetBSD: pmap.c,v 1.306 2022/04/09 23:36:22 riastradh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020 @@ -135,7 +135,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.305 2022/03/12 15:32:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.306 2022/04/09 23:36:22 riastradh Exp $"); #include #include @@ -1706,7 +1706,6 @@ pmap_reference(pmap_t pmap) newcount = atomic_inc_uint_nv(>pm_count); KASSERT(newcount != 0); - PMAP_MP(membar_enter()); } /*
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:36:22 UTC 2022 Modified Files: src/sys/arch/alpha/alpha: pmap.c Log Message: alpha: Omit needless membar in pmap_reference. If the pmap is published enough for us to obtain a reference to it then there's no membar needed. If it's not then something else is wrong and we can't use pmap_reference here anyway. Membars are needed only on the destruction side to make sure all use, by any thread, happens-before all freeing in the last user thread. To generate a diff of this commit: cvs rdiff -u -r1.305 -r1.306 src/sys/arch/alpha/alpha/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/audio
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:35:58 UTC 2022 Modified Files: src/sys/dev/audio: audio.c Log Message: audio(4): Use membar_acquire, not membar_enter. Cheaper and adequate to make an atomic_swap into a load-acquire. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/dev/audio/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio/audio.c diff -u src/sys/dev/audio/audio.c:1.122 src/sys/dev/audio/audio.c:1.123 --- src/sys/dev/audio/audio.c:1.122 Thu Mar 31 19:30:15 2022 +++ src/sys/dev/audio/audio.c Sat Apr 9 23:35:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.122 2022/03/31 19:30:15 pgoyette Exp $ */ +/* $NetBSD: audio.c,v 1.123 2022/04/09 23:35:58 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -181,7 +181,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.122 2022/03/31 19:30:15 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.123 2022/04/09 23:35:58 riastradh Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -316,7 +316,7 @@ audio_mlog_flush(void) /* Nothing to do if already in use ? */ if (atomic_swap_32(_inuse, 1) == 1) return; - membar_enter(); + membar_acquire(); int rpage = mlog_wpage; mlog_wpage ^= 1; @@ -353,7 +353,7 @@ audio_mlog_printf(const char *fmt, ...) mlog_drop++; return; } - membar_enter(); + membar_acquire(); va_start(ap, fmt); len = vsnprintf( @@ -1684,7 +1684,7 @@ audio_track_lock_tryenter(audio_track_t if (atomic_swap_uint(>lock, 1) != 0) return false; - membar_enter(); + membar_acquire(); return true; }
CVS commit: src/sys/dev/audio
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:35:58 UTC 2022 Modified Files: src/sys/dev/audio: audio.c Log Message: audio(4): Use membar_acquire, not membar_enter. Cheaper and adequate to make an atomic_swap into a load-acquire. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/dev/audio/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/mips/rmi
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:50 UTC 2022 Modified Files: src/sys/arch/mips/rmi: rmixl_intr.c Log Message: mips/rmixl: Insert appropriate membars around IPIs. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/rmi/rmixl_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/rmi/rmixl_intr.c diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.12 src/sys/arch/mips/rmi/rmixl_intr.c:1.13 --- src/sys/arch/mips/rmi/rmixl_intr.c:1.12 Fri Aug 26 15:45:48 2016 +++ src/sys/arch/mips/rmi/rmixl_intr.c Sat Apr 9 23:34:50 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: rmixl_intr.c,v 1.12 2016/08/26 15:45:48 skrll Exp $ */ +/* $NetBSD: rmixl_intr.c,v 1.13 2022/04/09 23:34:50 riastradh Exp $ */ /*- * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rmixl_intr.c,v 1.12 2016/08/26 15:45:48 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rmixl_intr.c,v 1.13 2022/04/09 23:34:50 riastradh Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -967,6 +967,7 @@ rmixl_send_ipi(struct cpu_info *ci, int | (RMIXL_INTRVEC_IPI + tag); mutex_enter(_ipi_lock); + membar_release(); atomic_or_64(>ci_request_ipis, req); RMIXL_PICREG_WRITE(RMIXL_PIC_IPIBASE, r); mutex_exit(_ipi_lock); @@ -984,8 +985,9 @@ rmixl_ipi_intr(void *arg) KASSERT((uintptr_t)arg < NIPIS); /* if the request is clear, it was previously processed */ - if ((ci->ci_request_ipis & ipi_mask) == 0) + if ((atomic_load_relaxed(>ci_request_ipis) & ipi_mask) == 0) return 0; + membar_acquire(); atomic_or_64(>ci_active_ipis, ipi_mask); atomic_and_64(>ci_request_ipis, ~ipi_mask);
CVS commit: src/sys/arch/mips/rmi
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:50 UTC 2022 Modified Files: src/sys/arch/mips/rmi: rmixl_intr.c Log Message: mips/rmixl: Insert appropriate membars around IPIs. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/rmi/rmixl_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/mips/cavium
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:40 UTC 2022 Modified Files: src/sys/arch/mips/cavium: octeon_intr.c Log Message: mips/cavium: Insert appropriate membars around IPIs. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/cavium/octeon_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/cavium/octeon_intr.c diff -u src/sys/arch/mips/cavium/octeon_intr.c:1.26 src/sys/arch/mips/cavium/octeon_intr.c:1.27 --- src/sys/arch/mips/cavium/octeon_intr.c:1.26 Sat Mar 26 19:38:00 2022 +++ src/sys/arch/mips/cavium/octeon_intr.c Sat Apr 9 23:34:40 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_intr.c,v 1.26 2022/03/26 19:38:00 riastradh Exp $ */ +/* $NetBSD: octeon_intr.c,v 1.27 2022/04/09 23:34:40 riastradh Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. * All rights reserved. @@ -44,7 +44,7 @@ #define __INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.26 2022/03/26 19:38:00 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.27 2022/04/09 23:34:40 riastradh Exp $"); #include #include @@ -548,6 +548,7 @@ octeon_ipi_intr(void *arg) ipi_mask &= mips3_ld(cpu->cpu_mbox_set); if (ipi_mask == 0) return 0; + membar_acquire(); mips3_sd(cpu->cpu_mbox_clr, ipi_mask); @@ -566,8 +567,9 @@ octeon_ipi_intr(void *arg) #endif /* if the request is clear, it was previously processed */ - if ((ci->ci_request_ipis & ipi_mask) == 0) + if ((atomic_load_relaxed(>ci_request_ipis) & ipi_mask) == 0) return 0; + membar_acquire(); atomic_or_64(>ci_active_ipis, ipi_mask); atomic_and_64(>ci_request_ipis, ~ipi_mask); @@ -600,8 +602,10 @@ octeon_send_ipi(struct cpu_info *ci, int const u_int ipi_shift = ipi_prio[req] == IPL_SCHED ? 16 : 0; const uint32_t ipi_mask = __BIT(req + ipi_shift); + membar_release(); atomic_or_64(>ci_request_ipis, ipi_mask); + membar_release(); mips3_sd(cpu->cpu_mbox_set, ipi_mask); return 0;
CVS commit: src/sys/arch/mips/cavium
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:40 UTC 2022 Modified Files: src/sys/arch/mips/cavium: octeon_intr.c Log Message: mips/cavium: Insert appropriate membars around IPIs. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/cavium/octeon_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:30 UTC 2022 Modified Files: src/sys/sys: atomic.h Log Message: atomic_loadstore(9): Use membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/sys/atomic.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/atomic.h diff -u src/sys/sys/atomic.h:1.23 src/sys/sys/atomic.h:1.24 --- src/sys/sys/atomic.h:1.23 Sat Apr 9 23:32:53 2022 +++ src/sys/sys/atomic.h Sat Apr 9 23:34:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.h,v 1.23 2022/04/09 23:32:53 riastradh Exp $ */ +/* $NetBSD: atomic.h,v 1.24 2022/04/09 23:34:30 riastradh Exp $ */ /*- * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. @@ -454,18 +454,12 @@ void kcsan_atomic_store(volatile void *, __END_ATOMIC_LOAD(__al_val); \ }) -/* - * We want {loads}-before-{loads,stores}. It is tempting to use - * membar_enter, but that provides {stores}-before-{loads,stores}, - * which may not help. So we must use membar_sync, which does the - * slightly stronger {loads,stores}-before-{loads,stores}. - */ #define atomic_load_acquire(p) \ ({ \ const volatile __typeof__(*(p)) *__al_ptr = (p); \ __ATOMIC_PTR_CHECK(__al_ptr); \ __BEGIN_ATOMIC_LOAD(__al_ptr, __al_val); \ - membar_sync(); \ + membar_acquire(); \ __END_ATOMIC_LOAD(__al_val); \ }) @@ -482,7 +476,7 @@ void kcsan_atomic_store(volatile void *, volatile __typeof__(*(p)) *__as_ptr = (p); \ __typeof__(*(p)) __as_val = (v); \ __ATOMIC_PTR_CHECK(__as_ptr); \ - membar_exit(); \ + membar_release(); \ __DO_ATOMIC_STORE(__as_ptr, __as_val); \ })
CVS commit: src/sys/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:34:30 UTC 2022 Modified Files: src/sys/sys: atomic.h Log Message: atomic_loadstore(9): Use membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/sys/atomic.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:32:53 UTC 2022 Modified Files: src/common/lib/libc/arch/aarch64/atomic: membar_ops.S src/common/lib/libc/arch/alpha/atomic: membar_ops.S src/common/lib/libc/arch/arm/atomic: membar_ops.S src/common/lib/libc/arch/hppa/atomic: membar_ops.S src/common/lib/libc/arch/i386/atomic: atomic.S src/common/lib/libc/arch/ia64/atomic: atomic.S src/common/lib/libc/arch/mips/atomic: membar_ops.S src/common/lib/libc/arch/or1k/atomic: membar_ops.S src/common/lib/libc/arch/powerpc/atomic: membar_ops.S src/common/lib/libc/arch/riscv/atomic: membar_ops.S src/common/lib/libc/arch/sparc/atomic: membar_ops.S src/common/lib/libc/arch/sparc64/atomic: membar_ops.S src/common/lib/libc/arch/x86_64/atomic: atomic.S src/common/lib/libc/atomic: membar_ops_nop.c src/distrib/sets/lists/comp: mi src/lib/libc/atomic: Makefile.inc membar_ops.3 src/share/man/man9: atomic_loadstore.9 src/sys/sys: atomic.h src/tests/lib/libc/membar: t_dekker.c t_spinlock.c Log Message: Introduce membar_acquire/release. Deprecate membar_enter/exit. The names membar_enter/exit were unclear, and the documentation of membar_enter has disagreed with the implementations on sparc, powerpc, and even x86(!) for the entire time it has been in NetBSD. The terms `acquire' and `release' are ubiquitous in the literature today, and have been adopted in the C and C++ standards to mean load-before-load/store and load/store-before-store, respectively, which are exactly the orderings required by acquiring and releasing a mutex, as well as other useful applications like decrementing a reference count and then freeing the underlying object if it went to zero. Originally I proposed changing one word in the documentation for membar_enter to make it load-before-load/store instead of store-before-load/store, i.e., to make it an acquire barrier. I proposed this on the grounds that (a) all implementations guarantee load-before-load/store, (b) some implementations fail to guarantee store-before-load/store, and (c) all uses in-tree assume load-before-load/store. I verified parts (a) and (b) (except, for (a), powerpc didn't even guarantee load-before-load/store -- isync isn't necessarily enough; need lwsync in general -- but it _almost_ did, and it certainly didn't guarantee store-before-load/store). Part (c) might not be correct, however: under the mistaken assumption that atomic-r/m/w then membar-w/rw is equivalent to atomic-r/m/w then membar-r/rw, I only audited the cases of membar_enter that _aren't_ immediately after an atomic-r/m/w. All of those cases assume load-before-load/store. But my assumption was wrong -- there are cases of atomic-r/m/w then membar-w/rw that would be broken by changing to atomic-r/m/w then membar-r/rw: https://mail-index.netbsd.org/tech-kern/2022/03/29/msg028044.html Furthermore, the name membar_enter has been adopted in other places like OpenBSD where it actually does follow the documentation and guarantee store-before-load/store, even if that order is not useful. So the name membar_enter currently lives in a bad place where it means either of two things -- r/rw or w/rw. With this change, we deprecate membar_enter/exit, introduce membar_acquire/release as better names for the useful pair (r/rw and rw/w), and make sure the implementation of membar_enter guarantees both what was documented _and_ what was implemented, making it an alias for membar_sync. While here, rework all of the membar_* definitions and aliases. The new logic follows a rule to make it easier to audit: membar_X is defined as an alias for membar_Y iff membar_X is guaranteed by membar_Y. The `no stronger than' relation is (the transitive closure of): - membar_consumer (r/r) is guaranteed by membar_acquire (r/rw) - membar_producer (w/w) is guaranteed by membar_release (rw/w) - membar_acquire (r/rw) is guaranteed by membar_sync (rw/rw) - membar_release (rw/w) is guaranteed by membar_sync (rw/rw) And, for the deprecated membars: - membar_enter (whether r/rw, w/rw, or rw/rw) is guaranteed by membar_sync (rw/rw) - membar_exit (rw/w) is guaranteed by membar_release (rw/w) (membar_exit is identical to membar_release, but the name is deprecated.) Finally, while here, annotate some of the instructions with their semantics. For powerpc, leave an essay with citations on the unfortunate but -- as far as I can tell -- necessary decision to use lwsync, not isync, for membar_acquire and membar_consumer. Also add membar(3) and atomic(3) man page links. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/alpha/atomic/membar_ops.S cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/atomic/membar_ops.S cvs rdiff -u -r1.2 -r1.3
CVS commit: src
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:32:53 UTC 2022 Modified Files: src/common/lib/libc/arch/aarch64/atomic: membar_ops.S src/common/lib/libc/arch/alpha/atomic: membar_ops.S src/common/lib/libc/arch/arm/atomic: membar_ops.S src/common/lib/libc/arch/hppa/atomic: membar_ops.S src/common/lib/libc/arch/i386/atomic: atomic.S src/common/lib/libc/arch/ia64/atomic: atomic.S src/common/lib/libc/arch/mips/atomic: membar_ops.S src/common/lib/libc/arch/or1k/atomic: membar_ops.S src/common/lib/libc/arch/powerpc/atomic: membar_ops.S src/common/lib/libc/arch/riscv/atomic: membar_ops.S src/common/lib/libc/arch/sparc/atomic: membar_ops.S src/common/lib/libc/arch/sparc64/atomic: membar_ops.S src/common/lib/libc/arch/x86_64/atomic: atomic.S src/common/lib/libc/atomic: membar_ops_nop.c src/distrib/sets/lists/comp: mi src/lib/libc/atomic: Makefile.inc membar_ops.3 src/share/man/man9: atomic_loadstore.9 src/sys/sys: atomic.h src/tests/lib/libc/membar: t_dekker.c t_spinlock.c Log Message: Introduce membar_acquire/release. Deprecate membar_enter/exit. The names membar_enter/exit were unclear, and the documentation of membar_enter has disagreed with the implementations on sparc, powerpc, and even x86(!) for the entire time it has been in NetBSD. The terms `acquire' and `release' are ubiquitous in the literature today, and have been adopted in the C and C++ standards to mean load-before-load/store and load/store-before-store, respectively, which are exactly the orderings required by acquiring and releasing a mutex, as well as other useful applications like decrementing a reference count and then freeing the underlying object if it went to zero. Originally I proposed changing one word in the documentation for membar_enter to make it load-before-load/store instead of store-before-load/store, i.e., to make it an acquire barrier. I proposed this on the grounds that (a) all implementations guarantee load-before-load/store, (b) some implementations fail to guarantee store-before-load/store, and (c) all uses in-tree assume load-before-load/store. I verified parts (a) and (b) (except, for (a), powerpc didn't even guarantee load-before-load/store -- isync isn't necessarily enough; need lwsync in general -- but it _almost_ did, and it certainly didn't guarantee store-before-load/store). Part (c) might not be correct, however: under the mistaken assumption that atomic-r/m/w then membar-w/rw is equivalent to atomic-r/m/w then membar-r/rw, I only audited the cases of membar_enter that _aren't_ immediately after an atomic-r/m/w. All of those cases assume load-before-load/store. But my assumption was wrong -- there are cases of atomic-r/m/w then membar-w/rw that would be broken by changing to atomic-r/m/w then membar-r/rw: https://mail-index.netbsd.org/tech-kern/2022/03/29/msg028044.html Furthermore, the name membar_enter has been adopted in other places like OpenBSD where it actually does follow the documentation and guarantee store-before-load/store, even if that order is not useful. So the name membar_enter currently lives in a bad place where it means either of two things -- r/rw or w/rw. With this change, we deprecate membar_enter/exit, introduce membar_acquire/release as better names for the useful pair (r/rw and rw/w), and make sure the implementation of membar_enter guarantees both what was documented _and_ what was implemented, making it an alias for membar_sync. While here, rework all of the membar_* definitions and aliases. The new logic follows a rule to make it easier to audit: membar_X is defined as an alias for membar_Y iff membar_X is guaranteed by membar_Y. The `no stronger than' relation is (the transitive closure of): - membar_consumer (r/r) is guaranteed by membar_acquire (r/rw) - membar_producer (w/w) is guaranteed by membar_release (rw/w) - membar_acquire (r/rw) is guaranteed by membar_sync (rw/rw) - membar_release (rw/w) is guaranteed by membar_sync (rw/rw) And, for the deprecated membars: - membar_enter (whether r/rw, w/rw, or rw/rw) is guaranteed by membar_sync (rw/rw) - membar_exit (rw/w) is guaranteed by membar_release (rw/w) (membar_exit is identical to membar_release, but the name is deprecated.) Finally, while here, annotate some of the instructions with their semantics. For powerpc, leave an essay with citations on the unfortunate but -- as far as I can tell -- necessary decision to use lwsync, not isync, for membar_acquire and membar_consumer. Also add membar(3) and atomic(3) man page links. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/alpha/atomic/membar_ops.S cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/atomic/membar_ops.S cvs rdiff -u -r1.2 -r1.3
CVS commit: src/common/lib/libc/arch/riscv/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:53 UTC 2022 Modified Files: src/common/lib/libc/arch/riscv/atomic: membar_ops.S Log Message: riscv/membar_ops: Upgrade membar_enter from W/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/riscv/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/riscv/atomic/membar_ops.S diff -u src/common/lib/libc/arch/riscv/atomic/membar_ops.S:1.2 src/common/lib/libc/arch/riscv/atomic/membar_ops.S:1.3 --- src/common/lib/libc/arch/riscv/atomic/membar_ops.S:1.2 Wed Apr 6 22:47:56 2022 +++ src/common/lib/libc/arch/riscv/atomic/membar_ops.S Sat Apr 9 22:53:53 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.2 2022/04/06 22:47:56 riastradh Exp $ */ +/* $NetBSD: membar_ops.S,v 1.3 2022/04/09 22:53:53 riastradh Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ ATOMIC_OP_ALIAS(membar_sync,_membar_sync CRT_ALIAS(__sync_synchronize,_membar_sync) ENTRY_NP(_membar_enter) - fence w,rw + fence rw,rw ret END(_membar_enter) ATOMIC_OP_ALIAS(membar_enter,_membar_enter)
CVS commit: src/common/lib/libc/arch/riscv/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:53 UTC 2022 Modified Files: src/common/lib/libc/arch/riscv/atomic: membar_ops.S Log Message: riscv/membar_ops: Upgrade membar_enter from W/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/riscv/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/x86_64/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:45 UTC 2022 Modified Files: src/common/lib/libc/arch/x86_64/atomic: atomic.S Log Message: x86_64/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/common/lib/libc/arch/x86_64/atomic/atomic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/x86_64/atomic/atomic.S diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.26 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.27 --- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.26 Sat Apr 9 12:07:29 2022 +++ src/common/lib/libc/arch/x86_64/atomic/atomic.S Sat Apr 9 22:53:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.26 2022/04/09 12:07:29 riastradh Exp $ */ +/* $NetBSD: atomic.S,v 1.27 2022/04/09 22:53:45 riastradh Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -365,7 +365,7 @@ ALIAS(atomic_cas_ptr_ni,_atomic_cas_64_n ALIAS(membar_consumer,_membar_consumer) ALIAS(membar_producer,_membar_producer) -ALIAS(membar_enter,_membar_consumer) +ALIAS(membar_enter,_membar_sync) ALIAS(membar_exit,_membar_producer) ALIAS(membar_sync,_membar_sync) @@ -421,7 +421,7 @@ STRONG_ALIAS(_atomic_cas_uint_ni,_atomic STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64_ni) STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64_ni) -STRONG_ALIAS(_membar_enter,_membar_consumer) +STRONG_ALIAS(_membar_enter,_membar_sync) STRONG_ALIAS(_membar_exit,_membar_producer) #ifdef _HARDKERNEL
CVS commit: src/common/lib/libc/arch/x86_64/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:45 UTC 2022 Modified Files: src/common/lib/libc/arch/x86_64/atomic: atomic.S Log Message: x86_64/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/common/lib/libc/arch/x86_64/atomic/atomic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/i386/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:36 UTC 2022 Modified Files: src/common/lib/libc/arch/i386/atomic: atomic.S Log Message: i386/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/common/lib/libc/arch/i386/atomic/atomic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/i386/atomic/atomic.S diff -u src/common/lib/libc/arch/i386/atomic/atomic.S:1.33 src/common/lib/libc/arch/i386/atomic/atomic.S:1.34 --- src/common/lib/libc/arch/i386/atomic/atomic.S:1.33 Sat Apr 9 12:07:29 2022 +++ src/common/lib/libc/arch/i386/atomic/atomic.S Sat Apr 9 22:53:36 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.33 2022/04/09 12:07:29 riastradh Exp $ */ +/* $NetBSD: atomic.S,v 1.34 2022/04/09 22:53:36 riastradh Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -342,7 +342,7 @@ ALIAS(__sync_val_compare_and_swap_8,_ato ALIAS(membar_consumer,_membar_consumer) ALIAS(membar_producer,_membar_producer) -ALIAS(membar_enter,_membar_consumer) +ALIAS(membar_enter,_membar_sync) ALIAS(membar_exit,_membar_producer) ALIAS(membar_sync,_membar_sync) @@ -398,7 +398,7 @@ STRONG_ALIAS(_atomic_cas_uint_ni,_atomic STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32_ni) STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32_ni) -STRONG_ALIAS(_membar_enter,_membar_consumer) +STRONG_ALIAS(_membar_enter,_membar_sync) STRONG_ALIAS(_membar_exit,_membar_producer) #ifdef _HARDKERNEL
CVS commit: src/common/lib/libc/arch/i386/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:36 UTC 2022 Modified Files: src/common/lib/libc/arch/i386/atomic: atomic.S Log Message: i386/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/common/lib/libc/arch/i386/atomic/atomic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/sparc64/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:25 UTC 2022 Modified Files: src/common/lib/libc/arch/sparc64/atomic: membar_ops.S Log Message: sparc64/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/sparc64/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/sparc64/atomic/membar_ops.S diff -u src/common/lib/libc/arch/sparc64/atomic/membar_ops.S:1.7 src/common/lib/libc/arch/sparc64/atomic/membar_ops.S:1.8 --- src/common/lib/libc/arch/sparc64/atomic/membar_ops.S:1.7 Sat Apr 9 12:06:47 2022 +++ src/common/lib/libc/arch/sparc64/atomic/membar_ops.S Sat Apr 9 22:53:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.7 2022/04/09 12:06:47 riastradh Exp $ */ +/* $NetBSD: membar_ops.S,v 1.8 2022/04/09 22:53:25 riastradh Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -35,8 +35,9 @@ /* * These assume Total Store Order (TSO), which may reorder - * store-before-load but nothing else. Hence, only membar_sync must - * issue anything -- namely, membar #StoreLoad. + * store-before-load but nothing else. Hence, only membar_sync (and + * its deprecated alias membar_enter) must issue anything -- namely, + * membar #StoreLoad. * * If we ran with Partial Store Order (PSO), we would also need to * issue membar #StoreStore for membar_exit (load/store-before-store) @@ -73,8 +74,8 @@ END(_membar_sync) ATOMIC_OP_ALIAS(membar_producer,_membar_consumer) STRONG_ALIAS(_membar_producer,_membar_consumer) ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer) -ATOMIC_OP_ALIAS(membar_enter,_membar_consumer) -STRONG_ALIAS(_membar_enter,_membar_consumer) +ATOMIC_OP_ALIAS(membar_enter,_membar_sync) +STRONG_ALIAS(_membar_enter,_membar_sync) ATOMIC_OP_ALIAS(membar_exit,_membar_consumer) STRONG_ALIAS(_membar_exit,_membar_consumer) ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
CVS commit: src/common/lib/libc/arch/sparc64/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:25 UTC 2022 Modified Files: src/common/lib/libc/arch/sparc64/atomic: membar_ops.S Log Message: sparc64/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/sparc64/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/sparc/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:17 UTC 2022 Modified Files: src/common/lib/libc/arch/sparc/atomic: membar_ops.S Log Message: sparc/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/sparc/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/sparc/atomic/membar_ops.S diff -u src/common/lib/libc/arch/sparc/atomic/membar_ops.S:1.6 src/common/lib/libc/arch/sparc/atomic/membar_ops.S:1.7 --- src/common/lib/libc/arch/sparc/atomic/membar_ops.S:1.6 Sat Apr 9 12:06:39 2022 +++ src/common/lib/libc/arch/sparc/atomic/membar_ops.S Sat Apr 9 22:53:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.6 2022/04/09 12:06:39 riastradh Exp $ */ +/* $NetBSD: membar_ops.S,v 1.7 2022/04/09 22:53:17 riastradh Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,10 +39,10 @@ /* * These assume Total Store Order (TSO), which may reorder - * store-before-load but nothing else. Hence, only membar_sync must - * issue anything -- specifically, an LDSTUB, which (along with SWAP) - * is the only instruction that implies a sequential consistency - * barrier. + * store-before-load but nothing else. Hence, only membar_sync (and + * its deprecated alias membar_enter) must issue anything -- + * specifically, an LDSTUB, which (along with SWAP) is the only + * instruction that implies a sequential consistency barrier. * * If we ran with Partial Store Order (PSO), we would also need to * issue STBAR for membar_exit (load/store-before-store) and @@ -66,8 +66,8 @@ END(_membar_sync) ATOMIC_OP_ALIAS(membar_producer,_membar_consumer) STRONG_ALIAS(_membar_producer,_membar_consumer) ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer) -ATOMIC_OP_ALIAS(membar_enter,_membar_consumer) -STRONG_ALIAS(_membar_enter,_membar_consumer) +ATOMIC_OP_ALIAS(membar_enter,_membar_sync) +STRONG_ALIAS(_membar_enter,_membar_sync) ATOMIC_OP_ALIAS(membar_exit,_membar_consumer) STRONG_ALIAS(_membar_exit,_membar_consumer) ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
CVS commit: src/common/lib/libc/arch/sparc/atomic
Module Name:src Committed By: riastradh Date: Sat Apr 9 22:53:17 UTC 2022 Modified Files: src/common/lib/libc/arch/sparc/atomic: membar_ops.S Log Message: sparc/membar_ops: Upgrade membar_enter from R/RW to RW/RW. This will be deprecated soon but let's avoid leaving rakes to trip on with it arising from disagreement over the documentation (W/RW) and implementation and usage (R/RW). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/sparc/atomic/membar_ops.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sat Apr 9 22:26:49 UTC 2022 Modified Files: src/usr.bin/xlint: Makefile.inc Log Message: lint: ensure that lint itself compiles without lint warnings It would be a pity if lint didn't even survive its own style checks. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/Makefile.inc diff -u src/usr.bin/xlint/Makefile.inc:1.21 src/usr.bin/xlint/Makefile.inc:1.22 --- src/usr.bin/xlint/Makefile.inc:1.21 Fri Apr 8 21:48:19 2022 +++ src/usr.bin/xlint/Makefile.inc Sat Apr 9 22:26:49 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.21 2022/04/08 21:48:19 rillig Exp $ +# $NetBSD: Makefile.inc,v 1.22 2022/04/09 22:26:49 rillig Exp $ .include @@ -24,3 +24,5 @@ CFLAGS+= ${ACTIVE_CC:Mgcc:%=-ftrapv} .if exists(${.CURDIR}/../../Makefile.inc) .include "${.CURDIR}/../../Makefile.inc" .endif + +LINTFLAGS+= -w # treat warnings as errors
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sat Apr 9 22:26:49 UTC 2022 Modified Files: src/usr.bin/xlint: Makefile.inc Log Message: lint: ensure that lint itself compiles without lint warnings It would be a pity if lint didn't even survive its own style checks. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 21:19:52 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c lint1.h Log Message: lint: rename dinfo_t.d_offset to d_offset_in_bits Most often, offsets are measured in bytes, so better embed the unit in the variable name. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.391 -r1.392 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.274 -r1.275 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.148 -r1.149 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.391 src/usr.bin/xlint/lint1/cgram.y:1.392 --- src/usr.bin/xlint/lint1/cgram.y:1.391 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 21:19:52 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $"); #endif #include @@ -921,7 +921,7 @@ struct_or_union: /* C99 6.7.2.1 */ T_STRUCT_OR_UNION { symtyp = FTAG; begin_declaration_level($1 == STRUCT ? MOS : MOU); - dcs->d_offset = 0; + dcs->d_offset_in_bits = 0; dcs->d_sou_align_in_bits = CHAR_SIZE; $$ = $1; } Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.15 src/usr.bin/xlint/lint1/debug.c:1.16 --- src/usr.bin/xlint/lint1/debug.c:1.15 Sat Apr 9 16:02:14 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 21:19:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $"); #endif #include @@ -325,8 +325,8 @@ debug_dinfo(const dinfo_t *d) // NOLINT( } if (d->d_redeclared_symbol != NULL) debug_sym(" redeclared=(", d->d_redeclared_symbol, ")"); - if (d->d_offset != 0) - debug_printf(" offset=%u", d->d_offset); + if (d->d_offset_in_bits != 0) + debug_printf(" offset=%u", d->d_offset_in_bits); if (d->d_sou_align_in_bits != 0) debug_printf(" align=%u", (unsigned)d->d_sou_align_in_bits); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.274 src/usr.bin/xlint/lint1/decl.c:1.275 --- src/usr.bin/xlint/lint1/decl.c:1.274 Sat Apr 9 16:02:14 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 21:19:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 rillig Exp $"); #endif #include @@ -1161,24 +1161,24 @@ declarator_1_struct_union(sym_t *dsym) } if (dcs->d_ctx == MOU) { - o = dcs->d_offset; - dcs->d_offset = 0; + o = dcs->d_offset_in_bits; + dcs->d_offset_in_bits = 0; } if (dsym->s_bitfield) { align(alignment_in_bits(tp), tp->t_flen); - dsym->u.s_member.sm_offset_in_bits = - dcs->d_offset - dcs->d_offset % size_in_bits(t); - tp->t_foffs = - dcs->d_offset - dsym->u.s_member.sm_offset_in_bits; - dcs->d_offset += tp->t_flen; + dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits - + dcs->d_offset_in_bits % size_in_bits(t); + tp->t_foffs = dcs->d_offset_in_bits - + dsym->u.s_member.sm_offset_in_bits; + dcs->d_offset_in_bits += tp->t_flen; } else { align(alignment_in_bits(tp), 0); - dsym->u.s_member.sm_offset_in_bits = dcs->d_offset; - dcs->d_offset += sz; + dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits; + dcs->d_offset_in_bits += sz; } if (dcs->d_ctx == MOU) { - if (o > dcs->d_offset) - dcs->d_offset = o; + if (o > dcs->d_offset_in_bits) + dcs->d_offset_in_bits = o; } check_function_definition(dsym, false); @@ -1210,9 +1210,9 @@ align(unsigned int al, unsigned int len) if (al > dcs->d_sou_align_in_bits) dcs->d_sou_align_in_bits = al; - no = (dcs->d_offset + (al - 1)) & ~(al - 1); - if (len == 0 || dcs->d_offset + len > no) - dcs->d_offset = no; + no = (dcs->d_offset_in_bits + (al - 1)) & ~(al - 1); + if (len == 0 ||
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 21:19:52 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c lint1.h Log Message: lint: rename dinfo_t.d_offset to d_offset_in_bits Most often, offsets are measured in bytes, so better embed the unit in the variable name. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.391 -r1.392 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.274 -r1.275 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.148 -r1.149 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem
Module Name:src Committed By: riastradh Date: Sat Apr 9 19:59:08 UTC 2022 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem: nouveau_nvkm_subdev_instmem_base.c Log Message: nouveau: Omit needless local patch. This code probably once called ioread32/iowrite32 or something, but no longer. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 \ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem
Module Name:src Committed By: riastradh Date: Sat Apr 9 19:59:08 UTC 2022 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem: nouveau_nvkm_subdev_instmem_base.c Log Message: nouveau: Omit needless local patch. This code probably once called ioread32/iowrite32 or something, but no longer. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 \ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c:1.8 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c:1.9 --- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c:1.8 Sun Dec 19 11:34:45 2021 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_base.c Sat Apr 9 19:59:08 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: nouveau_nvkm_subdev_instmem_base.c,v 1.8 2021/12/19 11:34:45 riastradh Exp $ */ +/* $NetBSD: nouveau_nvkm_subdev_instmem_base.c,v 1.9 2022/04/09 19:59:08 riastradh Exp $ */ /* * Copyright 2012 Red Hat Inc. @@ -24,7 +24,7 @@ * Authors: Ben Skeggs */ #include -__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_instmem_base.c,v 1.8 2021/12/19 11:34:45 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_instmem_base.c,v 1.9 2022/04/09 19:59:08 riastradh Exp $"); #include "priv.h" @@ -34,37 +34,6 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm # define __iomem __nvkm_memory_iomem #endif -#ifdef __NetBSD__ - -/* - * XXX I think this should be done with bus_space, but the depth of - * abstractions is dizzying and I'm not actually sure where these - * pointers come from. - */ - -# define ioread32_native fake_ioread32_native -# define iowrite32_native fake_iowrite32_native - -static inline uint32_t -ioread32_native(const void __iomem *ptr) -{ - uint32_t v; - - v = *(const uint32_t __iomem *)ptr; - membar_consumer(); - - return v; -} - -static inline void -iowrite32_native(uint32_t v, void __iomem *ptr) -{ - - membar_producer(); - *(uint32_t __iomem *)ptr = v; -} - -#endif /** * instmem object base implementation */ @@ -88,12 +57,6 @@ nvkm_instobj_load(struct nvkm_instobj *i iobj->suspend = NULL; } -#ifdef __NetBSD__ -# undef ioread32_native -# undef iowrite32_native -#endif - - static int nvkm_instobj_save(struct nvkm_instobj *iobj) {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 16:02:14 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: debug.c decl.c lint1.h tree.c Log Message: lint: extract is_member into separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.147 -r1.148 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.422 -r1.423 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 16:02:14 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: debug.c decl.c lint1.h tree.c Log Message: lint: extract is_member into separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.147 -r1.148 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.422 -r1.423 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.14 src/usr.bin/xlint/lint1/debug.c:1.15 --- src/usr.bin/xlint/lint1/debug.c:1.14 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 16:02:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $"); #endif #include @@ -277,8 +277,7 @@ debug_sym(const char *prefix, const sym_ debug_printf(" value=%s", sym->u.s_bool_constant ? "true" : "false"); - if ((sym->s_scl == MOS || sym->s_scl == MOU) && - sym->u.s_member.sm_sou_type != NULL) { + if (is_member(sym) && sym->u.s_member.sm_sou_type != NULL) { struct_or_union *sou_type = sym->u.s_member.sm_sou_type; const char *tag = sou_type->sou_tag->s_name; const sym_t *def = sou_type->sou_first_typedef; Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.273 src/usr.bin/xlint/lint1/decl.c:1.274 --- src/usr.bin/xlint/lint1/decl.c:1.273 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 16:02:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.273 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.273 2022/04/09 15:43:41 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $"); #endif #include @@ -1123,12 +1123,10 @@ declarator_1_struct_union(sym_t *dsym) int sz; unsigned int o = 0; /* Appease GCC */ - lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU); + lint_assert(is_member(dsym)); if (dcs->d_redeclared_symbol != NULL) { - /* should be ensured by storesym() */ - lint_assert(dcs->d_redeclared_symbol->s_scl == MOS || - dcs->d_redeclared_symbol->s_scl == MOU); + lint_assert(is_member(dcs->d_redeclared_symbol)); if (dsym->u.s_member.sm_sou_type == dcs->d_redeclared_symbol->u.s_member.sm_sou_type) { Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.147 src/usr.bin/xlint/lint1/lint1.h:1.148 --- src/usr.bin/xlint/lint1/lint1.h:1.147 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/lint1.h Sat Apr 9 16:02:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.147 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.148 2022/04/09 16:02:14 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -582,3 +582,9 @@ is_struct_or_union(tspec_t t) { return t == STRUCT || t == UNION; } + +static inline bool +is_member(const sym_t *sym) +{ + return sym->s_scl == MOS || sym->s_scl == MOU; +} Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.422 src/usr.bin/xlint/lint1/tree.c:1.423 --- src/usr.bin/xlint/lint1/tree.c:1.422 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/tree.c Sat Apr 9 16:02:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.422 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.422 2022/04/09 15:43:41 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 rillig Exp $"); #endif #include @@ -386,7 +386,7 @@ struct_or_union_member(tnode_t *tn, op_t */ if (str != NULL) { for (sym = msym; sym != NULL; sym = sym->s_symtab_next) { - if (sym->s_scl != MOS && sym->s_scl != MOU) + if (!is_member(sym)) continue; if (sym->u.s_member.sm_sou_type != str) continue; @@ -2776,7 +2776,7 @@ build_struct_access(op_t op, bool sys, t bool nolval; lint_assert(rn->tn_op == NAME); - lint_assert(rn->tn_sym->s_scl == MOS || rn->tn_sym->s_scl == MOU); + lint_assert(is_member(rn->tn_sym)); /* * Remember if the left operand is an lvalue (structure members
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 15:43:42 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: Makefile cgram.y ckbool.c debug.c decl.c lex.c lint1.h tree.c Log Message: lint: disambiguate sym_t.s_value Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.390 -r1.391 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.272 -r1.273 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.421 -r1.422 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.89 src/usr.bin/xlint/lint1/Makefile:1.90 --- src/usr.bin/xlint/lint1/Makefile:1.89 Sat Apr 9 14:50:18 2022 +++ src/usr.bin/xlint/lint1/Makefile Sat Apr 9 15:43:41 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.89 2022/04/09 14:50:18 rillig Exp $ +# $NetBSD: Makefile,v 1.90 2022/04/09 15:43:41 rillig Exp $ .include @@ -58,7 +58,6 @@ ${MAN}.date: err.c # Extra -UYYDEBUG since cgram.c contains 'int yydebug; if (yydebug)'. cgram.ln: cgram.c - : extra ${LINT} ${LINTFLAGS} \ ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \ -i -UYYDEBUG ${.IMPSRC} Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.390 src/usr.bin/xlint/lint1/cgram.y:1.391 --- src/usr.bin/xlint/lint1/cgram.y:1.390 Sat Apr 9 14:50:18 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 15:43:41 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.390 2022/04/09 14:50:18 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.390 2022/04/09 14:50:18 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $"); #endif #include @@ -114,7 +114,7 @@ static void anonymize(sym_t *s) { for ( ; s != NULL; s = s->s_next) - s->u.s_sou_type = NULL; + s->u.s_member.sm_sou_type = NULL; } #if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) Index: src/usr.bin/xlint/lint1/ckbool.c diff -u src/usr.bin/xlint/lint1/ckbool.c:1.11 src/usr.bin/xlint/lint1/ckbool.c:1.12 --- src/usr.bin/xlint/lint1/ckbool.c:1.11 Sat Apr 9 14:50:18 2022 +++ src/usr.bin/xlint/lint1/ckbool.c Sat Apr 9 15:43:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ckbool.c,v 1.11 2022/04/09 14:50:18 rillig Exp $ */ +/* $NetBSD: ckbool.c,v 1.12 2022/04/09 15:43:41 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: ckbool.c,v 1.11 2022/04/09 14:50:18 rillig Exp $"); +__RCSID("$NetBSD: ckbool.c,v 1.12 2022/04/09 15:43:41 rillig Exp $"); #endif #include @@ -243,18 +243,14 @@ fallback_symbol_strict_bool(sym_t *sym) if (Tflag && strcmp(sym->s_name, "__lint_false") == 0) { sym->s_scl = BOOL_CONST; sym->s_type = gettyp(BOOL); - sym->s_value.v_tspec = BOOL; - sym->s_value.v_unsigned_since_c90 = false; - sym->s_value.v_quad = 0; + sym->u.s_bool_constant = false; return true; } if (Tflag && strcmp(sym->s_name, "__lint_true") == 0) { sym->s_scl = BOOL_CONST; sym->s_type = gettyp(BOOL); - sym->s_value.v_tspec = BOOL; - sym->s_value.v_unsigned_since_c90 = false; - sym->s_value.v_quad = 1; + sym->u.s_bool_constant = true; return true; } Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.13 src/usr.bin/xlint/lint1/debug.c:1.14 --- src/usr.bin/xlint/lint1/debug.c:1.13 Sat Apr 9 14:50:18 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 15:43:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.13 2022/04/09 14:50:18 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.13 2022/04/09 14:50:18 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $"); #endif #include @@ -271,14 +271,17 @@ debug_sym(const char *prefix, const sym_ debug_printf(" used-at=%s:%d", sym->s_use_pos.p_file, sym->s_use_pos.p_line); - if (sym->s_type != NULL && - (sym->s_type->t_is_enum || sym->s_type->t_tspec == BOOL)) - debug_printf(" value=%d", (int)sym->s_value.v_quad); + if (sym->s_type != NULL && sym->s_type->t_is_enum) +
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 15:43:42 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: Makefile cgram.y ckbool.c debug.c decl.c lex.c lint1.h tree.c Log Message: lint: disambiguate sym_t.s_value Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.390 -r1.391 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.272 -r1.273 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.421 -r1.422 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 14:50:18 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: Makefile cgram.y ckbool.c debug.c decl.c lint1.h tree.c Log Message: lint: split CTCONST into BOOL_CONST and ENUM_CONST Having a unified compile-time constant "storage class" made the code more difficult to understand. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.389 -r1.390 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.271 -r1.272 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.420 -r1.421 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.88 src/usr.bin/xlint/lint1/Makefile:1.89 --- src/usr.bin/xlint/lint1/Makefile:1.88 Tue Dec 21 15:27:19 2021 +++ src/usr.bin/xlint/lint1/Makefile Sat Apr 9 14:50:18 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.88 2021/12/21 15:27:19 roy Exp $ +# $NetBSD: Makefile,v 1.89 2022/04/09 14:50:18 rillig Exp $ .include @@ -56,6 +56,13 @@ ${MAN}.date: err.c -e 1q \ ${.ALLSRC} > ${.TARGET} +# Extra -UYYDEBUG since cgram.c contains 'int yydebug; if (yydebug)'. +cgram.ln: cgram.c + : extra + ${LINT} ${LINTFLAGS} \ + ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \ + -i -UYYDEBUG ${.IMPSRC} + ${MAN}: makeman ${LINT1:./%=%} Makefile ${MAN}.date ${_MKTARGET_CREATE} ${HOST_SH} ${.ALLSRC:M*makeman} "$$(cat ${.ALLSRC:M*.date})" ${LINT1} -m >${.TARGET} Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.389 src/usr.bin/xlint/lint1/cgram.y:1.390 --- src/usr.bin/xlint/lint1/cgram.y:1.389 Sat Apr 9 13:38:17 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 14:50:18 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.389 2022/04/09 13:38:17 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.390 2022/04/09 14:50:18 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.389 2022/04/09 13:38:17 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.390 2022/04/09 14:50:18 rillig Exp $"); #endif #include @@ -1069,7 +1069,7 @@ enum_specifier: /* C99 6.7.2.2 */ enum:/* helper for C99 6.7.2.2 */ T_ENUM { symtyp = FTAG; - begin_declaration_level(CTCONST); + begin_declaration_level(ENUM_CONST); } ; Index: src/usr.bin/xlint/lint1/ckbool.c diff -u src/usr.bin/xlint/lint1/ckbool.c:1.10 src/usr.bin/xlint/lint1/ckbool.c:1.11 --- src/usr.bin/xlint/lint1/ckbool.c:1.10 Wed Dec 22 15:36:37 2021 +++ src/usr.bin/xlint/lint1/ckbool.c Sat Apr 9 14:50:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ckbool.c,v 1.10 2021/12/22 15:36:37 rillig Exp $ */ +/* $NetBSD: ckbool.c,v 1.11 2022/04/09 14:50:18 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: ckbool.c,v 1.10 2021/12/22 15:36:37 rillig Exp $"); +__RCSID("$NetBSD: ckbool.c,v 1.11 2022/04/09 14:50:18 rillig Exp $"); #endif #include @@ -241,7 +241,7 @@ bool fallback_symbol_strict_bool(sym_t *sym) { if (Tflag && strcmp(sym->s_name, "__lint_false") == 0) { - sym->s_scl = CTCONST; /* close enough */ + sym->s_scl = BOOL_CONST; sym->s_type = gettyp(BOOL); sym->s_value.v_tspec = BOOL; sym->s_value.v_unsigned_since_c90 = false; @@ -250,7 +250,7 @@ fallback_symbol_strict_bool(sym_t *sym) } if (Tflag && strcmp(sym->s_name, "__lint_true") == 0) { - sym->s_scl = CTCONST; /* close enough */ + sym->s_scl = BOOL_CONST; sym->s_type = gettyp(BOOL); sym->s_value.v_tspec = BOOL; sym->s_value.v_unsigned_since_c90 = false; Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.12 src/usr.bin/xlint/lint1/debug.c:1.13 --- src/usr.bin/xlint/lint1/debug.c:1.12 Sat Apr 9 13:38:17 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 14:50:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.12 2022/04/09 13:38:17 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.13 2022/04/09 14:50:18 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.12 2022/04/09 13:38:17 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.13 2022/04/09 14:50:18 rillig Exp $"); #endif #include @@ -191,7 +191,8 @@ scl_name(scl_t scl) "enum", "member-of-struct", "member-of-union", - "compile-time-constant", + "bool-constant", + "enum-constant", "abstract", "old-style-function-argument", "prototype-argument",
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 14:50:18 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: Makefile cgram.y ckbool.c debug.c decl.c lint1.h tree.c Log Message: lint: split CTCONST into BOOL_CONST and ENUM_CONST Having a unified compile-time constant "storage class" made the code more difficult to understand. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.389 -r1.390 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.271 -r1.272 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.420 -r1.421 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/makefs
Module Name:src Committed By: riastradh Date: Sat Apr 9 14:38:47 UTC 2022 Modified Files: src/usr.sbin/makefs: Makefile Log Message: makefs(8): Needs -lm for ceil in udf as a host tool too. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/makefs/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/makefs/Makefile diff -u src/usr.sbin/makefs/Makefile:1.38 src/usr.sbin/makefs/Makefile:1.39 --- src/usr.sbin/makefs/Makefile:1.38 Wed Apr 6 22:25:00 2022 +++ src/usr.sbin/makefs/Makefile Sat Apr 9 14:38:47 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.38 2022/04/06 22:25:00 hauke Exp $ +# $NetBSD: Makefile,v 1.39 2022/04/09 14:38:47 riastradh Exp $ # WARNS?= 5 @@ -28,7 +28,9 @@ CPPFLAGS+= -I${.CURDIR} -I${MKNODSRC} -I .include "${.CURDIR}/msdos/Makefile.inc" .include "${.CURDIR}/udf/Makefile.inc" -.if !defined(HOSTPROG) +.if defined(HOSTPROG) +LDADD+= -lm +.else DPADD+= ${LIBUTIL} ${LIBM} LDADD+= -lutil -lm
CVS commit: src/usr.sbin/makefs
Module Name:src Committed By: riastradh Date: Sat Apr 9 14:38:47 UTC 2022 Modified Files: src/usr.sbin/makefs: Makefile Log Message: makefs(8): Needs -lm for ceil in udf as a host tool too. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/makefs/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/mips
Module Name:src Committed By: riastradh Date: Sat Apr 9 14:09:32 UTC 2022 Modified Files: src/sys/arch/mips/include: asm.h src/sys/arch/mips/rmi: rmixl_cpu.c Log Message: mips/rmi: Hack to get XLSATX64.MP kernel building again. Using in a .c file is kinda grody but CALLFRAME_SIZ doesn't seem to be defined anywhere else. Not sure how this was ever supposed to work... To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/arch/mips/include/asm.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/rmi/rmixl_cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/include/asm.h diff -u src/sys/arch/mips/include/asm.h:1.69 src/sys/arch/mips/include/asm.h:1.70 --- src/sys/arch/mips/include/asm.h:1.69 Sun Feb 27 19:22:20 2022 +++ src/sys/arch/mips/include/asm.h Sat Apr 9 14:09:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: asm.h,v 1.69 2022/02/27 19:22:20 riastradh Exp $ */ +/* $NetBSD: asm.h,v 1.70 2022/04/09 14:09:32 riastradh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -61,12 +61,14 @@ #include "opt_gprof.h" #endif +#ifdef __ASSEMBLER__ #define __BIT(n) (1 << (n)) #define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo))) #define __LOWEST_SET_BIT(__mask) __mask) - 1) & (__mask)) ^ (__mask)) #define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) #define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) +#endif /* __ASSEMBLER__ */ /* * Define -pg profile entry code. Index: src/sys/arch/mips/rmi/rmixl_cpu.c diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.12 src/sys/arch/mips/rmi/rmixl_cpu.c:1.13 --- src/sys/arch/mips/rmi/rmixl_cpu.c:1.12 Wed Aug 12 07:37:39 2020 +++ src/sys/arch/mips/rmi/rmixl_cpu.c Sat Apr 9 14:09:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: rmixl_cpu.c,v 1.12 2020/08/12 07:37:39 skrll Exp $ */ +/* $NetBSD: rmixl_cpu.c,v 1.13 2022/04/09 14:09:32 riastradh Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -38,7 +38,7 @@ #include "locators.h" #include -__KERNEL_RCSID(0, "$NetBSD: rmixl_cpu.c,v 1.12 2020/08/12 07:37:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rmixl_cpu.c,v 1.13 2022/04/09 14:09:32 riastradh Exp $"); #include "opt_multiprocessor.h" #include "opt_ddb.h" @@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: rmixl_cpu.c, #include #endif +#include /* XXX CALLFRAME_SIZ */ static int cpu_rmixl_match(device_t, cfdata_t, void *); static void cpu_rmixl_attach(device_t, device_t, void *);
CVS commit: src/sys/arch/mips
Module Name:src Committed By: riastradh Date: Sat Apr 9 14:09:32 UTC 2022 Modified Files: src/sys/arch/mips/include: asm.h src/sys/arch/mips/rmi: rmixl_cpu.c Log Message: mips/rmi: Hack to get XLSATX64.MP kernel building again. Using in a .c file is kinda grody but CALLFRAME_SIZ doesn't seem to be defined anywhere else. Not sure how this was ever supposed to work... To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/arch/mips/include/asm.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/rmi/rmixl_cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 13:38:17 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c func.c lex.c lint1.h tree.c Log Message: lint: inline member access macros for sym_t Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.270 -r1.271 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.419 -r1.420 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.388 src/usr.bin/xlint/lint1/cgram.y:1.389 --- src/usr.bin/xlint/lint1/cgram.y:1.388 Wed Mar 9 00:20:48 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 13:38:17 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.388 2022/03/09 00:20:48 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.389 2022/04/09 13:38:17 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.388 2022/03/09 00:20:48 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.389 2022/04/09 13:38:17 rillig Exp $"); #endif #include @@ -114,7 +114,7 @@ static void anonymize(sym_t *s) { for ( ; s != NULL; s = s->s_next) - s->s_sou_type = NULL; + s->u.s_sou_type = NULL; } #if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.11 src/usr.bin/xlint/lint1/debug.c:1.12 --- src/usr.bin/xlint/lint1/debug.c:1.11 Sat Apr 2 14:28:30 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 13:38:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.11 2022/04/02 14:28:30 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.12 2022/04/09 13:38:17 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.11 2022/04/02 14:28:30 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.12 2022/04/09 13:38:17 rillig Exp $"); #endif #include @@ -275,9 +275,9 @@ debug_sym(const char *prefix, const sym_ debug_printf(" value=%d", (int)sym->s_value.v_quad); if ((sym->s_scl == MOS || sym->s_scl == MOU) && - sym->s_sou_type != NULL) { - const char *tag = sym->s_sou_type->sou_tag->s_name; - const sym_t *def = sym->s_sou_type->sou_first_typedef; + sym->u.s_sou_type != NULL) { + const char *tag = sym->u.s_sou_type->sou_tag->s_name; + const sym_t *def = sym->u.s_sou_type->sou_first_typedef; if (tag == unnamed && def != NULL) debug_printf(" sou='typedef %s'", def->s_name); else @@ -287,12 +287,13 @@ debug_sym(const char *prefix, const sym_ if (sym->s_keyword != NULL) { int t = (int)sym->s_value.v_quad; if (t == T_TYPE || t == T_STRUCT_OR_UNION) - debug_printf(" %s", tspec_name(sym->s_tspec)); + debug_printf(" %s", tspec_name(sym->u.s_tspec)); else if (t == T_QUAL) - debug_printf(" %s", tqual_name(sym->s_tqual)); + debug_printf(" %s", tqual_name(sym->u.s_qualifier)); } - debug_word(sym->s_osdef && sym->s_args != NULL, "old-style-args"); + debug_word(sym->s_osdef && sym->u.s_old_style_args != NULL, + "old-style-args"); debug_printf("%s", suffix); } Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.270 src/usr.bin/xlint/lint1/decl.c:1.271 --- src/usr.bin/xlint/lint1/decl.c:1.270 Sat Apr 9 13:22:05 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 13:38:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.270 2022/04/09 13:22:05 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.271 2022/04/09 13:38:17 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.270 2022/04/09 13:22:05 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.271 2022/04/09 13:38:17 rillig Exp $"); #endif #include @@ -1130,7 +1130,8 @@ declarator_1_struct_union(sym_t *dsym) lint_assert(dcs->d_redeclared_symbol->s_scl == MOS || dcs->d_redeclared_symbol->s_scl == MOU); - if (dsym->s_sou_type == dcs->d_redeclared_symbol->s_sou_type) { + if (dsym->u.s_sou_type == + dcs->d_redeclared_symbol->u.s_sou_type) { /* duplicate member name: %s */ error(33, dsym->s_name); rmsym(dcs->d_redeclared_symbol); @@ -1521,7 +1522,7 @@ old_style_function(sym_t *decl, sym_t *a */ if (args != NULL) {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 13:38:17 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c func.c lex.c lint1.h tree.c Log Message: lint: inline member access macros for sym_t Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.270 -r1.271 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.419 -r1.420 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 13:38:15 UTC 2022 Modified Files: src/sys/sys: lwp.h Log Message: sys/lwp.h: Nix trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/sys
Module Name:src Committed By: riastradh Date: Sat Apr 9 13:38:15 UTC 2022 Modified Files: src/sys/sys: lwp.h Log Message: sys/lwp.h: Nix trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/lwp.h diff -u src/sys/sys/lwp.h:1.213 src/sys/sys/lwp.h:1.214 --- src/sys/sys/lwp.h:1.213 Sun Feb 27 01:03:14 2022 +++ src/sys/sys/lwp.h Sat Apr 9 13:38:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lwp.h,v 1.213 2022/02/27 01:03:14 gutteridge Exp $ */ +/* $NetBSD: lwp.h,v 1.214 2022/04/09 13:38:15 riastradh Exp $ */ /* * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010, 2019, 2020 @@ -88,7 +88,7 @@ struct lwp { kmutex_t * volatile l_mutex; /* l: ptr to mutex on sched state */ struct turnstile *l_ts; /* l: current turnstile */ int l_stat; /* l: overall LWP status */ - int l__reserved; /* : padding - reuse as needed */ + int l__reserved; /* : padding - reuse as needed */ /* Scheduling and overall state. */ #define l_startzero l_runq @@ -272,7 +272,7 @@ extern int maxlwp __read_mostly; /* max /* * The second set of flags is kept in l_pflag, and they are modified only by - * the LWP itself, or modified when it's known the LWP cannot be running. + * the LWP itself, or modified when it's known the LWP cannot be running. * LP_RUNNING is typically updated with the LWP locked, but not always in * the case of soft interrupt handlers. */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 13:22:05 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h tree.c Log Message: lint: rename length to length_in_bits No functional change. To generate a diff of this commit: cvs rdiff -u -r1.269 -r1.270 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.152 -r1.153 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.418 -r1.419 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.269 src/usr.bin/xlint/lint1/decl.c:1.270 --- src/usr.bin/xlint/lint1/decl.c:1.269 Fri Apr 8 21:48:19 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 13:22:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.269 2022/04/08 21:48:19 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.270 2022/04/09 13:22:05 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.269 2022/04/08 21:48:19 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.270 2022/04/09 13:22:05 rillig Exp $"); #endif #include @@ -836,11 +836,11 @@ end_type(void) * Return the length of a type in bits. * * Printing a message if the outermost dimension of an array is 0 must - * be done by the caller. All other problems are reported by length() + * be done by the caller. All other problems are reported by this function * if name is not NULL. */ int -length(const type_t *tp, const char *name) +length_in_bits(const type_t *tp, const char *name) { unsigned int elem, elsz; @@ -991,7 +991,7 @@ check_type(sym_t *sym) /* illegal use of 'void' */ error(18); *tpp = gettyp(INT); -#if 0 /* errors are produced by length() */ +#if 0 /* errors are produced by length_in_bits */ } else if (is_incomplete(tp)) { /* array of incomplete type */ if (sflag) { @@ -1150,11 +1150,11 @@ declarator_1_struct_union(sym_t *dsym) } /* - * bit-fields of length 0 are not warned about because length() + * bit-fields of length 0 are not warned about because length_in_bits * does not return the length of the bit-field but the length * of the type the bit-field is packed in (it's ok) */ - if ((sz = length(dsym->s_type, dsym->s_name)) == 0) { + if ((sz = length_in_bits(dsym->s_type, dsym->s_name)) == 0) { if (t == ARRAY && dsym->s_type->t_dim == 0) { /* zero sized array in struct is a C99 extension: %s */ c99ism(39, dsym->s_name); @@ -2483,12 +2483,12 @@ declare_argument(sym_t *sym, bool initfl warning(269, sym->s_name); /* - * Arguments must have complete types. length() prints the needed - * error messages (null dimension is impossible because arrays are - * converted to pointers). + * Arguments must have complete types. length_in_bits prints the + * needed error messages (null dimension is impossible because arrays + * are converted to pointers). */ if (sym->s_type->t_tspec != VOID) - (void)length(sym->s_type, sym->s_name); + (void)length_in_bits(sym->s_type, sym->s_name); sym->s_used = dcs->d_used; mark_as_set(sym); @@ -2983,7 +2983,7 @@ check_size(sym_t *dsym) if (dsym->s_type->t_tspec == FUNC) return; - if (length(dsym->s_type, dsym->s_name) == 0 && + if (length_in_bits(dsym->s_type, dsym->s_name) == 0 && dsym->s_type->t_tspec == ARRAY && dsym->s_type->t_dim == 0) { if (tflag) { /* empty array declaration: %s */ @@ -3291,7 +3291,7 @@ static void check_global_variable_size(const sym_t *sym) { pos_t cpos; - int length_in_bits; + int len_in_bits; if (sym->s_def != TDEF) return; @@ -3302,14 +3302,15 @@ check_global_variable_size(const sym_t * */ return; if (sym->s_def == TDEF && sym->s_type->t_tspec == VOID) - return; /* prevent internal error in length() below */ + return; /* prevent internal error in length_in_bits + * below */ cpos = curr_pos; curr_pos = sym->s_def_pos; - length_in_bits = length(sym->s_type, sym->s_name); + len_in_bits = length_in_bits(sym->s_type, sym->s_name); curr_pos = cpos; - if (length_in_bits == 0 && + if (len_in_bits == 0 && sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) { if (tflag || (sym->s_scl == EXTERN && !sflag)) { /* empty array declaration: %s */ Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.152 src/usr.bin/xlint/lint1/externs1.h:1.153 --- src/usr.bin/xlint/lint1/externs1.h:1.152 Sat Apr 2 17:28:06 2022 +++ src/usr.bin/xlint/lint1/externs1.h Sat Apr 9 13:22:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.152 2022/04/02 17:28:06 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.153 2022/04/09 13:22:05 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -191,7 +191,7 @@ extern void end_declaration_level(void); extern void setasm(void);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Apr 9 13:22:05 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h tree.c Log Message: lint: rename length to length_in_bits No functional change. To generate a diff of this commit: cvs rdiff -u -r1.269 -r1.270 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.152 -r1.153 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.418 -r1.419 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.