Commit 5b921a06 authored by Philippe Gerum's avatar Philippe Gerum
Browse files

cobalt/kernel: use standard accessor to global pid

parent a7cfe3ba
......@@ -265,7 +265,7 @@ static inline pid_t xnthread_host_pid(struct xnthread *thread)
if (xnthread_test_state(thread, XNROOT))
return 0;
return xnthread_host_task(thread)->pid;
return task_pid_nr(xnthread_host_task(thread));
}
#define xnthread_for_each_claimed(__pos, __thread) \
......
......@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <cobalt/kernel/select.h>
#include <rtdm/fd.h>
#include "internal.h"
......@@ -713,7 +714,7 @@ mq_notify(struct cobalt_mqd *mqd, unsigned index, const struct sigevent *evp)
* receiver's namespaces. We pass the receiver's creds
* into the init namespace instead.
*/
mq->si.si_pid = current->pid;
mq->si.si_pid = task_pid_nr(current);
mq->si.si_uid = get_current_uuid();
}
......
......@@ -33,6 +33,7 @@
#include <linux/cred.h>
#include <linux/file.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/vmalloc.h>
#include <linux/signal.h>
#include <linux/kallsyms.h>
......@@ -1138,17 +1139,20 @@ no_ptrace:
if (!XENO_WARN(COBALT, !xnthread_test_state(next, XNRELAX),
"hardened thread %s[%d] running in Linux domain?! "
"(status=0x%x, sig=%d, prev=%s[%d])",
next->name, next_task->pid, xnthread_get_state(next),
signal_pending(next_task), prev_task->comm, prev_task->pid))
next->name, task_pid_nr(next_task),
xnthread_get_state(next),
signal_pending(next_task),
prev_task->comm, task_pid_nr(prev_task)))
XENO_WARN(COBALT,
!(next_task->ptrace & PT_PTRACED) &&
!xnthread_test_state(next, XNDORMANT)
&& xnthread_test_state(next, XNPEND),
"blocked thread %s[%d] rescheduled?! "
"(status=0x%x, sig=%d, prev=%s[%d])",
next->name, next_task->pid, xnthread_get_state(next),
next->name, task_pid_nr(next_task),
xnthread_get_state(next),
signal_pending(next_task), prev_task->comm,
prev_task->pid);
task_pid_nr(prev_task));
out:
return KEVENT_PROPAGATE;
}
......@@ -1315,13 +1319,13 @@ static int attach_process(struct cobalt_process *process)
if (ret)
return ret;
cobalt_umm_set_name(&p->umm, "private heap[%d]", current->pid);
cobalt_umm_set_name(&p->umm, "private heap[%d]", task_pid_nr(current));
p->mayday_tramp = map_mayday_page();
if (p->mayday_tramp == 0) {
printk(XENO_WARNING
"%s[%d] cannot map MAYDAY page\n",
current->comm, current->pid);
current->comm, task_pid_nr(current));
ret = -ENOMEM;
goto fail_mayday;
}
......@@ -1330,7 +1334,7 @@ static int attach_process(struct cobalt_process *process)
if (IS_ERR(exe_path)) {
printk(XENO_WARNING
"%s[%d] can't find exe path\n",
current->comm, current->pid);
current->comm, task_pid_nr(current));
exe_path = NULL; /* Not lethal, but weird. */
}
p->exe_path = exe_path;
......
......@@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <linux/sched.h>
#include <cobalt/kernel/assert.h>
#include "internal.h"
#include "signal.h"
......@@ -499,7 +500,7 @@ int __cobalt_kill(struct cobalt_thread *thread, int sig, int group) /* nklocked,
sigp->si.si_signo = sig;
sigp->si.si_errno = 0;
sigp->si.si_code = SI_USER;
sigp->si.si_pid = current->pid;
sigp->si.si_pid = task_pid_nr(current);
sigp->si.si_uid = get_current_uuid();
if (cobalt_signal_send(thread, sigp, group) <= 0)
cobalt_signal_free(sigp);
......@@ -558,7 +559,7 @@ int __cobalt_sigqueue(pid_t pid, int sig, const union sigval *value)
sigp->si.si_signo = sig;
sigp->si.si_errno = 0;
sigp->si.si_code = SI_QUEUE;
sigp->si.si_pid = current->pid;
sigp->si.si_pid = task_pid_nr(current);
sigp->si.si_uid = get_current_uuid();
sigp->si.si_value = *value;
if (cobalt_signal_send(thread, sigp, 1) <= 0)
......
......@@ -19,6 +19,7 @@
#include <linux/types.h>
#include <linux/err.h>
#include <linux/ipipe.h>
#include <linux/sched.h>
#include <linux/kconfig.h>
#include <cobalt/uapi/corectl.h>
#include <cobalt/kernel/tree.h>
......@@ -258,7 +259,7 @@ static COBALT_SYSCALL(mayday, current, (void))
if (cur == NULL) {
printk(XENO_WARNING
"MAYDAY received from invalid context %s[%d]\n",
current->comm, current->pid);
current->comm, task_pid_nr(current));
return -EPERM;
}
......@@ -521,7 +522,7 @@ static int handle_head_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
if (XENO_DEBUG(COBALT) && nr != sc_cobalt_get_current)
printk(XENO_WARNING
"syscall <%d> denied to %s[%d]\n",
nr, current->comm, current->pid);
nr, current->comm, task_pid_nr(current));
__xn_error_return(regs, -EPERM);
goto ret_handled;
}
......
......@@ -44,7 +44,7 @@ struct local_thread_hash {
struct local_thread_hash *next;
};
/* System-wide index on task_struct->pid. */
/* System-wide index on task_pid_nr(). */
struct global_thread_hash {
pid_t pid;
struct cobalt_thread *thread;
......
......@@ -20,6 +20,7 @@
#include <linux/workqueue.h>
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/fdtable.h>
#include <linux/anon_inodes.h>
......@@ -108,7 +109,7 @@ open_devnode(struct rtdm_device *dev, const char *path, int oflag)
strncmp(path, "/dev/rtdm/", 10))
printk(XENO_WARNING
"%s[%d] opens obsolete device path: %s\n",
current->comm, current->pid, path);
current->comm, task_pid_nr(current), path);
filename = kasprintf(GFP_KERNEL, "/dev/rtdm/%s", dev->name);
if (filename == NULL)
......
......@@ -20,6 +20,7 @@
#include <linux/list.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/poll.h>
#include <linux/kthread.h>
......@@ -736,7 +737,7 @@ static inline void warn_user(struct file *file, const char *call)
printk(XENO_WARNING
"%s[%d] called regular %s() on /dev/rtdm/%s\n",
current->comm, current->pid, call + 5, dentry->d_name.name);
current->comm, task_pid_nr(current), call + 5, dentry->d_name.name);
}
static ssize_t dumb_read(struct file *file, char __user *buf,
......
......@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/signal.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <cobalt/kernel/sched.h>
#include <cobalt/kernel/thread.h>
#include <cobalt/kernel/timer.h>
......@@ -837,7 +838,7 @@ int ___xnsched_run(struct xnsched *sched)
* leave_root() may not still be the current one. Use
* "current" for disambiguating.
*/
xntrace_pid(current->pid, xnthread_current_priority(curr));
xntrace_pid(task_pid_nr(current), xnthread_current_priority(curr));
reschedule:
switched = 0;
if (!test_resched(sched))
......@@ -897,7 +898,7 @@ reschedule:
*/
curr = sched->curr;
xnthread_switch_fpu(sched);
xntrace_pid(current->pid, xnthread_current_priority(curr));
xntrace_pid(task_pid_nr(current), xnthread_current_priority(curr));
out:
if (switched &&
xnsched_maybe_resched_after_unlocked_switch(sched))
......
......@@ -381,7 +381,7 @@ void __xntimer_init(struct xntimer *timer,
timer->tracker = clock;
#endif
ksformat(timer->name, XNOBJECT_NAME_LEN, "%d/%s",
current->pid, current->comm);
task_pid_nr(current), current->comm);
xntimer_reset_stats(timer);
xnlock_get_irqsave(&nklock, s);
list_add_tail(&timer->next_stat, &clock->timerq);
......
......@@ -26,6 +26,7 @@
#define _TRACE_COBALT_CORE_H
#include <linux/tracepoint.h>
#include <linux/sched.h>
DECLARE_EVENT_CLASS(thread_event,
TP_PROTO(struct xnthread *thread),
......@@ -431,7 +432,7 @@ TRACE_EVENT(cobalt_lostage_request,
TP_fast_assign(
__entry->type = type;
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
),
......@@ -449,7 +450,7 @@ TRACE_EVENT(cobalt_lostage_wakeup,
),
TP_fast_assign(
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
),
......@@ -468,7 +469,7 @@ TRACE_EVENT(cobalt_lostage_signal,
),
TP_fast_assign(
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
__entry->sig = sig;
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
),
......
......@@ -27,6 +27,7 @@
#include <linux/tracepoint.h>
#include <linux/mman.h>
#include <linux/sched.h>
struct rtdm_fd;
struct rtdm_event;
......@@ -70,7 +71,7 @@ DECLARE_EVENT_CLASS(fd_request,
TP_fast_assign(
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
__entry->dev = rtdm_fd_to_context(fd)->device;
__entry->ufd = ufd;
__entry->arg = arg;
......@@ -95,7 +96,7 @@ DECLARE_EVENT_CLASS(fd_request_status,
TP_fast_assign(
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
__entry->dev =
!IS_ERR(fd) ? rtdm_fd_to_context(fd)->device : NULL;
__entry->ufd = ufd;
......@@ -312,7 +313,7 @@ TRACE_EVENT(cobalt_fd_mmap,
TP_fast_assign(
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
__entry->pid = task->pid;
__entry->pid = task_pid_nr(task);
__entry->dev = rtdm_fd_to_context(fd)->device;
__entry->ufd = ufd;
__entry->length = rma->length;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment