aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/sched.h
Commit message (Collapse)AuthorAgeFilesLines
* LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.Hans Petter Selasky2021-07-311-1/+2
| | | | | | | | Reviewed by: kib Submitted by: greg@unrelenting.technology Differential Revision: https://reviews.freebsd.org/D29921 MFC after: 1 week Sponsored by: NVIDIA Networking
* Reduce chance of RCU deadlock in the LinuxKPI by implementing the sectionHans Petter Selasky2021-03-291-0/+1
| | | | | | | | | 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
* Need to clone the task struct fields related to RCU aswell in theHans Petter Selasky2020-08-111-2/+3
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=364109
* LinuxKPI: Add group_leader member to struct task_struct.Johannes Lundberg2019-05-161-0/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=347843
* Implement task_euid() and get_task_state() function macros in the LinuxKPI.Hans Petter Selasky2019-03-131-0/+2
| | | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Limelight Networks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=345100
* Implement get_task_comm() in the LinuxKPI.Hans Petter Selasky2019-03-131-0/+8
| | | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Limelight Networks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=345099
* Implement current_exiting() in the LinuxKPI.Hans Petter Selasky2019-03-131-0/+5
| | | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Limelight Networks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=345098
* Implement current_work() function in the LinuxKPI.Hans Petter Selasky2018-08-061-0/+2
| | | | | | | | | Tested by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337376
* Implement the task_pid_vnr() function macro in the LinuxKPI.Hans Petter Selasky2018-06-051-0/+1
| | | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Notes: svn path=/head/; revision=334661
* The schedule_timeout_killable() function should listen for signalsHans Petter Selasky2018-05-281-1/+1
| | | | | | | | | | | in the LinuxKPI. Found by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=334283
* Return correct error code to user-space when a system call receives aHans Petter Selasky2018-02-221-2/+17
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=329825
* Properly implement the cond_resched() function macro in the LinuxKPI.Hans Petter Selasky2018-01-311-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=328623
* Remove release and acquire semantics when accessing the "state" field of theHans Petter Selasky2017-11-111-4/+3
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=325708
* Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI.Mark Johnston2017-08-081-2/+13
| | | | | | | | | Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11871 Notes: svn path=/head/; revision=322213
* Add TASK_COMM_LEN to the LinuxKPI.Mark Johnston2017-07-081-0/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=320810
* Add kthread parking support to the LinuxKPI.Mark Johnston2017-06-181-0/+1
| | | | | | | | | | Submitted by: kmacy (original version) Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11264 Notes: svn path=/head/; revision=320078
* Avoid including list.h in LinuxKPI headers.Mark Johnston2017-06-181-1/+0
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=320072
* Augment wait queue support in the LinuxKPI.Mark Johnston2017-06-091-51/+44
| | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=319757
* Fix problem regarding priority inversion when using the concurrencyHans Petter Selasky2017-04-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=317137
* Create the LinuxKPI current task structure on the fly if it doesn'tHans Petter Selasky2017-04-071-1/+5
| | | | | | | | | | exist when the current macro is used. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=316609
* Cleanup the bitmap_xxx() functions in the LinuxKPI:Hans Petter Selasky2017-04-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=316568
* Implement need_resched() in the LinuxKPI.Hans Petter Selasky2017-04-061-0/+2
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=316564
* Fix implementation of task_pid_group_leader() in the LinuxKPI.Hans Petter Selasky2017-04-061-2/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=316563
* Implement get_pid_task(), pid_task() and some other PID helperHans Petter Selasky2017-03-171-5/+22
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315457
* Implement minimalistic memory mapping structure, struct mm_struct, andHans Petter Selasky2017-03-171-0/+2
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315443
* Define some more LinuxKPI task related macros.Hans Petter Selasky2017-03-161-0/+6
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=315410
* Make the LinuxKPI task struct persistent accross system calls.Hans Petter Selasky2017-02-211-29/+16
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314040
* Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI canHans Petter Selasky2016-05-251-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=300671
* Fix handling of IOCTLs in the LinuxKPI.Hans Petter Selasky2016-05-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=299530
* Create a dummy "task_struct" on the stack which is returned byHans Petter Selasky2016-05-121-5/+14
| | | | | | | | | | | | | "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 Notes: svn path=/head/; revision=299526
* Finish process of moving the LinuxKPI module into the default kernel build.Hans Petter Selasky2015-10-291-0/+126
- 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 Notes: svn path=/head/; revision=290135