From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zheng Li Subject: [PATCH 8/8] oxenstored: fine tunning the recognition of domain connections with queued input/output Date: Mon, 15 Sep 2014 23:39:20 +0100 Message-ID: <1410820760-7994-9-git-send-email-dev@zheng.li> References: <1410820760-7994-1-git-send-email-dev@zheng.li> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XTexj-000752-AI for xen-devel@lists.xenproject.org; Mon, 15 Sep 2014 22:41:35 +0000 In-Reply-To: <1410820760-7994-1-git-send-email-dev@zheng.li> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Dave Scott , Joe Jin , "Luis R. Rodriguez" , Luonengjun , Zheng Li , Fanhenglong , "Liuqiming (John)" , Ian Jackson List-Id: xen-devel@lists.xenproject.org ... also, only try to input on a connection with queued input, ditto for output. Signed-off-by: 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 a0f1b89..1baa6c3 100644 --- a/tools/ocaml/xenstored/connections.ml +++ b/tools/ocaml/xenstored/connections.ml @@ -93,11 +93,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 41a188d..b95232c 100644 --- a/tools/ocaml/xenstored/xenstored.ml +++ b/tools/ocaml/xenstored/xenstored.ml @@ -376,9 +376,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 @@ -390,7 +390,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