]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
authorHans Petter Selasky <hselasky@FreeBSD.org>
Wed, 16 Mar 2022 14:40:09 +0000 (15:40 +0100)
committerHans Petter Selasky <hselasky@FreeBSD.org>
Thu, 17 Mar 2022 12:26:31 +0000 (13:26 +0100)
Sponsored by: NVIDIA Networking
Approved by: re (gjb)

(cherry picked from commit c6cf874c7de3bcc092a58a932c732221b2933043)
(cherry picked from commit d17c5a4f62157c665ecc187e676d52c07e841923)

sys/compat/linuxkpi/common/include/linux/smp.h

index 290b91469b12c82b75a0f02255e48ff9a5667249..c6d011fceb5f04804304bcc033f02d5d9defa693 100644 (file)
 #ifndef _LINUXKPI_LINUX_SMP_H_
 #define        _LINUXKPI_LINUX_SMP_H_
 
+/*
+ * Important note about the use of the function provided below:
+ *
+ * The callback function passed to on_each_cpu() is called from a
+ * so-called critical section, and if you need a mutex you will have
+ * to rewrite the code to use native FreeBSD mtx spinlocks instead of
+ * the spinlocks provided by the LinuxKPI! Be very careful to not call
+ * any LinuxKPI functions inside the on_each_cpu()'s callback
+ * function, because they may sleep, unlike in native Linux.
+ *
+ * Enabling witness(4) when testing, can catch such issues.
+ */
 #define        on_each_cpu(cb, data, wait) ({                          \
        CTASSERT(wait);                                         \
        linux_on_each_cpu(cb, data);                            \