From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: [PATCH 5/9] restart: obtain pid_max from /proc/sys/kernel/pid_max
Date: Wed, 26 Jan 2011 11:19:04 -0500 [thread overview]
Message-ID: <1296058748-21418-6-git-send-email-orenl@cs.columbia.edu> (raw)
In-Reply-To: <1296058748-21418-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Signed-off-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
---
restart.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/restart.c b/restart.c
index 9535543..d998834 100644
--- a/restart.c
+++ b/restart.c
@@ -157,6 +157,9 @@ struct ckpt_ctx {
struct cr_restart_args *args;
char *freezer;
+
+ /* system limits */
+ pid_t pid_max;
};
struct pid_swap {
@@ -488,6 +491,9 @@ int process_args(struct cr_restart_args *args)
static void init_ctx(struct ckpt_ctx *ctx)
{
+ FILE *file;
+ char buf[1024];
+
memset(ctx, 0, sizeof(*ctx));
/* mark all fds as unused */
@@ -499,6 +505,15 @@ static void init_ctx(struct ckpt_ctx *ctx)
ctx->pipe_feed[1] = -1;
ctx->pipe_coord[0] = -1;
ctx->pipe_coord[1] = -1;
+
+ /* system limits */
+ ctx->pid_max = SHRT_MAX; /* default */
+ file = fopen("/proc/sys/kernel/pid_max", "r");
+ if (file) {
+ if (fgets(buf, 1024, file))
+ ctx->pid_max = atoi(buf);
+ fclose(file);
+ }
}
static void exit_ctx(struct ckpt_ctx *ctx)
@@ -1212,12 +1227,12 @@ static int ckpt_alloc_pid(struct ckpt_ctx *ctx)
* (this will become inefficient if pid-space is exhausted)
*/
do {
- if (ctx->tasks_pid == INT_MAX)
+ if (ctx->tasks_pid == ctx->pid_max)
ctx->tasks_pid = CKPT_RESERVED_PIDS;
else
ctx->tasks_pid++;
- if (n++ == INT_MAX) { /* ohhh... */
+ if (n++ == ctx->pid_max) { /* ohhh... */
ckpt_err("pid namsepace exhausted");
return -1;
}
--
1.7.1
next prev parent reply other threads:[~2011-01-26 16:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 16:18 [PATCH 0/9] user-cr: support for pids as shared objects Oren Laadan
[not found] ` <1296058748-21418-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2011-01-26 16:19 ` [PATCH 1/9] Initialize of args->{outfd, logfd, infd} in main c/r programs Oren Laadan
[not found] ` <1296058748-21418-2-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2011-01-26 16:24 ` [PATCH 0/9] user-cr: support for pids as shared objects Oren Laadan
2011-01-26 16:19 ` [PATCH 2/9] Introduce ctx->error to improve error reporting Oren Laadan
2011-01-26 16:19 ` [PATCH 3/9] restart: cleanup setup/cleanup of freezer cgroups Oren Laadan
2011-01-26 16:19 ` [PATCH 4/9] restart: make feeder a proper child instead of a thread Oren Laadan
2011-01-26 16:19 ` Oren Laadan [this message]
2011-01-26 16:19 ` [PATCH 6/9] restart: rename 'ctx->tasks_arr' to 'ctx->tasks' Oren Laadan
2011-01-26 16:19 ` [PATCH 7/9] udpate kernel headers: support for pids objects Oren Laadan
2011-01-26 16:19 ` [PATCH 8/9] ckptinfo: s/ckpt_pids/ckpt_task_pids/ after kerenl header update Oren Laadan
2011-01-26 16:19 ` [PATCH 9/9] restart: fix support for nested pid namespaces Oren Laadan
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=1296058748-21418-6-git-send-email-orenl@cs.columbia.edu \
--to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.