LinuxKPI: Add comment describing proper use of the on_each_cpu() function.

MFC after:		1 week
Sponsored by:		NVIDIA Networking
This commit is contained in:
Hans Petter Selasky 2022-03-16 15:40:09 +01:00
parent 4bbc8ee29e
commit c6cf874c7d

View File

@ -29,6 +29,18 @@
#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); \