lkpi: allow late binding of linux_alloc_current
Some consumers may be loosely coupled with the lkpi. This allows them to call linux_alloc_current without having a static dependency. Reviewed by: hps@ MFC after: 1 week Sponsored by: iX Systems Differential Revision: https://reviews.freebsd.org/D19257
This commit is contained in:
parent
d97d43310c
commit
983ed4f9f1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344478
@ -41,18 +41,19 @@ struct task_struct;
|
||||
extern int linux_alloc_current(struct thread *, int flags);
|
||||
extern void linux_free_current(struct task_struct *);
|
||||
|
||||
|
||||
static inline void
|
||||
linux_set_current(struct thread *td)
|
||||
{
|
||||
if (__predict_false(td->td_lkpi_task == NULL))
|
||||
linux_alloc_current(td, M_WAITOK);
|
||||
lkpi_alloc_current(td, M_WAITOK);
|
||||
}
|
||||
|
||||
static inline int
|
||||
linux_set_current_flags(struct thread *td, int flags)
|
||||
{
|
||||
if (__predict_false(td->td_lkpi_task == NULL))
|
||||
return (linux_alloc_current(td, flags));
|
||||
return (lkpi_alloc_current(td, flags));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,7 @@ linux_get_pid_task(pid_t pid)
|
||||
static void
|
||||
linux_current_init(void *arg __unused)
|
||||
{
|
||||
lkpi_alloc_current = linux_alloc_current;
|
||||
linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
|
||||
linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
|
||||
}
|
||||
@ -242,7 +243,7 @@ linux_current_uninit(void *arg __unused)
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
sx_sunlock(&allproc_lock);
|
||||
|
||||
EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag);
|
||||
lkpi_alloc_current = linux_alloc_current_noop;
|
||||
}
|
||||
SYSUNINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_uninit, NULL);
|
||||
|
@ -107,6 +107,14 @@ struct thread0_storage thread0_st __aligned(32);
|
||||
struct vmspace vmspace0;
|
||||
struct proc *initproc;
|
||||
|
||||
int
|
||||
linux_alloc_current_noop(struct thread *td __unused, int flags __unused)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
int (*lkpi_alloc_current)(struct thread *, int) = linux_alloc_current_noop;
|
||||
|
||||
|
||||
#ifndef BOOTHOWTO
|
||||
#define BOOTHOWTO 0
|
||||
#endif
|
||||
@ -454,7 +462,7 @@ proc0_init(void *dummy __unused)
|
||||
GIANT_REQUIRED;
|
||||
p = &proc0;
|
||||
td = &thread0;
|
||||
|
||||
|
||||
/*
|
||||
* Initialize magic number and osrel.
|
||||
*/
|
||||
|
@ -237,6 +237,13 @@ void init_param2(long physpages);
|
||||
void init_static_kenv(char *, size_t);
|
||||
void tablefull(const char *);
|
||||
|
||||
/*
|
||||
* Allocate per-thread "current" state in the linuxkpi
|
||||
*/
|
||||
extern int (*lkpi_alloc_current)(struct thread *, int);
|
||||
int linux_alloc_current_noop(struct thread *, int);
|
||||
|
||||
|
||||
#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET)
|
||||
#define critical_enter() critical_enter_KBI()
|
||||
#define critical_exit() critical_exit_KBI()
|
||||
|
Loading…
Reference in New Issue
Block a user