From: Zheng Li <dev@zheng.li>
To: xen-devel@lists.xenproject.org
Cc: Dave Scott <Dave.Scott@citrix.com>, Joe Jin <joe.jin@oracle.com>,
"Luis R. Rodriguez" <mcgrof@suse.com>,
Luonengjun <luonengjun@huawei.com>, Zheng Li <dev@zheng.li>,
Fanhenglong <fanhenglong@huawei.com>,
"Liuqiming (John)" <john.liuqiming@huawei.com>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: [PATCH v2 2/8] oxenstored: add facilities to raise the max open fds uplimit
Date: Tue, 16 Sep 2014 10:31:31 +0100 [thread overview]
Message-ID: <1410859897-31563-3-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1410859897-31563-1-git-send-email-dev@zheng.li>
To go beyond 1024 fds, we also need to raise the process limitation on max
open fds (usually defaults to 1024).
We need to know the system level max open fds so that we won't go above that.
Simply setting the limit to RLIM_INFINITY doesn't work on Linux 3.x (EPERM), a
patch on this went into the 2.x branch but not 3.x for some reason.
Signed-off-by: Zheng Li <dev@zheng.li>
---
tools/ocaml/xenstored/select.ml | 10 ++++++++++
tools/ocaml/xenstored/select_stubs.c | 12 ++++++++++++
2 files changed, 22 insertions(+)
diff --git a/tools/ocaml/xenstored/select.ml b/tools/ocaml/xenstored/select.ml
index 3f4b671..ab8c847 100644
--- a/tools/ocaml/xenstored/select.ml
+++ b/tools/ocaml/xenstored/select.ml
@@ -23,6 +23,16 @@ type event = {
}
external select_on_poll: (Unix.file_descr * event) array -> int -> int = "stub_select_on_poll"
+external set_fd_limit: int -> unit = "stub_set_fd_limit"
+
+(* The rlim_max given to setrlimit must not go above the system level nr_open,
+ which we can read from /proc/sys. *)
+let get_sys_fs_nr_open () =
+ try
+ let ch = open_in "/proc/sys/fs/nr_open" in
+ let v = int_of_string (input_line ch) in
+ close_in_noerr ch; v
+ with _ -> 1024 * 1024
let init_event () = {read = false; write = false; except = false}
diff --git a/tools/ocaml/xenstored/select_stubs.c b/tools/ocaml/xenstored/select_stubs.c
index 33beeb9..4a8edb5 100644
--- a/tools/ocaml/xenstored/select_stubs.c
+++ b/tools/ocaml/xenstored/select_stubs.c
@@ -66,3 +66,15 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
CAMLreturn(Val_int(rc));
}
+
+
+CAMLprim value stub_set_fd_limit(value limit) {
+
+ CAMLparam1(limit);
+ struct rlimit rl;
+
+ rl.rlim_cur = rl.rlim_max = Int_val(limit);
+ if (setrlimit(RLIMIT_NOFILE, &rl) != 0) uerror("setrlimit", Nothing);
+ CAMLreturn(Val_unit);
+
+}
--
2.1.0
next prev parent reply other threads:[~2014-09-16 17:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 9:31 Some oxenstored improvements (v2) Zheng Li
2014-09-16 9:31 ` [PATCH v2 1/8] oxenstored: add a poll-based select mechanism Zheng Li
2014-09-16 9:31 ` Zheng Li [this message]
2014-09-16 9:31 ` [PATCH v2 3/8] oxenstored: add a --use-select command line flag Zheng Li
2014-09-16 9:31 ` [PATCH v2 4/8] oxenstored: catch the error when a connection is already deleted Zheng Li
2014-09-16 9:31 ` [PATCH v2 5/8] oxenstored: use hash table to store socket connections Zheng Li
2014-09-16 9:31 ` [PATCH v2 6/8] oxenstored: enable domain connection indexing based on eventchn port Zheng Li
2014-09-16 9:31 ` [PATCH v2 7/8] oxenstored: only process domain connections that notify us by events Zheng Li
2014-09-16 9:31 ` [PATCH v2 8/8] oxenstored: fine tunning the recognition of domain connections with queued input/output Zheng Li
2014-09-23 14:32 ` Some oxenstored improvements (v2) Ian Jackson
2014-09-23 15:20 ` Zheng Li
2014-09-23 15:23 ` Dave Scott
2014-09-23 15:41 ` Ian Jackson
2014-09-23 15:57 ` Zheng Li
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=1410859897-31563-3-git-send-email-dev@zheng.li \
--to=dev@zheng.li \
--cc=Dave.Scott@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=fanhenglong@huawei.com \
--cc=joe.jin@oracle.com \
--cc=john.liuqiming@huawei.com \
--cc=luonengjun@huawei.com \
--cc=mcgrof@suse.com \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).