aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/sched.h
Commit message (Collapse)AuthorAgeFilesLines
* 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