From patchwork Mon Aug 28 08:55:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111104 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547912qge; Mon, 28 Aug 2017 01:58:40 -0700 (PDT) X-Received: by 10.36.91.7 with SMTP id g7mr5857096itb.62.1503910720650; Mon, 28 Aug 2017 01:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910720; cv=none; d=google.com; s=arc-20160816; b=MAOHJvdjfZg/h7gAurtEhSebijdmCgaXhEj563so1SYwbHKenYygAy70wlvL46gPQI Q9slJ3yf5M52DhlCth+GZ+i1tGtDKoIYI+SqiPgTx7n/x8Zu9wVxTDukl/KIjFdgw1tB QBoH29foYYMSbziN80y1tmJkSNdqhte3W4n00F1FMkObtqW2DnIdIvkV3+BctuSwiUwC d+3R1bs6wIZ0rXp52SNwHZac9Qe5DvSx3mrmr3ty6x1wfqaXicr1m4ctGBqlfY17oe7d 8TsYo2gmdkD37rICeo0pe2bG5/+Z1M4UCWnS5QYSdc9cfS+BUcN3vF1n9rsxPiN66xak 7CWA== 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=KmG5y2IOPXhy6yBIF50uhSh4Zejsng9JchqH5nodiy5MHJyqfP71HjKyXhMLhD/4Yw 13uBAVHAm5ppsNLLjz8wC7YnyagZwvxleFTWFX5PA3sqLBq0QfsOs2/c4SiZslaIV/OR k8nVitC8Pk7lyXU6l8GdYkmbut2lmW8/dr5BKVlcpT+HRerTPEkqtlDae3VY2PVPC5mc GEcgwQipA0DjyHPJkLyTPONkdirJ8kaDg4Lr+6VH8N245kbQqcKcrJ1NPj3LemSGYooj NyimyAQiLMm+k2z5uAAyQpx17myKANNvESPXbYXu3IR3Zr19gP2BO/1ubVWp1v2kYE8q YBWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VdVGH8AP; 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 k190si5462125itd.55.2017.08.28.01.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:40 -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=VdVGH8AP; 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 1dmFr5-0005Es-Q6; Mon, 28 Aug 2017 08:57:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFr5-0005Dg-3H for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:11 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id E5/81-02962-6EAD3A95; Mon, 28 Aug 2017 08:57:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTAet2ntxZ HGsw/qGnxfctkJgdGj8MfrrAEMEaxZuYl5VcksGYsfH2fuWC+RMXEPbcZGxh/C3cxcnEICcxk lPjSuJ8NxGERmMcssebMfhYQR0Kgn1Xi1vUexi5GTiAnTeJ/+zM2CLtK4tvvrUwgtpCAlsTRU 7NZIUbtZ5JYuGYncxcjBwebgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtQLNkhYIFHiwNMTrC A2i4CqxKkFM1lAbF4BH4mfLzvZIZbJSdw818kMYnMCxXesvcsOsdhbouv1B9YJjAILGBlWMWo UpxaVpRbpGproJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBhcDEOxgvL4x4BCj JAeTkijvzorFkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeENuAuUEi1LTUyvSMnOAYQ6TluDgU RLh/QCS5i0uSMwtzkyHSJ1iNOa4cmXdFyaOKQe2f2ESYsnLz0uVEud9CFIqAFKaUZoHNwgWf5 cYZaWEeRmBThPiKUgtys0sQZV/xSjOwagkzHsQZApPZl4J3L5XQKcwAZ2iKLgQ5JSSRISUVAM j74Z0lYXMc3JtRS0arkV+CMr4FBQreNIr2/XYDxcbv90MsT9Yom1WVFpXeWREfBbW7pBv4ylf dG3Zh5XLDAx/Nfwzn1JoxHDx9PHqzTcd2tPuS3XJWFUsC1R5VvZqjrmbpe/OW5bOR/Kff7Bpe puy0LLrO/vEHbuLjxxa8seTddHkXzuFfE2UWIozEg21mIuKEwExxP11ugIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-27.messagelabs.com!1503910628!108265412!1 X-Originating-IP: [209.85.192.175] 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 58547 invoked from network); 28 Aug 2017 08:57:09 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-5.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:09 -0000 Received: by mail-pf0-f175.google.com with SMTP id c15so14537899pfm.2 for ; Mon, 28 Aug 2017 01:57:09 -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=VdVGH8APOpaP5CdB+D7SVHZWpjNT21JCkB8Y0OlpSvdYyL5sbuR1YnkQ9AKQ/3NHPi sSW9wMJI+FRyhVidE6sF+JiBZQmpItv+JSu3kS4XlyNbet8nO1PDWFAxfWAB/c67j/mP lvMwmkdyxUvq1pdum+j5XaJE5PLTSK47aZ7jc= 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=lnanEW+1OgCSzU/LQKHETCWu9xPNSgTPbDmKtpRI7AoIXjghvz9SBG5qIuiYxFZGYl j+OKsk5F94VDy9wUh6Qb0QKqMRq+uMiAdhyxvyoYa3S/QiANHZIptVKhroer4LOSxBUR 6v6PZYW4Gr2F55JMGV+1bSKelV9VDTDY5FLYH868u+VN+34/WYPK6Ifie96kGm9OuKpp sGGxxVCsfDt3IjO3EPzikxefaBJbSOpBVeSYu7xwERy2cL2k0D7IHSBRC5pqe4nnFhso fgSeb9DO7Vui8ehtMo98nLyjozjE9IJtW8x8SFEesLINGO4A4dlWkeAjLLPGSaduWDNH HIPA== X-Gm-Message-State: AHYfb5jPyJTVnkzndeNquJgwKBixZfprXAUMDXXVgMPG3IqzH4vlYuzv DmcJcMlW4LWaMHk6wk93BA== X-Received: by 10.99.43.144 with SMTP id r138mr6555959pgr.360.1503910627798; Mon, 28 Aug 2017 01:57:07 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:58 +0530 Message-Id: <1503910570-24427-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/27 v8] 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);