From patchwork Mon Sep 18 10:31:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 112882 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3501083qgf; Mon, 18 Sep 2017 03:34:46 -0700 (PDT) X-Received: by 10.107.197.198 with SMTP id v189mr19664361iof.94.1505730886596; Mon, 18 Sep 2017 03:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505730886; cv=none; d=google.com; s=arc-20160816; b=SjZgcVTtCilehQ31ZpvIvmAClyTJnFQPsuPyIhW4NfqgLSizcxGeqngcmbCJEYRBmU y2IGkC5Id2pOzV26bqy6iloyEzPG9n4Jkeau/bOBbzkrDQ25RrLPVd6glH3eVJzIUeRO idL5mBtSE2aarZAsG/nmRgGy+C3QvvOpmcTGqexddJFAYfCjyZsjSVmnI+NyhtnXSETd XtNhBK2Og/DacEWmi3BKNhPRlTMzxprjGLQ5/gg174smXGr+UCk1t+RS1XAFWnwT/5Fb M2J1o0x2ZsangirHIEt2AEAarU7Bg7Icgg7+Pgjwq4R04xmNSRBF7Zz63yn0UNodGTBz Qe2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Q//ZvXSf6O3d1s0mYjwUQWsaeqGoT/sNc0NvqLgFwSc=; b=rDXAE+Jb7oXDRxHW8M69sk3CLQB8tnkfNRAymsmlhYLKlJMsBMHOYWpOkxGKlOcJyK JTN1dZRE3QxPjqJHdQ7U9YXHynvAGpC4xQpLBPM9KwidLN9HHMCc4xWiQ9WpNUya0+j+ ToOQaqox21zQlgdSi4c+WPJftyaMTKHHueRk4fuHRqDNfaVFXTykA+QKI3hjiCfy8H0R RmYAS5wqvuYv0RM0UetBEjlSKqkTLV7voWUU2r+Exbg2p1gvS3Ro5haOHkS+jAhQyYu0 zWotybsnlq7IRMgLuaZsvumyeeAX9PQgyVj4Fdc0+KOqEUeEsJd0rORUuCTwT/vgHUK7 0rzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IjP9ng1k; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 3si527643itx.160.2017.09.18.03.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 03:34:46 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IjP9ng1k; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dttMU-0002Gv-0o; Mon, 18 Sep 2017 10:33:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dttMS-0002Di-3m for xen-devel@lists.xenproject.org; Mon, 18 Sep 2017 10:33:08 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 95/BA-30688-3E0AFB95; Mon, 18 Sep 2017 10:33:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMfTASt2HC/Z HGvxZaW7xfctkJgdGj8MfrrAEMEaxZuYl5VcksGYsfH2fuWC+RMXEPbcZGxh/C3cxcnEICUxn lJj+5w17FyMnB4vAPGaJzZfNQGwJgX5WidbfLhB2msTZc9uYYezTM3qYIOxyiU0rehhBbCEBL Ymjp2azQgzdwSQx9e9zti5GDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKmXDSQhLJAo0T zpGyPEEaoSTf+vgi3jFfCRmHBmCdQyOYmb5zrB4pxA8fPrH7BCLPaWmPfrCuMERsEFjAyrGDW KU4vKUot0DS30kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r1kvNzNzECA44BCHYwNm33PMQo ycGkJMorGrk/UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr9Z8oJxgUWp6akVaZg4w9GHSEhw8S iK8FiBp3uKCxNzizHSI1ClGS44Ldy79YeI4sOcWkOy4efcPkxBLXn5eqpQ4bx1IgwBIQ0ZpHt w4WHxeYpSVEuZlBDpQiKcgtSg3swRV/hWjOAejkjDvl3lAU3gy80rgtr4COogJ6KCWHXtADip JREhJNTD6mL75Os3JIFw7Pz5cKEfzjMAtHiMtoebyZV1WPzdxNMQ8cFpwW3J/8oG583SuBgob FkQ+mfKwZ1aS5Jwea4+Us/3/HEMzfqx7kc4QIVun/uzh4/BldXMY/v9r9uucJbeUaa5j1POmS 48PNM4vjT7o+mb6UzNO6XPGj6bk6J/ayslou87t/QclluKMREMt5qLiRACzQhz8ygIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-206.messagelabs.com!1505730784!110410598!1 X-Originating-IP: [209.85.192.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27765 invoked from network); 18 Sep 2017 10:33:05 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Sep 2017 10:33:05 -0000 Received: by mail-pf0-f169.google.com with SMTP id l188so30493pfc.6 for ; Mon, 18 Sep 2017 03:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6YGovVGluRqECYuWlBHwMmYrCh73aradxIet+Hw08pw=; b=IjP9ng1kGvmq9LzCAG5mZlnCzXSLf8J+/7eTPlkbilfc2o82u0n3D+vCsJNDHrd0vX rMEuRR3cluBx1QhRNIQ9TdrmQqdC2bJTHQ47/zLGTld3wVhUgM51B0oWbnDTW+ayFaaP YiYLdQEpqU8p12oIPNYvhNv63TbosQ4jU+bVU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6YGovVGluRqECYuWlBHwMmYrCh73aradxIet+Hw08pw=; b=RhwavrrCapQAieBHjQgxNtpUQBNG8FPXO9qGjPH9+bhbSRHLhPX2sWs7DqGPWboXlV IewwbpRT+APkzLkO9rhmdYZW6XP/rncCBXpt4EhdcAq8qdSIgw4v4DE66C0HVmSUdng+ /iIYsqxCR79cG+LSxPwKf7vb/F9Av+infTG/glg1BOQQRDLj6cz+DcvVGMBY5v6tb8Oe R7iiXw3oyPgqw5LbWhahlCS3g6O8S5pP1BblD12mfQW0gpLRU2Qhbxfd5LcTH02y9x+K PDYZRIE6lu4WmE+P+chVTLeFX9Nxxx2+xx/GbwSEtMqCdexTHqYnmWSa0HNq/LE/dNFM +fEQ== X-Gm-Message-State: AHPjjUg6FAdSgwDan03o6BS3LgUl9BY6otYskUSQn3Lma2Pq+l1kNVZg Ymg3Fl3qWvQhH/MdFuuVJA== X-Google-Smtp-Source: AOwi7QDMwRXJ6ymuFdrwvUaHDi6oWjj2flyKm7UdqAnsuvai3yGUxktQotvl3+bN/d9N38jojYXECA== X-Received: by 10.98.40.3 with SMTP id o3mr11433431pfo.317.1505730783931; Mon, 18 Sep 2017 03:33:03 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id b7sm12937845pge.79.2017.09.18.03.33.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Sep 2017 03:33:03 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 18 Sep 2017 16:01:59 +0530 Message-Id: <1505730731-10947-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> References: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/27 v9] xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new console_evtchn_unmask function. This function unmasks the console event channel if it is masked for some timeout period. One optimization that has been done is to merge the two for loops. One for loop was used to iterate through all domains and unmask the domain event channels which had been rate limited for a specified duration. The other for loop was run to add the event channel fd and the tty fd to the poll list. These two for loops were merged so that the these operations can be done in one iteration instead of two iterations. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a0b35da..2dcaee6 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -117,6 +117,11 @@ struct domain { static struct domain *dom_head; +static inline bool console_enabled(struct console *con) +{ + return con->local_port != -1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -908,6 +913,27 @@ static void handle_tty_write(struct console *con) } } +static void console_evtchn_unmask(struct console *con, void *data) +{ + long long now = (long long)data; + + if (!console_enabled(con)) + return; + + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz + * for select(), it is not clear poll() has + * similar behavior (returning a couple of ms + * sooner than requested) as well. Just leave + * the fuzz here. Remove it with a separate + * patch if necessary */ + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, con->local_port); + con->event_count = 0; + } +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; @@ -1142,23 +1168,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz - * for select(), it is not clear poll() has - * similar behavior (returning a couple of ms - * sooner than requested) as well. Just leave - * the fuzz here. Remove it with a separate - * patch if necessary */ - if ((now+5) > con->next_period) { - con->next_period = now + RATE_LIMIT_PERIOD; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(con->xce_handle, con->local_port); - } - con->event_count = 0; - } - } - - for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; + console_evtchn_unmask(con, (void *)now); maybe_add_console_evtchn_fd(con, (void *)&next_timeout);