All of lore.kernel.org
 help / color / mirror / Atom feed
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 8/8] oxenstored: fine tunning the recognition of domain connections with queued input/output
Date: Tue, 16 Sep 2014 10:31:37 +0100	[thread overview]
Message-ID: <1410859897-31563-9-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1410859897-31563-1-git-send-email-dev@zheng.li>

... also, only try to input on a connection with queued input, ditto for output.

Signed-off-by: Zheng Li <dev@zheng.li>
---
 tools/ocaml/xenstored/connection.ml  |  1 +
 tools/ocaml/xenstored/connections.ml | 14 +++++++++-----
 tools/ocaml/xenstored/xenstored.ml   |  7 ++++---
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/tools/ocaml/xenstored/connection.ml b/tools/ocaml/xenstored/connection.ml
index 47695f8..1769e23 100644
--- a/tools/ocaml/xenstored/connection.ml
+++ b/tools/ocaml/xenstored/connection.ml
@@ -223,6 +223,7 @@ 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
diff --git a/tools/ocaml/xenstored/connections.ml b/tools/ocaml/xenstored/connections.ml
index 1c8d911..1cf916a 100644
--- a/tools/ocaml/xenstored/connections.ml
+++ b/tools/ocaml/xenstored/connections.ml
@@ -98,11 +98,15 @@ 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 (racc, wacc) ->
+		 (if Connection.has_more_input con
+		  then con :: racc else racc),
+		 (if (* not currently blocked by filled up ring *)
+                    not (Connection.has_old_output con)
+		    && Connection.has_new_output con
+		  then con :: wacc else wacc))
+		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 c7dc6fa..70dff6f 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -379,9 +379,9 @@ let _ =
 			periodic_ops ();
 		);
 
-		let mw = Connections.has_more_work cons in
+		let rmw, wmw = Connections.has_more_work cons in
+		let timeout = if List.length rmw > 0 || List.length wmw > 0 then 0. else -1. in
 		let inset, outset = Connections.select cons in
-		let timeout = if List.length mw > 0 then 0. else -1. in
 		let rset, wset, _ =
 		try
 			Select.select (spec_fds @ inset) outset [] timeout
@@ -393,7 +393,8 @@ let _ =
 			process_special_fds sfds;
 		if List.length cfds > 0 || List.length wset > 0 then
 			process_connection_fds store cons domains cfds wset;
-		List.iter (process_domain store cons domains) mw
+		List.iter (process_domain ~mode_switch:true store cons domains) rmw;
+		List.iter (process_domain ~mode_switch:false store cons domains) wmw
 		in
 
 	while not !quit
-- 
2.1.0

  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 ` [PATCH v2 2/8] oxenstored: add facilities to raise the max open fds uplimit Zheng Li
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 ` Zheng Li [this message]
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-9-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 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.