Module: xenomai-3
Branch: wip/prioceil
Commit: 5b921a067208271525fa2226bd8e4bf23809c8ca
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5b921a067208271525fa2226bd8e4bf23809c8ca

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Mar  2 16:03:24 2016 +0100

cobalt/kernel: use standard accessor to global pid

---

 include/cobalt/kernel/thread.h    |    2 +-
 kernel/cobalt/posix/mqueue.c      |    3 ++-
 kernel/cobalt/posix/process.c     |   18 +++++++++++-------
 kernel/cobalt/posix/signal.c      |    5 +++--
 kernel/cobalt/posix/syscall.c     |    5 +++--
 kernel/cobalt/posix/thread.c      |    2 +-
 kernel/cobalt/rtdm/core.c         |    3 ++-
 kernel/cobalt/rtdm/fd.c           |    3 ++-
 kernel/cobalt/sched.c             |    5 +++--
 kernel/cobalt/timer.c             |    2 +-
 kernel/cobalt/trace/cobalt-core.h |    7 ++++---
 kernel/cobalt/trace/cobalt-rtdm.h |    7 ++++---
 12 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index e08a0a2..b45de8e 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -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)             \
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index 0f5e19e..77dabce 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -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();
        }
 
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 5b80521..28fde9e 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -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;
diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index dc16bc8..a3ec756 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -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)
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index dd4dfba..f7cde92 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -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;
        }
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 70e4c70..d87edb1 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -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;
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 0ec8169..0f68e77 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -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)
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index eacc1cc..d82cfe4 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -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,
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 033b124..7cb91a5 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -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))
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index ee16198..114c2ed 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -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);
diff --git a/kernel/cobalt/trace/cobalt-core.h 
b/kernel/cobalt/trace/cobalt-core.h
index d9875b9..dde5da3 100644
--- a/kernel/cobalt/trace/cobalt-core.h
+++ b/kernel/cobalt/trace/cobalt-core.h
@@ -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);
        ),
diff --git a/kernel/cobalt/trace/cobalt-rtdm.h 
b/kernel/cobalt/trace/cobalt-rtdm.h
index 5113f92..d548a0b 100644
--- a/kernel/cobalt/trace/cobalt-rtdm.h
+++ b/kernel/cobalt/trace/cobalt-rtdm.h
@@ -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;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to