From owner-dev-commits-src-branches@freebsd.org  Mon Feb  1 12:40:47 2021
Return-Path: <owner-dev-commits-src-branches@freebsd.org>
Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id 652E04FE970;
 Mon,  1 Feb 2021 12:40:47 +0000 (UTC) (envelope-from git@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 4DTnbz1tTNz3F0R;
 Mon,  1 Feb 2021 12:40:47 +0000 (UTC) (envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:5])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 797271B696;
 Mon,  1 Feb 2021 12:40:43 +0000 (UTC) (envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
 by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 111Cehi2094846;
 Mon, 1 Feb 2021 12:40:43 GMT (envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
 by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 111CehGE094845;
 Mon, 1 Feb 2021 12:40:43 GMT (envelope-from git)
Date: Mon, 1 Feb 2021 12:40:43 GMT
Message-Id: <202102011240.111CehGE094845@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
 dev-commits-src-branches@FreeBSD.org
From: Mateusz Guzik <mjg@FreeBSD.org>
Subject: git: e92ab3adf4f9 - stable/13 - atomic: make atomic_store_ptr
 type-aware
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: mjg
X-Git-Repository: src
X-Git-Refname: refs/heads/stable/13
X-Git-Reftype: branch
X-Git-Commit: e92ab3adf4f9848933439c9c2fca36df290c0884
Auto-Submitted: auto-generated
X-BeenThere: dev-commits-src-branches@freebsd.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Commits to the stable branches of the FreeBSD src repository
 <dev-commits-src-branches.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-branches>, 
 <mailto:dev-commits-src-branches-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-branches/>
List-Post: <mailto:dev-commits-src-branches@freebsd.org>
List-Help: <mailto:dev-commits-src-branches-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-branches>, 
 <mailto:dev-commits-src-branches-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Feb 2021 12:40:47 -0000

The branch stable/13 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=e92ab3adf4f9848933439c9c2fca36df290c0884

commit e92ab3adf4f9848933439c9c2fca36df290c0884
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-01-25 19:39:14 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-02-01 12:39:16 +0000

    atomic: make atomic_store_ptr type-aware
    
    (cherry picked from commit cc96f92a570e05636a20fdd15d4616b127bb9ecc)
---
 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c | 2 +-
 sys/fs/tmpfs/tmpfs_subr.c                             | 6 ++----
 sys/sys/_cscan_atomic.h                               | 5 ++++-
 sys/sys/atomic_common.h                               | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c
index f9a0820eda2d..d9f2635b0129 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c
@@ -444,7 +444,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
 	zp->z_blksz = blksz;
 	zp->z_seq = 0x7A4653;
 	zp->z_sync_cnt = 0;
-	atomic_store_ptr((uintptr_t *)&zp->z_cached_symlink, (uintptr_t)NULL);
+	atomic_store_ptr(&zp->z_cached_symlink, NULL);
 
 	vp = ZTOV(zp);
 
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 07e7ea11ad6e..3b3581fc81f6 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -360,8 +360,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount *tmp, enum vtype type,
 		 * TODO: Since there is no load consume primitive provided
 		 * right now, the load is performed with an acquire fence.
 		 */
-		atomic_store_ptr((uintptr_t *)&nnode->tn_link_target,
-		    (uintptr_t)symlink);
+		atomic_store_ptr(&nnode->tn_link_target, symlink);
 		atomic_store_char((char *)&nnode->tn_link_smr, symlink_smr);
 		atomic_thread_fence_rel();
 		break;
@@ -453,8 +452,7 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct tmpfs_node *node,
 
 	case VLNK:
 		symlink = node->tn_link_target;
-		atomic_store_ptr((uintptr_t *)&node->tn_link_target,
-		    (uintptr_t)NULL);
+		atomic_store_ptr(&node->tn_link_target, NULL);
 		if (atomic_load_char(&node->tn_link_smr)) {
 			cache_symlink_free(symlink, node->tn_size + 1);
 		} else {
diff --git a/sys/sys/_cscan_atomic.h b/sys/sys/_cscan_atomic.h
index 19c05b179940..3bd9455102b1 100644
--- a/sys/sys/_cscan_atomic.h
+++ b/sys/sys/_cscan_atomic.h
@@ -243,7 +243,10 @@ void	kcsan_atomic_thread_fence_seq_cst(void);
 #define	atomic_subtract_ptr		kcsan_atomic_subtract_ptr
 #define	atomic_subtract_acq_ptr		kcsan_atomic_subtract_acq_ptr
 #define	atomic_subtract_rel_ptr		kcsan_atomic_subtract_rel_ptr
-#define	atomic_store_ptr		kcsan_atomic_store_ptr
+#define	atomic_store_ptr(x, v)		({					\
+	__typeof(*x) __value = (v);						\
+	kcsan_atomic_store_ptr((volatile uintptr_t *)(x), (uintptr_t)(__value));\
+})
 #define	atomic_store_rel_ptr		kcsan_atomic_store_rel_ptr
 #define	atomic_swap_ptr			kcsan_atomic_swap_ptr
 #define	atomic_testandclear_ptr		kcsan_atomic_testandclear_ptr
diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h
index a3548977b940..4c29d132c369 100644
--- a/sys/sys/atomic_common.h
+++ b/sys/sys/atomic_common.h
@@ -58,7 +58,7 @@
 #define	atomic_store_long(p, v)		\
     (*(volatile u_long *)(p) = (u_long)(v))
 #define	atomic_store_ptr(p, v)		\
-    (*(volatile uintptr_t *)(p) = (uintptr_t)(v))
+    (*(volatile __typeof(*p) *)(p) = (v))
 #define	atomic_store_8(p, v)		\
     (*(volatile uint8_t *)(p) = (uint8_t)(v))
 #define	atomic_store_16(p, v)		\