Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Mar 2022 10:00:20 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d17c5a4f6215 - stable/13 - LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
Message-ID:  <202203171000.22HA0KWE089787@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=d17c5a4f62157c665ecc187e676d52c07e841923

commit d17c5a4f62157c665ecc187e676d52c07e841923
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-16 14:40:09 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-17 09:55:15 +0000

    LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
    
    Sponsored by:           NVIDIA Networking
    
    (cherry picked from commit c6cf874c7de3bcc092a58a932c732221b2933043)
---
 sys/compat/linuxkpi/common/include/linux/smp.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/smp.h b/sys/compat/linuxkpi/common/include/linux/smp.h
index 290b91469b12..c6d011fceb5f 100644
--- a/sys/compat/linuxkpi/common/include/linux/smp.h
+++ b/sys/compat/linuxkpi/common/include/linux/smp.h
@@ -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);				\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203171000.22HA0KWE089787>