History log of /freebsd-current/sys/compat/linuxkpi/common/include/linux/sched.h
Revision Date Author Comments
# db65db64 10-Feb-2024 Vladimir Kondratyev <wulf@FreeBSD.org>

Revert "LinuxKPI: Add explicit software context to FPU sections"

kmalloc() support within FPU sections will be redone in other way.

This reverts commit 5a3bd281672bd6bd8e18081c3928dfe76d330a5f.

Sponsored by: Serenity Cyber Security, LLC
Requested by: jhb


# 5a3bd281 24-Dec-2023 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Add explicit software context to FPU sections

Amdgpu driver does a lot of memory allocations in FPU-protected sections
of code for certain display cores, e.g. for DCN30. This does not work
currently on FreeBSD as its malloc function can not be run within a
critical section. Allocate memory for FPU context to overcome such
restriction.

Sponsored by: Serenity Cyber Security, LLC
Reviewed by: manu (previous version), markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42822


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 8c46bd9f 30-Dec-2022 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Include `linux/sched/mm.h` from `linux/sched.h`

At least one file in the DRM drivers benefits from some namespace
pollution to use `fs_reclaim_acquire()`/`fs_reclaim_release()`. They are
defined in `linux/sched/mm.h` and this header must be included
indirectly into the DRM drivers' source file.

I couldn't find how it was included. Therefore this commit includes
`linux/sched/mm.h` from `linux/sched.h`. This is not the case in Linux
but fixes the issue with the DRM drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37912


# f04f3afb 28-Jul-2022 Konstantin Belousov <kib@FreeBSD.org>

linuxkpi: more precise need_resched() definition

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35888


# c6d31b83 18-Jul-2022 Konstantin Belousov <kib@FreeBSD.org>

AST: rework

Make most AST handlers dynamically registered. This allows to have
subsystem-specific handler source located in the subsystem files,
instead of making subr_trap.c aware of it. For instance, signal
delivery code on return to userspace is now moved to kern_sig.c.

Also, it allows to have some handlers designated as the cleanup (kclear)
type, which are called both at AST and on thread/process exit. For
instance, ast(), exit1(), and NFS server no longer need to be aware
about UFS softdep processing.

The dynamic registration also allows third-party modules to register AST
handlers if needed. There is one caveat with loadable modules: the
code does not make any effort to ensure that the module is not unloaded
before all threads processed through AST handler in it. In fact, this
is already present behavior for hwpmc.ko and ufs.ko. I do not think it
is worth the efforts and the runtime overhead to try to fix it.

Reviewed by: markj
Tested by: emaste (arm64), pho
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35888


# 0093bc3c 17-May-2022 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Implement sched_set_fifo(_low) functions

Required by: drm-kmod

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35050


# 1ebd7aee 17-May-2022 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Add some pollution required by drm-kmod to linux/sched.h

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35050


# 41559beb 17-May-2022 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Fix typo in cond_resched_lock

Lock must be released rather than acquired around mi_switch call.

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35048


# 9b801654 21-Mar-2022 Emmanuel Vadot <manu@FreeBSD.org>

linuxkpi: Add cond_resched_lock

If we need to resched it takes the lock, resched, release the lock
and returns 1, otherwise simply returns 0.

Needed by drm v5.9

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34620


# 307f78f3 19-Dec-2021 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards

MFC after: 1 week
Reviewed by: bz, emaste, hselasky, manu
Differential Revision: https://reviews.freebsd.org/D33562


# 7ec6cbf1 03-Dec-2021 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Convert schedule() to inlined function

to prevent name clashing with drm-kmod

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D33294


# 469884cf 31-Jul-2021 Hans Petter Selasky <hselasky@FreeBSD.org>

LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.

Reviewed by: kib
Submitted by: greg@unrelenting.technology
Differential Revision: https://reviews.freebsd.org/D29921
MFC after: 1 week
Sponsored by: NVIDIA Networking


# 17777208 28-Mar-2021 Hans Petter Selasky <hselasky@FreeBSD.org>

Reduce chance of RCU deadlock in the LinuxKPI by implementing the section
feature of the concurrency kit, CK.

Differential Revision: https://reviews.freebsd.org/D29467
Reviewed by: kib@ and markj@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking


# 6ae24079 10-Aug-2020 Hans Petter Selasky <hselasky@FreeBSD.org>

