From: Kirill Korotaev <dev@sw.ru>
To: Kirill Korotaev <dev@openvz.org>
Cc: serue@us.ibm.com, arjan@infradead.org, frankeh@watson.ibm.com,
clg@fr.ibm.com, haveblue@us.ibm.com, mrmacman_g4@mac.com,
alan@lxorguk.ukuu.org.uk,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
devel@openvz.org
Subject: [RFC][PATCH 3/7] VPIDs: fork modifications
Date: Thu, 02 Feb 2006 19:24:09 +0300 [thread overview]
Message-ID: <43E23229.5070503@sw.ru> (raw)
In-Reply-To: <43E22B2D.1040607@openvz.org>
[-- Attachment #1: Type: text/plain, Size: 214 bytes --]
This patch changes forking procedure. Basically it adds a function
do_fork_pid() that alows forking task with predefined virtual pid.
Also it adds required vpid manipulations on fork().
Simple and straightforward.
[-- Attachment #2: diff-vpids-fork --]
[-- Type: text/plain, Size: 3234 bytes --]
--- ./kernel/fork.c.vpid_fork 2006-02-02 14:33:58.811003152 +0300
+++ ./kernel/fork.c 2006-02-02 14:41:40.806769120 +0300
@@ -871,7 +871,7 @@ static task_t *copy_process(unsigned lon
unsigned long stack_size,
int __user *parent_tidptr,
int __user *child_tidptr,
- int pid)
+ int pid, int vpid)
{
int retval;
struct task_struct *p = NULL;
@@ -932,9 +932,11 @@ static task_t *copy_process(unsigned lon
p->did_exec = 0;
copy_flags(clone_flags, p);
p->pid = pid;
+ if (set_virt_pid(p, alloc_vpid(p->pid, vpid ? : -1)) < 0)
+ goto bad_fork_cleanup_module;
retval = -EFAULT;
if (clone_flags & CLONE_PARENT_SETTID)
- if (put_user(p->pid, parent_tidptr))
+ if (put_user(virt_pid(p), parent_tidptr))
goto bad_fork_cleanup;
p->proc_dentry = NULL;
@@ -985,8 +987,13 @@ static task_t *copy_process(unsigned lon
#endif
p->tgid = p->pid;
- if (clone_flags & CLONE_THREAD)
+ set_virt_tgid(p, virt_pid(p));
+ set_virt_pgid(p, virt_pgid(current));
+ set_virt_sid(p, virt_sid(current));
+ if (clone_flags & CLONE_THREAD) {
p->tgid = current->tgid;
+ set_virt_tgid(p, virt_tgid(current));
+ }
if ((retval = security_task_alloc(p)))
goto bad_fork_cleanup_policy;
@@ -1181,6 +1188,9 @@ bad_fork_cleanup_cpuset:
#endif
cpuset_exit(p);
bad_fork_cleanup:
+ if (virt_pid(p) != p->pid && virt_pid(p) > 0)
+ free_vpid(virt_pid(p));
+bad_fork_cleanup_module:
if (p->binfmt)
module_put(p->binfmt->module);
bad_fork_cleanup_put_domain:
@@ -1206,7 +1216,7 @@ task_t * __devinit fork_idle(int cpu)
task_t *task;
struct pt_regs regs;
- task = copy_process(CLONE_VM, 0, idle_regs(®s), 0, NULL, NULL, 0);
+ task = copy_process(CLONE_VM, 0, idle_regs(®s), 0, NULL, NULL, 0, 0);
if (!task)
return ERR_PTR(-ENOMEM);
init_idle(task, cpu);
@@ -1236,12 +1246,12 @@ static inline int fork_traceflag (unsign
* It copies the process, and if successful kick-starts
* it and waits for it to finish using the VM if required.
*/
-long do_fork(unsigned long clone_flags,
+static long do_fork_pid(unsigned long clone_flags,
unsigned long stack_start,
struct pt_regs *regs,
unsigned long stack_size,
int __user *parent_tidptr,
- int __user *child_tidptr)
+ int __user *child_tidptr, int vpid)
{
struct task_struct *p;
int trace = 0;
@@ -1255,7 +1265,8 @@ long do_fork(unsigned long clone_flags,
clone_flags |= CLONE_PTRACE;
}
- p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);
+ p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr,
+ child_tidptr, pid, vpid);
/*
* Do this prior waking up the new thread - the thread pointer
* might get invalid after that point, if the thread exits quickly.
@@ -1298,6 +1309,17 @@ long do_fork(unsigned long clone_flags,
return pid;
}
+long do_fork(unsigned long clone_flags,
+ unsigned long stack_start,
+ struct pt_regs *regs,
+ unsigned long stack_size,
+ int __user *parent_tidptr,
+ int __user *child_tidptr)
+{
+ return do_fork_pid(clone_flags, stack_start, regs, stack_size,
+ parent_tidptr, child_tidptr, 0);
+}
+
#ifndef ARCH_MIN_MMSTRUCT_ALIGN
#define ARCH_MIN_MMSTRUCT_ALIGN 0
#endif
next prev parent reply other threads:[~2006-02-02 16:22 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-02 15:54 [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach) Kirill Korotaev
2006-02-02 16:16 ` [RFC][PATCH 1/7] VPIDs: add VPID config option Kirill Korotaev
2006-02-02 16:21 ` [RFC][PATCH 2/7] VPIDs: pid/vpid conversions Kirill Korotaev
2006-02-08 20:29 ` Eric W. Biederman
2006-02-08 23:53 ` Alexey Kuznetsov
2006-02-09 0:37 ` Eric W. Biederman
2006-02-09 1:11 ` Alexey Kuznetsov
2006-02-09 1:36 ` Eric W. Biederman
2006-02-09 2:51 ` Serge E. Hallyn
2006-02-09 9:55 ` Alexey Kuznetsov
2006-02-09 19:22 ` Eric W. Biederman
2006-02-20 14:57 ` Kirill Korotaev
2006-02-20 16:56 ` Herbert Poetzl
2006-02-21 16:19 ` Kirill Korotaev
2006-02-21 23:17 ` Herbert Poetzl
2006-02-02 16:24 ` Kirill Korotaev [this message]
2006-02-02 20:08 ` [RFC][PATCH 3/7] VPIDs: fork modifications Cedric Le Goater
2006-02-02 16:26 ` [RFC][PATCH 4/7] VPIDs: vpid macros in non-VPID case Kirill Korotaev
2006-02-02 16:30 ` [RFC][PATCH 5/7] VPIDs: vpid/pid conversion in VPID enabled case Kirill Korotaev
2006-02-02 17:05 ` Dave Hansen
2006-02-02 19:29 ` Serge E. Hallyn
2006-02-03 10:52 ` Alexey Kuznetsov
2006-02-03 12:48 ` Cedric Le Goater
2006-02-03 14:02 ` Alexey Kuznetsov
2006-02-03 16:25 ` Dave Hansen
2006-02-06 11:24 ` Alexey Kuznetsov
2006-02-03 17:05 ` Cedric Le Goater
2006-02-06 9:48 ` Alexey Kuznetsov
2006-02-06 14:51 ` Serge E. Hallyn
2006-02-06 15:51 ` Alexey Kuznetsov
2006-02-06 16:24 ` Serge E. Hallyn
2006-02-07 9:46 ` Cedric Le Goater
2006-02-07 11:44 ` Kirill Korotaev
2006-02-07 12:59 ` Cedric Le Goater
2006-02-07 9:15 ` Cedric Le Goater
2006-02-03 14:05 ` Kirill Korotaev
2006-02-03 15:40 ` Cedric Le Goater
2006-02-03 16:28 ` Kirill Korotaev
2006-02-02 16:31 ` [RFC][PATCH 6/7] VPIDs: small proc VPID export Kirill Korotaev
2006-02-02 16:33 ` [RFC][PATCH 7/7] VPIDs: required VPS interface for VPIDs Kirill Korotaev
2006-02-03 3:01 ` [RFC][PATCH] VPIDs: Virtualization of PIDs (OpenVZ approach) Herbert Poetzl
2006-02-03 10:30 ` Kirill Korotaev
2006-02-03 12:45 ` Alexey Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43E23229.5070503@sw.ru \
--to=dev@sw.ru \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjan@infradead.org \
--cc=clg@fr.ibm.com \
--cc=dev@openvz.org \
--cc=devel@openvz.org \
--cc=frankeh@watson.ibm.com \
--cc=haveblue@us.ibm.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mrmacman_g4@mac.com \
--cc=serue@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox