Home » Mailing lists » Devel » [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach)
[RFC][PATCH 2/7] VPIDs: pid/vpid conversions [message #1155 is a reply to message #1153] |
Thu, 02 February 2006 16:21   |
dev
Messages: 1693 Registered: September 2005 Location: Moscow
|
Senior Member |

|
|
This is one of the major patches,
it adds vpid-to-pid conversions by placing macros
introduced in diff-vpid-macro patch.
Note that in CONFIG_VIRTUAL_PIDS=n case these macros expand to default code.
Kirill
--- ./drivers/char/tty_io.c.vpid_core 2006-02-02 14:15:33.271070768 +0300
+++ ./drivers/char/tty_io.c 2006-02-02 14:33:58.795005584 +0300
@@ -2366,7 +2366,7 @@ static int tiocgpgrp(struct tty_struct *
*/
if (tty == real_tty && current->signal->tty != real_tty)
return -ENOTTY;
- return put_user(real_tty->pgrp, p);
+ return put_user(pid_type_to_vpid(PIDTYPE_PGID, real_tty->pgrp), p);
}
static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
@@ -2386,6 +2386,9 @@ static int tiocspgrp(struct tty_struct *
return -EFAULT;
if (pgrp < 0)
return -EINVAL;
+ pgrp = vpid_to_pid(pgrp);
+ if (pgrp < 0)
+ return -EPERM;
if (session_of_pgrp(pgrp) != current->signal->session)
return -EPERM;
real_tty->pgrp = pgrp;
@@ -2402,7 +2405,7 @@ static int tiocgsid(struct tty_struct *t
return -ENOTTY;
if (real_tty->session <= 0)
return -ENOTTY;
- return put_user(real_tty->session, p);
+ return put_user(pid_type_to_vpid(PIDTYPE_SID, real_tty->session), p);
}
static int tiocsetd(struct tty_struct *tty, int __user *p)
--- ./fs/binfmt_elf.c.vpid_core 2006-02-02 14:15:34.478887152 +0300
+++ ./fs/binfmt_elf.c 2006-02-02 14:33:58.797005280 +0300
@@ -1276,10 +1276,10 @@ static void fill_prstatus(struct elf_prs
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_sigpend = p->pending.signal.sig[0];
prstatus->pr_sighold = p->blocked.sig[0];
- prstatus->pr_pid = p->pid;
- prstatus->pr_ppid = p->parent->pid;
- prstatus->pr_pgrp = process_group(p);
- prstatus->pr_sid = p->signal->session;
+ prstatus->pr_pid = virt_pid(p);
+ prstatus->pr_ppid = virt_pid(p->parent);
+ prstatus->pr_pgrp = virt_pgid(p);
+ prstatus->pr_sid = virt_sid(p);
if (thread_group_leader(p)) {
/*
* This is the record for the group leader. Add in the
@@ -1322,10 +1322,10 @@ static int fill_psinfo(struct elf_prpsin
psinfo->pr_psargs[i] = ' ';
psinfo->pr_psargs[len] = 0;
- psinfo->pr_pid = p->pid;
- psinfo->pr_ppid = p->parent->pid;
- psinfo->pr_pgrp = process_group(p);
- psinfo->pr_sid = p->signal->session;
+ psinfo->pr_pid = virt_pid(p);
+ psinfo->pr_ppid = virt_pid(p->parent);
+ psinfo->pr_pgrp = virt_pgid(p);
+ psinfo->pr_sid = virt_sid(p);
i = p->state ? ffz(~p->state) + 1 : 0;
psinfo->pr_state = i;
--- ./fs/exec.c.vpid_core 2006-02-02 14:15:55.352713848 +0300
+++ ./fs/exec.c 2006-02-02 14:33:58.799004976 +0300
@@ -1282,7 +1282,7 @@ static void format_corename(char *corena
case 'p':
pid_in_pattern = 1;
rc = snprintf(out_ptr, out_end - out_ptr,
- "%d", current->tgid);
+ "%d", virt_tgid(current));
if (rc > out_end - out_ptr)
goto out;
out_ptr += rc;
@@ -1354,7 +1354,7 @@ static void format_corename(char *corena
if (!pid_in_pattern
&& (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1)) {
rc = snprintf(out_ptr, out_end - out_ptr,
- ".%d", current->tgid);
+ ".%d", virt_tgid(current));
if (rc > out_end - out_ptr)
goto out;
out_ptr += rc;
--- ./fs/fcntl.c.vpid_core 2006-02-02 14:15:34.521880616 +0300
+++ ./fs/fcntl.c 2006-02-02 14:33:58.800004824 +0300
@@ -251,6 +251,7 @@ static int setfl(int fd, struct file * f
static void f_modown(struct file *filp, unsigned long pid,
uid_t uid, uid_t euid, int force)
{
+ pid = comb_vpid_to_pid(pid);
write_lock_irq(&filp->f_owner.lock);
if (force || !filp->f_owner.pid) {
filp->f_owner.pid = pid;
@@ -317,7 +318,7 @@ static long do_fcntl(int fd, unsigned in
* current syscall conventions, the only way
* to fix this will be in libc.
*/
- err = filp->f_owner.pid;
+ err = comb_pid_to_vpid(filp->f_owner.pid);
force_successful_syscall_return();
break;
case F_SETOWN:
--- ./fs/locks.c.vpid_core 2006-02-02 14:15:34.551876056 +0300
+++ ./fs/locks.c 2006-02-02 14:33:58.801004672 +0300
@@ -1573,7 +1573,7 @@ int fcntl_getlk(struct file *filp, struc
flock.l_type = F_UNLCK;
if (fl != NULL) {
- flock.l_pid = fl->fl_pid;
+ flock.l_pid = pid_type_to_vpid(PIDTYPE_TGID, fl->fl_pid);
#if BITS_PER_LONG == 32
/*
* Make sure we can represent the posix lock via
@@ -1727,7 +1727,7 @@ int fcntl_getlk64(struct file *filp, str
flock.l_type = F_UNLCK;
if (fl != NULL) {
- flock.l_pid = fl->fl_pid;
+ flock.l_pid = pid_type_to_vpid(PIDTYPE_TGID, fl->fl_pid);
flock.l_start = fl->fl_start;
flock.l_len = fl->fl_end == OFFSET_MAX ? 0 :
fl->fl_end - fl->fl_start + 1;
--- ./fs/proc/array.c.vpid_core 2006-02-02 14:15:34.661859336 +0300
+++ ./fs/proc/array.c 2006-02-02 14:33:58.802004520 +0300
@@ -174,9 +174,10 @@ static inline char * task_state(struct t
"Gid:\t%d\t%d\t%d\t%d\n",
get_task_state(p),
(p->sleep_avg/1024)*100/(1020000000/1024),
- p->tgid,
- p->pid, pid_alive(p) ? p->group_leader->real_parent->tgid : 0,
- pid_alive(p) && p->ptrace ? p->parent->pid : 0,
+ get_task_tgid(p),
+ get_task_pid(p),
+ get_task_ppid(p),
+ pid_alive(p) && p->ptrace ? get_task_pid(p->parent) : 0,
p->uid, p->euid, p->suid, p->fsuid,
p->gid, p->egid, p->sgid, p->fsgid);
read_unlock(&tasklist_lock);
@@ -370,11 +371,12 @@ static int do_task_stat(struct task_stru
}
if (task->signal) {
if (task->signal->tty) {
- tty_pgrp = task->signal->tty->pgrp;
+ tty_pgrp = pid_type_to_vpid(PIDTYPE_PGID,
+ task->signal->tty->pgrp);
tty_nr = new_encode_dev(tty_devnum(task->signal->tty));
}
- pgid = process_group(task);
- sid = task->signal->session;
+ pgid = get_task_pgid(task);
+ sid = get_task_sid(task);
cmin_flt = task->signal->cmin_flt;
cmaj_flt = task->signal->cmaj_flt;
cutime = task->signal->cutime;
@@ -388,7 +390,7 @@ static int do_task_stat(struct task_stru
}
it_real_value = task->signal->real_timer.expires;
}
- ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0;
+ ppid = get_task_ppid(task);
read_unlock(&tasklist_lock);
if (!whole || num_threads<2)
@@ -415,7 +417,7 @@ static int do_task_stat(struct task_stru
res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
%lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu \
%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n",
- task->pid,
+ get_task_pid(task),
tcomm,
state,
ppid,
--- ./fs/proc/base.c.vpid_core 2006-02-02 14:15:34.662859184 +0300
+++ ./fs/proc/base.c 2006-02-02 14:33:58.804004216 +0300
@@ -1879,14 +1879,14 @@ static int proc_self_readlink(struct den
int buflen)
{
char tmp[30];
- sprintf(tmp, "%d", current->tgid);
+ sprintf(tmp, "%d", get_task_tgid(current));
return vfs_readlink(dentry,buffer,buflen,tmp);
}
static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
{
char tmp[30];
- sprintf(tmp, "%d", current->tgid);
+ sprintf(tmp, "%d", get_task_tgid(current));
return ERR_PTR(vfs_follow_link(nd,tmp));
}
@@ -2134,7 +2134,7 @@ static int get_tid_list(int index, unsig
* via next_thread().
*/
if (pid_alive(task)) do {
- int tid = task->pid;
+ int tid = get_task_pid(task);
if (--index >= 0)
continue;
--- ./include/net/scm.h.vpid_core 2006-01-03 06:21:10.000000000 +0300
+++ ./include/net/scm.h 2006-02-02 14:33:58.805004064 +0300
@@ -40,7 +40,7 @@ static __inline__ int scm_send(struct so
memset(scm, 0, sizeof(*scm));
scm->creds.uid = current->uid;
scm->creds.gid = current->gid;
- scm->creds.pid = current->tgid;
+ scm->creds.pid = virt_tgid(current);
if (msg->msg_controllen <= 0)
return 0;
return __scm_send(sock, msg, scm);
--- ./ipc/msg.c.vpid_core 2006-02-02 14:15:35.148785312 +0300
+++ ./ipc/msg.c 2006-02-02 14:33:58.806003912 +0300
@@ -540,7 +540,7 @@ static inline int pipelined_send(struct
msr->r_msg = ERR_PTR(-E2BIG);
} else {
msr->r_msg = NULL;
- msq->q_lrpid = msr->r_tsk->pid;
+ msq->q_lrpid = virt_pid(msr->r_tsk);
msq->q_rtime = get_seconds();
wake_up_process(msr->r_tsk);
smp_mb();
@@ -622,7 +622,7 @@ asmlinkage long sys_msgsnd (int msqid, s
}
}
- msq->q_lspid = current->tgid;
+ msq->q_lspid = virt_tgid(current);
msq->q_stime = get_seconds();
if(!pipelined_send(msq,msg)) {
@@ -718,7 +718,7 @@ asmlinkage long sys_msgrcv (int msqid, s
list_del(&msg->m_list);
msq->q_qnum--;
msq->q_rtime = get_seconds();
- msq->q_lrpid = current->tgid;
+ msq->q_lrpid = virt_tgid(current);
msq->q_cbytes -= msg->m_ts;
atomic_sub(msg->m_ts,&msg_bytes);
atomic_dec(&msg_hdrs);
--- ./ipc/sem.c.vpid_core 2006-02-02 14:15:35.149785160 +0300
+++ ./ipc/sem.c 2006-02-02 14:33:58.807003760 +0300
@@ -743,7 +743,7 @@ static int semctl_main(int semid, int se
for (un = sma->undo; un; un = un->id_next)
un->semadj[semnum] = 0;
curr->semval = val;
- curr->sempid = current->tgid;
+ curr->sempid = virt_tgid(current);
sma->sem_ctime = get_seconds();
/* maybe some queued-up processes were waiting for this */
update_queue(sma);
@@ -1135,7 +1135,7 @@ retry_undos:
if (error)
goto out_unlock_free;
- error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
+ error = try_atomic_semop (sma, sops, nsops, un, virt_tgid(current));
if (error <
...
|
|
|
 |
|
[RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach)
|
 |
|
[RFC][PATCH 1/7] VPIDs: add VPID config option
By: dev on Thu, 02 February 2006 16:16
|
 |
|
[RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: dev on Thu, 02 February 2006 16:21
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: ebiederm on Wed, 08 February 2006 20:29
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: ebiederm on Thu, 09 February 2006 00:37
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: ebiederm on Thu, 09 February 2006 01:36
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: serue on Thu, 09 February 2006 02:51
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: ebiederm on Thu, 09 February 2006 19:22
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: dev on Mon, 20 February 2006 14:55
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
By: dev on Tue, 21 February 2006 16:17
|
 |
|
Re: [RFC][PATCH 2/7] VPIDs: pid/vpid conversions
|
 |
|
[RFC][PATCH 3/7] VPIDs: fork modifications
By: dev on Thu, 02 February 2006 16:24
|
 |
|
Re: [RFC][PATCH 3/7] VPIDs: fork modifications
|
 |
|
[RFC][PATCH 4/7] VPIDs: vpid macros in non-VPID case
|
 |
|
[RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
By: serue on Thu, 02 February 2006 19:29
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
By: serue on Mon, 06 February 2006 14:51
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
By: serue on Mon, 06 February 2006 16:24
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
By: dev on Tue, 07 February 2006 11:42
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
By: dev on Fri, 03 February 2006 14:03
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
Re: [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case
|
 |
|
[RFC][PATCH 6/7] VPIDs: small proc VPID export
|
 |
|
[RFC][PATCH 7/7] VPIDs: required VPS interface for VPIDs
|
 |
|
Re: [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach)
|
 |
|
Re: [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach)
|
 |
|
Re: [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach)
|
Goto Forum:
Current Time: Sat Aug 30 18:58:44 GMT 2025
Total time taken to generate the page: 0.08184 seconds
|