Need to clone the task struct fields related to RCU aswell in the
LinuxKPI after r359727. This fixes a minor regression issue. Else the
priority tracking won't work properly when both sleepable and
non-sleepable RCU is in use on the same thread.

Bump the __FreeBSD_version to force recompilation of external kernel
modules.

PR: 242272
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 07e0a3ca 16-May-2019 Johannes Lundberg <johalun@FreeBSD.org>

LinuxKPI: Add group_leader member to struct task_struct.

Assign self as group leader at creation to act as the only member of a
new process group.
This patch is part of D19565

Reviewed by: hps
Approved by: imp (mentor), hps
MFC after: 1 week


# 5746b1cd 13-Mar-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement task_euid() and get_task_state() function macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies


# c7486758 13-Mar-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement get_task_comm() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies


# 638fa5a3 13-Mar-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement current_exiting() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies


# 549dcdb3 06-Aug-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement current_work() function in the LinuxKPI.

Tested by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 5a1d03bb 05-Jun-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement the task_pid_vnr() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks


# 666cda9e 28-May-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

The schedule_timeout_killable() function should listen for signals
in the LinuxKPI.

Found by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 94944062 22-Feb-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Return correct error code to user-space when a system call receives a
signal in the LinuxKPI.

The read(), write() and mmap() system calls can return either EINTR or
ERESTART upon receiving a signal. Add code to figure out the correct
return value by temporarily storing the return code from the relevant
FreeBSD kernel APIs in the Linux task structure.

MFC after: 3 days
Sponsored by: Mellanox Technologies


# cb57d1dd 31-Jan-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Properly implement the cond_resched() function macro in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# ef925749 11-Nov-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Remove release and acquire semantics when accessing the "state" field of the
LinuxKPI task struct. Change type of "state" variable from "int" to
"atomic_t" to simplify code and avoid unneccessary casting.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# c0589825 07-Aug-2017 Mark Johnston <markj@FreeBSD.org>

Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI.

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11871


# 8cd823ec 08-Jul-2017 Mark Johnston <markj@FreeBSD.org>

Add TASK_COMM_LEN to the LinuxKPI.

MFC after: 1 week


# 8504aa98 18-Jun-2017 Mark Johnston <markj@FreeBSD.org>

Add kthread parking support to the LinuxKPI.

Submitted by: kmacy (original version)
Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11264


# 4eb18346 18-Jun-2017 Mark Johnston <markj@FreeBSD.org>

Avoid including list.h in LinuxKPI headers.

list.h includes a number of FreeBSD headers as a workaround for the
LIST_HEAD name collision. To reduce pollution, avoid including list.h
in commonly used headers when it is not explicitly needed.

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11249


# 46565964 09-Jun-2017 Mark Johnston <markj@FreeBSD.org>

Augment wait queue support in the LinuxKPI.

In particular:
- Don't evaluate event conditions with a sleepqueue lock held, since such
code may attempt to acquire arbitrary locks.
- Fix the return value for wait_event_interruptible() in the case that the
wait is interrupted by a signal.
- Implement wait_on_bit_timeout() and wait_on_atomic_t().
- Implement some functions used to test for pending signals.
- Implement a number of wait_event_*() variants and unify the existing
implementations.
- Unify the mechanism used by wait_event_*() and schedule() to put the
calling thread to sleep.

This is required to support updated DRM drivers. Thanks to hselasky for
finding and fixing a number of bugs in the original revision.

Reviewed by: hselasky
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10986


# f3de9af6 19-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix problem regarding priority inversion when using the concurrency
kit, CK, in the LinuxKPI.

When threads are pinned to a CPU core or when there is only one CPU,
it can happen that a higher priority thread can call the CK
synchronize function while a lower priority thread holds the read
lock. Because the CK's synchronize is a simple wait loop this can lead
to a deadlock situation. To solve this problem use the recently
introduced CK's wait callback function.

When detecting a CK blocking condition figure out the lowest priority
among the blockers and update the calling thread's priority and
yield. If another CPU core is holding the read lock, pin the thread to
the blocked CPU core and update the priority. The calling threads
priority and CPU bindings are restored before return.

If a thread holding a CK read lock is detected to be sleeping, pause()
will be used instead of yield().

MFC after: 1 week
Sponsored by: Mellanox Technologies


# 22cbd6ef 07-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Create the LinuxKPI current task structure on the fly if it doesn't
exist when the current macro is used.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# c9dd0b48 06-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Cleanup the bitmap_xxx() functions in the LinuxKPI:

