From nobody Sat Jan 22 19:36:27 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 26EA1196B924; Sat, 22 Jan 2022 19:36:32 +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 4Jh61p1rQdz3R3q; Sat, 22 Jan 2022 19:36:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gzvgIMdkcCdKiyRDarjRO7RRhPH5ZinKs/0o/hAgYvA=; b=XjOUf9WU8nwJ8GpNKjmP0+X68F98PQ1XfQavrFL3xOqzVCY+32KHkD9dY7EsmEArN4gtf/ J9yvMHEpRI7TJtN6BmExo3Z9G8yq2o5PMZqycAiA0z5BNTXNEvOKM4GaL4sphGOsO577Jg DLsgc2lfI7t4FM6sl4gvFpis+YZInhxRWwA8npfwdjzEHryakmiK+yXIa5i4DaM2wndQs9 mkvKK8guHxg2fUXLknFlqDBsF/J1ADOJJH/2iTrCKcfHt/oVEFYJAU8JAmRcKAJuYKk4e1 kga+aDMDVfsuuhNHgqP8WbkCVbNpNEWrEMwmAV6j1Iq63M7IIZGfL6EXNRF/PA== 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 4F73014CCC; Sat, 22 Jan 2022 19:36:27 +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 20MJaRqE000141; Sat, 22 Jan 2022 19:36:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20MJaRol000140; Sat, 22 Jan 2022 19:36:27 GMT (envelope-from git) Date: Sat, 22 Jan 2022 19:36:27 GMT Message-Id: <202201221936.20MJaRol000140@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: b4f5d92c8849 - stable/13 - LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_* List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b4f5d92c88496e45bf7353e12120205c1c720565 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gzvgIMdkcCdKiyRDarjRO7RRhPH5ZinKs/0o/hAgYvA=; b=UR35KkhT5NGAyEvlgzYFcPh2YiP1rs+Bdt8OyxmG7Z/G6smq33ToYoTiLcMihTiIeMnzcd r/kA51gOv1LDZMpZsyLEkpzgy5z1YvCHwPr28W6DLqxVbEXaZVjCWPks2UyE9wKvhLfu4s IlC7M1rj4/6UOgYMx8WHqpUMC2Wemfs0I1XDJW4JWtiT69BQ3VEgc9RfWSM9m7U0p4HipR t28pfGo5qw6BPSi5cAXVZZGJCC9G4rnaktVWh9gSmWkBok1uv5k87Ey4m6secEzoKmedez 68FrcU3/RNA/ikVwGgE2RUiSFsem8F3i+0sejSbeMxz6XGk5UjXIGl0kpudICA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642880191; a=rsa-sha256; cv=none; b=uLMI6xCAAqfZ2OQzMLtohmtIdnfeemYUooFC6W4l4jnr6uANrgEh3G/uOgGijajcxvEQH0 FuBtP+9glC2tR21ya9fOjRJjlYYDr4541XPk7F5WTDUABvxWIS/xgCWLlKaIUAW7DEqxsG wFTNVO5OAu2CY6HGzIU2CBHM5ziazCiLi0AxazHsV/SK2oBx7rriW0aZ027v24XIQUg7YH Q7b+NmCf1mH+lfIyRcxlPishyiq1SXi3O9t35HlRKisMKEswrNB9jwQYd0efXgnYHaDTLS PHdaY8fp7V8LbDcHBLtoRzkuOFiwJT7me+DrJe/LQjdnfXyPG1tn0T7cKd1XFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b4f5d92c88496e45bf7353e12120205c1c720565 commit b4f5d92c88496e45bf7353e12120205c1c720565 Author: Vladimir Kondratyev AuthorDate: 2021-07-04 14:13:09 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-22 19:34:36 +0000 LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_* for x86 and move them to asm/barrier.h MFC after: 1 week Reviewed by: bz, hselasky, manu Differential Revision: https://reviews.freebsd.org/D33296 (cherry picked from commit 2fb5be7978c27505c02b667a21ce3a79f72e2091) --- sys/compat/linuxkpi/common/include/asm/barrier.h | 58 ++++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/atomic.h | 1 + .../linuxkpi/common/include/linux/compiler.h | 1 - 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/asm/barrier.h b/sys/compat/linuxkpi/common/include/asm/barrier.h new file mode 100644 index 000000000000..10aa24a7ae8b --- /dev/null +++ b/sys/compat/linuxkpi/common/include/asm/barrier.h @@ -0,0 +1,58 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Vladimir Kondratyev + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ASM_BARRIER_H_ +#define _ASM_BARRIER_H_ + +#include +#include + +#include +#include + +/* TODO: Check other archs for atomic_thread_fence_* useability */ +#if defined(__amd64__) || defined(__i386__) +#define smp_mb() atomic_thread_fence_seq_cst() +#define smp_wmb() atomic_thread_fence_rel() +#define smp_rmb() atomic_thread_fence_acq() +#define smp_store_mb(x, v) do { (void)xchg(&(x), v); } while (0) +#endif + +#ifndef smp_mb +#define smp_mb() mb() +#endif +#ifndef smp_wmb +#define smp_wmb() wmb() +#endif +#ifndef smp_rmb +#define smp_rmb() rmb() +#endif +#ifndef smp_store_mb +#define smp_store_mb(x, v) do { WRITE_ONCE(x, v); smp_mb(); } while (0) +#endif + +#endif /* _ASM_BARRIER_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/atomic.h b/sys/compat/linuxkpi/common/include/linux/atomic.h index f8aa5c9276e7..969af384e3ba 100644 --- a/sys/compat/linuxkpi/common/include/linux/atomic.h +++ b/sys/compat/linuxkpi/common/include/linux/atomic.h @@ -32,5 +32,6 @@ #include #include #include +#include #endif /* _LINUX_ATOMIC_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h index e641b1b096c3..c4c189c2505f 100644 --- a/sys/compat/linuxkpi/common/include/linux/compiler.h +++ b/sys/compat/linuxkpi/common/include/linux/compiler.h @@ -80,7 +80,6 @@ #define __printf(a,b) __printflike(a,b) #define barrier() __asm__ __volatile__("": : :"memory") -#define smp_mb() mb() #define lower_32_bits(n) ((u32)(n)) #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))