From nobody Tue Jun 04 11:35:32 2024 X-Original-To: dev-commits-src-all@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 4VtpS4343fz5NHPy; Tue, 04 Jun 2024 11:35: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 4VtpS42QTRz4NtZ; Tue, 4 Jun 2024 11:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717500932; 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=7JQS9fk4uhdbSjEM+ASgE/EVEzpfo5vTe4BM+czCqBw=; b=PJqAGfHhD4A6jrLoLKrzxvqBckjTFPrzrSPI+4sTuyp3076mH9xQo1X7k5BxC+bh+lUIDP hmK91lrrCPKEOnOLoeeip1NZ3yCm7+4Z/0MyyRJSCcPGGQDPyM5+1qOQXFBGPUHDVc/GYe BKDLtTDTamOv57FjxBegAFJ3IMM4xw3zzFx/nbtwdpLLDCCdQvrWNAnDvK0GrAKjxPpKt0 Ps0Q1g0/LDzW3d0jRSNhPXNg0sb508pRb+pTaBVCHOW0F2pSGeDDtr9ka81cpsIOU7UAGb jfPlRmeyEonj2vC+He0+m0T8QxP6urJ1emos1HZDizNixh2fBzOLTzgLTU1MQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717500932; a=rsa-sha256; cv=none; b=OS0zDlrLGdRakWFJkz6sbm9JmRlGClNEFn5Wkyw5jo+e9CMwujO9Xudq586MyS2dkdsHHW /NeQhaelEMH72pJn1VrLK5hD2WU/NwOwya/ftYj4CAUgFHSmJMQkWmX85UImlXO/bWJAUT 77r+JhxHv6qkpdYUIK3CM7NTSV8AdYWWB+LL1YStclWgpUgmBqlD1bLOlxh13TugKrgCbz byFae7JQ4sfwvO6iTw7fBbJtycTzQjDw4bah8iNC5dU4Vjngo3JHUZ9TB7/MXYIq0dAdFS gM5mjGCp4rrEXyHwDac4z/sAfr4HX9Mu4XnO8WpZ5S33wJgEg+kTKxSs0d7AbQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717500932; 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=7JQS9fk4uhdbSjEM+ASgE/EVEzpfo5vTe4BM+czCqBw=; b=NwBKYb8VWZbUKqUAwdHjIGRZe8D7mAKJBO53x6blPPYf8af5K9/bkz0m0+6DL81QoH+FM4 daLY0OrBNr+HGQIzcH3d0kZkCQnLys22RDA0KCRFx9VQH8vz3ro+Tv4UW64GsrxafdNmOm J5tmDp/Y+U+ctSV9TMD5+Vw9M0oyOM/wGmg0U0hj+sKJ7YTievCvR1cEwuKMUnkM1c2PyV u3d5JjCBuSI50BSUYybfUxRU8f27WXRqukveLriHrCyfKaBn+1qCVvVIhcspgr4YCE9Ez+ FvmWhRSWNSio6xlUvww8O9pXj/Mkr9B83akmMFzZj3tbhnqR/cyoH9neTUdTSg== 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 4VtpS41xPMzHXg; Tue, 4 Jun 2024 11:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 454BZWZ9011607; Tue, 4 Jun 2024 11:35:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 454BZWMJ011604; Tue, 4 Jun 2024 11:35:32 GMT (envelope-from git) Date: Tue, 4 Jun 2024 11:35:32 GMT Message-Id: <202406041135.454BZWMJ011604@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: f85181b036c4 - stable/14 - linuxkpi: refcount: Use atomic_t directly List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f85181b036c49cf45d507c186e4f8de74f3884d2 Auto-Submitted: auto-generated The branch stable/14 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=f85181b036c49cf45d507c186e4f8de74f3884d2 commit f85181b036c49cf45d507c186e4f8de74f3884d2 Author: Emmanuel Vadot AuthorDate: 2024-05-15 09:50:51 +0000 Commit: Emmanuel Vadot CommitDate: 2024-06-04 11:23:34 +0000 linuxkpi: refcount: Use atomic_t directly Simply use a typedef for refcount_t on atomic_t, this allow us to use a nativ type and also changing struct kref to directly use a refcount_t like Linux. Reviewed by: bz Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D45207 (cherry picked from commit abb1a1340e3f0dcdbb81b5c42ad304f02c812e20) --- sys/compat/linuxkpi/common/include/linux/kref.h | 3 +-- .../linuxkpi/common/include/linux/refcount.h | 23 ++++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kref.h b/sys/compat/linuxkpi/common/include/linux/kref.h index 47d61c9ee316..b2fba468f7df 100644 --- a/sys/compat/linuxkpi/common/include/linux/kref.h +++ b/sys/compat/linuxkpi/common/include/linux/kref.h @@ -41,8 +41,7 @@ #include struct kref { - /* XXX In Linux this is a refcount_t */ - atomic_t refcount; + refcount_t refcount; }; static inline void diff --git a/sys/compat/linuxkpi/common/include/linux/refcount.h b/sys/compat/linuxkpi/common/include/linux/refcount.h index 61947485945d..02a7eda3f4a9 100644 --- a/sys/compat/linuxkpi/common/include/linux/refcount.h +++ b/sys/compat/linuxkpi/common/include/linux/refcount.h @@ -31,58 +31,51 @@ #include -struct refcount_linux { - atomic_t value; -}; -typedef struct refcount_linux refcount_t; +typedef atomic_t refcount_t; static inline void refcount_set(refcount_t *ref, unsigned int i) { - atomic_set(&ref->value, i); + atomic_set(ref, i); } static inline void refcount_inc(refcount_t *ref) { - atomic_inc(&ref->value); + atomic_inc(ref); } static inline bool refcount_inc_not_zero(refcount_t *ref) { - return (atomic_inc_not_zero(&ref->value)); + return (atomic_inc_not_zero(ref)); } static inline void refcount_dec(refcount_t *ref) { - atomic_dec(&ref->value); + atomic_dec(ref); } static inline unsigned int refcount_read(refcount_t *ref) { - return atomic_read(&ref->value); + return atomic_read(ref); } static inline bool refcount_dec_and_lock_irqsave(refcount_t *ref, spinlock_t *lock, unsigned long *flags) { - if (atomic_dec_and_test(&ref->value) == true) { + if (atomic_dec_and_test(ref) == true) { spin_lock_irqsave(lock, flags); return (true); } return (false); } -/* - * struct kref uses atomic_t and not refcount_t so - * we differ from Linux here. - */ static inline bool -refcount_dec_and_test(atomic_t *r) +refcount_dec_and_test(refcount_t *r) { return (atomic_dec_and_test(r));