- Move all bitmap related functions from bitops.h to bitmap.h, similar
to what Linux does.

- Apply some minor code cleanup and simplifications to optimize the
generated code when using static inline functions.

- Implement the following list of bitmap functions which are needed by
drm-next and ibcore:
- bitmap_find_next_zero_area_off()
- bitmap_find_next_zero_area()
- bitmap_or()
- bitmap_and()
- bitmap_xor()

- Add missing include directives to the qlnxe driver
(davidcs@ has been notified)

MFC after: 1 week
Sponsored by: Mellanox Technologies


# fc51649e 06-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement need_resched() in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 8402f058 06-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix implementation of task_pid_group_leader() in the LinuxKPI.

In FreeBSD thread IDs and procedure IDs have distinct number
spaces. When asking for the group leader task ID in the LinuxKPI,
return the procedure ID and let this resolve to the first task in the
procedure having a valid LinuxKPI task structure pointer.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# a0699ebf 17-Mar-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement get_pid_task(), pid_task() and some other PID helper
functions in the LinuxKPI. Add a usage atomic to the task_struct
structure to facilitate refcounting the task structure when returned
from get_pid_task(). The get_task_struct() and put_task_struct()
function is used to manage atomic refcounting. After this change the
task_struct should only be freed through put_task_struct().

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 05d4f501 17-Mar-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement minimalistic memory mapping structure, struct mm_struct, and
some associated helper functions in the LinuxKPI. Let the existing
linux_alloc_current() function allocate and initialize the new
structure and let linux_free_current() drop the refcount on the memory
mapping structure. When the mm_struct's refcount reaches zero, the
structure is freed.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# b8a8ed7c 15-Mar-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Define some more LinuxKPI task related macros.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 1e3db1de 20-Feb-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Make the LinuxKPI task struct persistent accross system calls.

A set of helper functions have been added to manage the life of the
LinuxKPI task struct. When an external system call or task is invoked,
a check is made to create the task struct by demand. A thread
destructor callback is registered to free the task struct when a
thread exits to avoid memory leaks.

This change lays the ground for emulating the Linux kernel more
closely which is a dependency by the code using the LinuxKPI APIs.

Add new dedicated td_lkpi_task field has been added to struct thread
instead of abusing td_retval[1].

Fix some header file inclusions to make LINT kernel build properly
after this change.

Bump the __FreeBSD_version to force a rebuild of all kernel modules.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# 85714218 25-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI can
run after a panic(). This for example allows a LinuxKPI based graphics
stack to receive prints during a panic.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 3a8bec33 12-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix handling of IOCTLs in the LinuxKPI.

Linux requires that all IOCTL data resides in userspace. FreeBSD
always moves the main IOCTL structure into a kernel buffer before
invoking the IOCTL handler and then copies it back into userspace,
before returning. Hide this difference in the "linux_copyin()" and
"linux_copyout()" functions by remapping userspace addresses in the
range from 0x10000 to 0x20000, to the kernel IOCTL data buffer.

It is assumed that the userspace code, data and stack segments starts
no lower than memory address 0x400000, which is also stated by "man 1
ld", which means any valid userspace pointer can be passed to regular
LinuxKPI handled IOCTLs.

Bump the FreeBSD version to force recompilation of all kernel modules.

Discussed with: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 464d20bc 12-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Create a dummy "task_struct" on the stack which is returned by
"current" inside all LinuxKPI file operation callbacks. The "current"
is frequently used for various debug prints, printing the thread name
and thread ID for example.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 8d59ecb2 29-Oct-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Finish process of moving the LinuxKPI module into the default kernel build.

- Move all files related to the LinuxKPI into sys/compat/linuxkpi and
its subfolders.
- Update sys/conf/files and some Makefiles to use new file locations.
- Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn
adds the LinuxKPI to all LINT builds.
- The LinuxKPI can be added to the kernel by setting the
COMPAT_LINUXKPI option. The OFED kernel option no longer builds the
LinuxKPI into the kernel. This was done to keep the build rules for
the LinuxKPI in sys/conf/files simple.
- Extend the LinuxKPI module to include support for USB by moving the
Linux USB compat from usb.ko to linuxkpi.ko.
- Bump the FreeBSD_version.
- A universe kernel build has been done.

Reviewed by: np @ (cxgb and cxgbe related changes only)
Sponsored by: Mellanox Technologies