Date: Tue, 4 Aug 2020 14:44:16 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363836 - head/sys/compat/linuxkpi/common/include/linux Message-ID: <202008041444.074EiGKo018963@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Tue Aug 4 14:44:16 2020 New Revision: 363836 URL: https://svnweb.freebsd.org/changeset/base/363836 Log: linuxkpi: Add kref_put_lock Same as kref_put but in addition to calling the rel function it will acquire the lock first. Sponsored by: The FreeBSD Foundation Reviewed by: hselasky, emaste Differential Revision: https://reviews.freebsd.org/D25942 Modified: head/sys/compat/linuxkpi/common/include/linux/kref.h Modified: head/sys/compat/linuxkpi/common/include/linux/kref.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/kref.h Tue Aug 4 14:42:38 2020 (r363835) +++ head/sys/compat/linuxkpi/common/include/linux/kref.h Tue Aug 4 14:44:16 2020 (r363836) @@ -38,6 +38,7 @@ #include <linux/compiler.h> #include <linux/kernel.h> #include <linux/mutex.h> +#include <linux/refcount.h> #include <asm/atomic.h> @@ -76,6 +77,20 @@ kref_put(struct kref *kref, void (*rel)(struct kref *k } return 0; } + +static inline int +kref_put_lock(struct kref *kref, void (*rel)(struct kref *kref), + spinlock_t *lock) +{ + + if (refcount_release(&kref->refcount.counter)) { + spin_lock(lock); + rel(kref); + return (1); + } + return (0); +} + static inline int kref_sub(struct kref *kref, unsigned int count,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008041444.074EiGKo018963>