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>,
Ian Jackson <Ian.Jackson@citrix.com>,
"Liuqiming (John)" <john.liuqiming@huawei.com>
Subject: [PATCH v3 7/9] oxenstored: only process domain connections that notify us by events
Date: Thu, 25 Sep 2014 18:35:00 +0100 [thread overview]
Message-ID: <1411666502-23709-8-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1411666502-23709-1-git-send-email-dev@zheng.li>
Currently, upon receiving an event, oxenstored will always scan/process all
the domain connections (xs rings), disregarding which domain sent that event.
This is rather costy and inefficient. It also shadows and indulges client
for not correctly communicating with us on message/space availability.
With this patch, oxenstore will only scan/process the domain connections
that have correctly notified us by events or have IO actions leftover from
previous communication.
Signed-off-by: Zheng Li <dev@zheng.li>
---
tools/ocaml/xenstored/connection.ml | 4 ++++
tools/ocaml/xenstored/connections.ml | 9 ++++-----
tools/ocaml/xenstored/xenstored.ml | 13 ++++++++++---
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/tools/ocaml/xenstored/connection.ml b/tools/ocaml/xenstored/connection.ml
index 47695f8..807fc00 100644
--- a/tools/ocaml/xenstored/connection.ml
+++ b/tools/ocaml/xenstored/connection.ml
@@ -223,10 +223,14 @@ let pop_in con = Xenbus.Xb.get_in_packet con.xb
let has_more_input con = Xenbus.Xb.has_more_input con.xb
let has_output con = Xenbus.Xb.has_output con.xb
+let has_old_output con = Xenbus.Xb.has_old_output con.xb
let has_new_output con = Xenbus.Xb.has_new_output con.xb
let peek_output con = Xenbus.Xb.peek_output con.xb
let do_output con = Xenbus.Xb.output con.xb
+let has_more_work con =
+ has_more_input con || not (has_old_output con) && has_new_output con
+
let incr_ops con = con.stat_nb_ops <- con.stat_nb_ops + 1
let mark_symbols con =
diff --git a/tools/ocaml/xenstored/connections.ml b/tools/ocaml/xenstored/connections.ml
index 1c8d911..f9bc225 100644
--- a/tools/ocaml/xenstored/connections.ml
+++ b/tools/ocaml/xenstored/connections.ml
@@ -98,11 +98,10 @@ let iter cons fct =
iter_domains cons fct; iter_anonymous cons fct
let has_more_work cons =
- Hashtbl.fold (fun id con acc ->
- if Connection.has_more_input con then
- con :: acc
- else
- acc) cons.domains []
+ Hashtbl.fold
+ (fun id con acc ->
+ if Connection.has_more_work con then con :: acc else acc)
+ cons.domains []
let key_of_str path =
if path.[0] = '@'
diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xenstored.ml
index ea1a08f..b13393c 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -57,7 +57,10 @@ let process_domains store cons domains =
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
+ List.iter
+ (fun c ->
+ match Connection.get_domain c with
+ | Some d -> do_io_domain d | _ -> ())
let sigusr1_handler store =
try
@@ -305,6 +308,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 +316,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_domains 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 +389,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
+ process_domains store cons domains mw
in
while not !quit
--
2.1.1
next prev parent reply other threads:[~2014-09-25 17:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 17:34 Some oxenstored improvements (v3) Zheng Li
2014-09-25 17:34 ` [PATCH v3 1/9] oxenstored: add a poll-based select mechanism Zheng Li
2014-09-25 17:34 ` [PATCH v3 2/9] oxenstored: add facilities to raise the max open fds uplimit Zheng Li
2014-09-25 17:34 ` [PATCH v3 3/9] oxenstored: add a --use-select command line flag Zheng Li
2014-09-25 17:34 ` [PATCH v3 4/9] oxenstored: catch the error when a connection is already deleted Zheng Li
2014-09-25 17:34 ` [PATCH v3 5/9] oxenstored: use hash table to store socket connections Zheng Li
2014-09-25 17:34 ` [PATCH v3 6/9] oxenstored: enable domain connection indexing based on eventchn port Zheng Li
2014-09-25 17:35 ` Zheng Li [this message]
2014-09-25 17:35 ` [PATCH v3 8/9] oxenstored: add a safe net mechanism for existing ill-behaved clients Zheng Li
2014-09-25 17:35 ` [PATCH v3 9/9] oxenstored: reduce syslog call overhead Zheng Li
2014-09-25 21:00 ` [PATCH v3 9/9] oxenstored: reduce syslog call overhead (fix typo) Zheng Li
2014-09-26 15:16 ` Ian Jackson
2014-09-26 15:33 ` Zheng Li
2014-09-26 15:57 ` Ian Jackson
2014-09-26 16:29 ` Zheng Li
2014-09-26 16:37 ` Ian Jackson
2014-09-26 16:38 ` Zheng Li
2014-09-29 14:37 ` Some oxenstored improvements (v3) Konrad Rzeszutek Wilk
2014-09-29 20:55 ` Dave Scott
2014-09-30 10:21 ` Zheng Li
2014-10-07 13:24 ` Konrad Rzeszutek Wilk
2014-10-08 12:59 ` Dave Scott
2014-10-08 13:01 ` Konrad Rzeszutek Wilk
2014-10-08 13:42 ` Ian Campbell
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=1411666502-23709-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).