linuxkpi: improvements for linux_pid_task() and linux_get_pid_task().
Unify functions bodies. Do not call tdfind() if pid is passed, and do not call pfind() if tid is supplied. Reviewed by: hselasky Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25534
This commit is contained in:
parent
4bc5ce2c74
commit
f334f212d9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362886
@ -155,65 +155,52 @@ linuxkpi_thread_dtor(void *arg __unused, struct thread *td)
|
|||||||
put_task_struct(ts);
|
put_task_struct(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct task_struct *
|
static struct task_struct *
|
||||||
linux_pid_task(pid_t pid)
|
linux_get_pid_task_int(pid_t pid, const bool do_get)
|
||||||
{
|
{
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
|
struct task_struct *ts;
|
||||||
|
|
||||||
/* try to find corresponding thread */
|
if (pid > PID_MAX) {
|
||||||
td = tdfind(pid, -1);
|
/* try to find corresponding thread */
|
||||||
if (td != NULL) {
|
td = tdfind(pid, -1);
|
||||||
struct task_struct *ts = td->td_lkpi_task;
|
if (td != NULL) {
|
||||||
PROC_UNLOCK(td->td_proc);
|
ts = td->td_lkpi_task;
|
||||||
return (ts);
|
if (do_get && ts != NULL)
|
||||||
}
|
get_task_struct(ts);
|
||||||
|
PROC_UNLOCK(td->td_proc);
|
||||||
/* try to find corresponding procedure */
|
return (ts);
|
||||||
p = pfind(pid);
|
}
|
||||||
if (p != NULL) {
|
} else {
|
||||||
FOREACH_THREAD_IN_PROC(p, td) {
|
/* try to find corresponding procedure */
|
||||||
struct task_struct *ts = td->td_lkpi_task;
|
p = pfind(pid);
|
||||||
if (ts != NULL) {
|
if (p != NULL) {
|
||||||
PROC_UNLOCK(p);
|
FOREACH_THREAD_IN_PROC(p, td) {
|
||||||
return (ts);
|
ts = td->td_lkpi_task;
|
||||||
}
|
if (ts != NULL) {
|
||||||
|
if (do_get)
|
||||||
|
get_task_struct(ts);
|
||||||
|
PROC_UNLOCK(p);
|
||||||
|
return (ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PROC_UNLOCK(p);
|
||||||
}
|
}
|
||||||
PROC_UNLOCK(p);
|
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct task_struct *
|
||||||
|
linux_pid_task(pid_t pid)
|
||||||
|
{
|
||||||
|
return (linux_get_pid_task_int(pid, false));
|
||||||
|
}
|
||||||
|
|
||||||
struct task_struct *
|
struct task_struct *
|
||||||
linux_get_pid_task(pid_t pid)
|
linux_get_pid_task(pid_t pid)
|
||||||
{
|
{
|
||||||
struct thread *td;
|
return (linux_get_pid_task_int(pid, true));
|
||||||
struct proc *p;
|
|
||||||
|
|
||||||
/* try to find corresponding thread */
|
|
||||||
td = tdfind(pid, -1);
|
|
||||||
if (td != NULL) {
|
|
||||||
struct task_struct *ts = td->td_lkpi_task;
|
|
||||||
if (ts != NULL)
|
|
||||||
get_task_struct(ts);
|
|
||||||
PROC_UNLOCK(td->td_proc);
|
|
||||||
return (ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* try to find corresponding procedure */
|
|
||||||
p = pfind(pid);
|
|
||||||
if (p != NULL) {
|
|
||||||
FOREACH_THREAD_IN_PROC(p, td) {
|
|
||||||
struct task_struct *ts = td->td_lkpi_task;
|
|
||||||
if (ts != NULL) {
|
|
||||||
get_task_struct(ts);
|
|
||||||
PROC_UNLOCK(p);
|
|
||||||
return (ts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PROC_UNLOCK(p);
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user