Date: Tue, 20 Jul 2021 23:46:21 GMT From: Vladimir Kondratyev <wulf@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 71d815861f1c - stable/13 - LinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave Message-ID: <202107202346.16KNkLBt054582@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=71d815861f1cd0281443a216998c23000fb4b301 commit 71d815861f1cd0281443a216998c23000fb4b301 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2021-07-05 00:19:01 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2021-07-20 22:43:52 +0000 LinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave On Linux atomic_dec_and_lock_irqsave is a wrapper macro which provides a reference to third parameter rather than parameter value itself to implementation routine called _atomic_dec_and_lock_irqsave [1]. While here, implement a fast path. [1] https://github.com/torvalds/linux/blob/master/include/linux/spinlock.h#L476 Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D30781 (cherry picked from commit c77ec79b57aa92b428b940ed550a4a14ed44da48) --- sys/compat/linuxkpi/common/include/linux/spinlock.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h index 458d8d9f8da9..56eaecfb4cd6 100644 --- a/sys/compat/linuxkpi/common/include/linux/spinlock.h +++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h @@ -168,15 +168,20 @@ spin_lock_destroy(spinlock_t *lock) mtx_assert(&(_l)->m, MA_OWNED); \ } while (0) +#define atomic_dec_and_lock_irqsave(cnt, lock, flags) \ + _atomic_dec_and_lock_irqsave(cnt, lock, &(flags)) static inline int -atomic_dec_and_lock_irqsave(atomic_t *cnt, spinlock_t *lock, - unsigned long flags) +_atomic_dec_and_lock_irqsave(atomic_t *cnt, spinlock_t *lock, + unsigned long *flags) { - spin_lock_irqsave(lock, flags); + if (atomic_add_unless(cnt, -1, 1)) + return (0); + + spin_lock_irqsave(lock, *flags); if (atomic_dec_and_test(cnt)) - return 1; - spin_unlock_irqrestore(lock, flags); - return 0; + return (1); + spin_unlock_irqrestore(lock, *flags); + return (0); } #endif /* _LINUX_SPINLOCK_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107202346.16KNkLBt054582>