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 7/8] oxenstored: only process domain connections that notify us by events
Date: Mon, 15 Sep 2014 23:39:19 +0100 [thread overview]
Message-ID: <1410820760-7994-8-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1410820760-7994-1-git-send-email-dev@zheng.li>
Currently, upon receiving an event, oxenstored will scan all the xs rings (of
all domains), disregarding who sent that event. This is not very efficient, and
also it can shadow some misbehaviors of xenstore clients.
With this patch, oxenstore will only scan and process the domain connections
that have correctly notified it by events.
The function process_domains is refactored to be process_domain in order to
allow processing single domain connection. Also a mode_switch flag is added to
enable selectively processing just the input or output or both.
Signed-off-by: Zheng Li <dev@zheng.li>
---
tools/ocaml/xenstored/xenstored.ml | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xenstored.ml
index ea1a08f..41a188d 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -51,13 +51,17 @@ let process_connection_fds store cons domains rset wset =
process_fdset_with rset Process.do_input;
process_fdset_with wset Process.do_output
-let process_domains store cons domains =
- let do_io_domain domain =
- if not (Domain.is_bad_domain domain) then
- let con = Connections.find_domain cons (Domain.get_id domain) in
- Process.do_input store cons domains con;
- Process.do_output store cons domains con in
- Domains.iter domains do_io_domain
+let process_domain ?mode_switch store cons domains c =
+ match Connection.get_domain c with
+ | None -> ()
+ | Some dom ->
+ if not (Domain.is_bad_domain dom) then
+ let read, write = match mode_switch with
+ | None -> true, true
+ | Some true -> true, false
+ | Some false -> false, true in
+ (if read then Process.do_input store cons domains c;
+ if write then Process.do_output store cons domains c)
let sigusr1_handler store =
try
@@ -305,6 +309,7 @@ let _ =
Connections.add_anonymous cons cfd can_write
and handle_eventchn fd =
let port = Event.pending eventchn in
+ debug "pending port %d" (Xeneventchn.to_int port);
finally (fun () ->
if Some port = eventchn.Event.virq_port then (
let (notify, deaddom) = Domains.cleanup xc domains in
@@ -312,7 +317,10 @@ let _ =
if deaddom <> [] || notify then
Connections.fire_spec_watches cons "@releaseDomain"
)
- ) (fun () -> Event.unmask eventchn port);
+ else
+ let c = Connections.find_domain_by_port cons port in
+ process_domain store cons domains c
+ ) (fun () -> Event.unmask eventchn port)
and do_if_set fd set fct =
if List.mem fd set then
fct fd in
@@ -382,7 +390,7 @@ let _ =
process_special_fds sfds;
if List.length cfds > 0 || List.length wset > 0 then
process_connection_fds store cons domains cfds wset;
- process_domains store cons domains
+ List.iter (process_domain store cons domains) mw
in
while not !quit
--
2.1.0
next prev parent reply other threads:[~2014-09-15 22:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 22:39 Some oxenstored improvements Zheng Li
2014-09-15 22:39 ` [PATCH 1/8] oxenstored: add a poll-based select mechanism Zheng Li
2014-09-16 9:01 ` David Scott
2014-09-16 13:00 ` Zheng Li
2014-09-15 22:39 ` [PATCH 2/8] oxenstored: add facilities to raise the max open fds uplimit Zheng Li
2014-09-16 9:05 ` Dave Scott
2014-09-16 9:38 ` David Vrabel
2014-09-16 13:05 ` Zheng Li
2014-09-15 22:39 ` [PATCH 3/8] oxenstored: add a --use-select command line flag Zheng Li
2014-09-15 22:39 ` [PATCH 4/8] oxenstored: catch the error when a connection is already deleted Zheng Li
2014-09-16 9:08 ` Dave Scott
2014-09-15 22:39 ` [PATCH 5/8] oxenstored: use hash table to store socket connections Zheng Li
2014-09-15 22:39 ` [PATCH 6/8] oxenstored: enable domain connection indexing based on eventchn port Zheng Li
2014-09-16 9:16 ` Dave Scott
2014-09-16 13:13 ` Zheng Li
2014-09-15 22:39 ` Zheng Li [this message]
2014-09-16 9:19 ` [PATCH 7/8] oxenstored: only process domain connections that notify us by events Dave Scott
2014-09-16 13:34 ` Zheng Li
2014-09-15 22:39 ` [PATCH 8/8] oxenstored: fine tunning the recognition of domain connections with queued input/output 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=1410820760-7994-8-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).