From patchwork Mon Aug 7 08:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109521 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481791obb; Mon, 7 Aug 2017 01:55:39 -0700 (PDT) X-Received: by 10.36.173.91 with SMTP id a27mr162505itj.130.1502096139421; Mon, 07 Aug 2017 01:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096139; cv=none; d=google.com; s=arc-20160816; b=Z4GggjjHKccGVY+b9stTL58YKqGW4mEZFqrpTNixnTDlljQPIRtGj9aZPSIjYvEowj REfE380WXWJO5kDBRlWkzGlbilHyZhOXkYuEzA/xVj+EYM3Mqb9lwIIH4AHWh6iNwpIk dSo2hRbx9EMN9nO15S1oU72/XMoWbzCC7gt/Vm3mXri8H+rgNmAaBofypRgihRseX0Uc 2o+bkYGqAS0XAgkszjbLp9GUqaQspDjUbyaIISlsw8Hb3iGncletoR4yOCKxasKlrr6S WfTP54SES8XQeLVjtu4acF7MPD75zdaS6Qx3rWvAzH24kejOX+2vAd/s6WG8vzfYgpZW DZDQ== 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=D5+2goXUtH/2O/ZiCc3q8lfrUcyZJNg5eC8EdxaPfsU=; b=Xx+YhjykuG7GHCJuILvDPYuPtsU2j3p3JP6RYs5oWuEs4D6ypzHmp93cDb6Cqfv5z0 8qi4ognCw2tu40sJN3kjvKcEK0GD0k6gueGSJdJWGtd5Bb/siW+Naf3FiMW7WPUiurJC 3Kz6eOLMgjLmgNnWKp+dvTlb+I9Ohx2VPqf+reoh9Da9ZkPqn54lnND9s7tpphnjHKwx nP12eOCLdfo2VG3glYcWuJAUU5NIh2RclKbVK95z/AayLN1REflOhd2u4jJ6ysAee6xD lbPVXMjorkoM96aFi0G6AjySE2rSbh2/jYReF+c5lgG5Yn7DSe6cetfhHXxtyYi2tTpZ bnLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WcQeAqY9; 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 e126si8478638itg.33.2017.08.07.01.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:39 -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.b=WcQeAqY9; 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 1dednl-0004qN-NU; Mon, 07 Aug 2017 08:54:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednj-0004nR-O0 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:15 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id A3/58-03612-7BA28895; Mon, 07 Aug 2017 08:54:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTAWt1tWh2 RBg2L5C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox9+5pZC/6LV/Te2cfawHhfuIuRi0NIYCaj xKfF+1lAHBaBecwSEz59ZgZxJAT6WSVOX1nG1sXICeSkSZy5cIq1i5EDyK6QuLnbFiQsJKAlc fTUbFaISW1MEjuu94DVsAmYSMzqkACpERFQkri3ajITSA2zwHxGiaZJvWAzhQUSJQ7vmMMEYr MIqEr8nj+BEcTmFfCR6Hr+gRFir5zEzXOdzCA2J1D8/KU3LBCLvSVuH+tjnMAosICRYRWjRnF qUVlqka6hhV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmBoMQDBDsabGwMOMUpy MCmJ8savaIsU4kvKT6nMSCzOiC8qzUktPsQow8GhJMGboNkRKSRYlJqeWpGWmQMMcpi0BAePk gjvC3WgNG9xQWJucWY6ROoUoyXHlSvrvjBxTDmwHUi+mvD/G5MQS15+XqqUOG8OyDwBkIaM0j y4cbBIvMQoKyXMywh0oBBPQWpRbmYJqvwrRnEORiVh3kkgU3gy80rgtr4COogJ6KA3ia0gB5U kIqSkGhgnCfzycWY/8+XUutV1Lm+LhOd/4t12Wu3lhdQcqaryh07/9Eznc0eduG/CeqTc03tF gYGF7/bvu4uuLgzb/IDJ2dFXYUKqTdL7XZ2/Nz6MEz/24szipOcsD2bzs2c6brQ4cERZL1Lv/ wo93ZXXWPQ7qzNdti2s3x0VJSvrybDm79Wm7ZOvRE5VYinOSDTUYi4qTgQAUFHyP78CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-21.messagelabs.com!1502096053!76598926!1 X-Originating-IP: [209.85.192.173] 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 32272 invoked from network); 7 Aug 2017 08:54:14 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:14 -0000 Received: by mail-pf0-f173.google.com with SMTP id h68so17546321pfk.0 for ; Mon, 07 Aug 2017 01:54:14 -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=18Ge6a9O/Pp9Crt+qmm0kz9rAVp/MTv6jUoUgCTXZWo=; b=WcQeAqY9jMfFODfN388RnH3RTNFHHHdlHGA/8eqO+XiBjoVvQwMfU9AZ0DO5yxHsBz AmNCB6YrSoakboEGsLILF0kGsC0ew/t+T2fr+MVEr4hNtDoVVexMs7xQGnHlKY60HfIf OO10JdCM6pjnYwevOnFBf8Jgd8fl4LV1inK3Y= 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=18Ge6a9O/Pp9Crt+qmm0kz9rAVp/MTv6jUoUgCTXZWo=; b=eYEA8SdCJV3Pe6AykTPMTvWWLSHInsTWgOvrgq0/LHI7sEUDJEZHXMsWmNroF5lun2 YH6IVNxt1xEE3CsQsYmqA0ViiCb39lm/D0am2qIbxTedSKlOQs4+5DYycSztpP5dj27P IwJR16o31GkzKh/GlI6TaFR9io2z4rZxvE5/ceQFe0azUNz5JVU+QnJj01osp78iUlrw S2NlE3pLk5CpmjG/5HrCXfq8TJR5cSqpvF7/KAEbjyOFix+HRCR/e5iVzEUXYlqoL3P6 QbeRoJxinbwpmIIUjuXLA0q3lGwx9TDBiRTbKizkIZ0R+Nu8h79XJTB/SkAO2cdYqLct L6AA== X-Gm-Message-State: AIVw110Lm0JG+QZ9iPkSQB7dGsWGKOOpAAxAEq714e8/3JlfZs3ZhvJ8 UnC+Xek0qOKm+zlzJewo4Q== X-Received: by 10.98.205.8 with SMTP id o8mr11048719pfg.241.1502096052584; Mon, 07 Aug 2017 01:54:12 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:12 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:07 +0530 Message-Id: <1502095997-31219-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/25 v7] 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);