From patchwork Wed Sep 27 06:13:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 114337 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4665425qgf; Tue, 26 Sep 2017 23:17:04 -0700 (PDT) X-Received: by 10.107.18.85 with SMTP id a82mr402411ioj.251.1506493024119; Tue, 26 Sep 2017 23:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506493024; cv=none; d=google.com; s=arc-20160816; b=r4J4J2H+FOHY4mUHfaIuv1TFf+MhBdD9YZQEvcD+7pXnXdHyYm8bPA286sFaLgU8sd /ngWKBbQohsQuz0iOLbw4xMRc4wI4daH+aeicIR595RlPjVdq0JoaVOFvzrkJyfDgG+S rC8YceFIfIMpM4MD3MiEP2zMPsCPwdBKjVhDq1DgHnrhJKysbf5P4LMxpNnZMONGAyTV uAvYL+6ApqeBS7sxCqINHMIobdNykKoJqsDG8UkQ+uh71M7nZuDS0waGhJ22eQ03yevQ T2EIVTiR2TTj3X7anTwAc5zwVd7ie4KCU5GBdJqmxSQny7ROS3SJVkXZWKbA8evRnWnx Vo5A== 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=Z2UlOsBiAlqdHtt4CrUSI9EdlaGBmw/yROwllWTb/V5LSWU8gKEtamSf8beAeWKcEc 2C8G/4J0UllGEOFPUDvG56iM0iw9ioayjDPQSR8aRk6AG7yF3LrzOJROMwSuZ5QYpIxX SWEzPbU8C/Ztu0YjUFN3L7bwyJ4uzO+lbx2QmTVzHdAlDUDCidiRiPwVadOnt/E0wqfP BgOvXJw/Bh/D4gLpHRk/UR8f0hvFtWp+vt7fSFTAM0wyLoy/eH4nqArHwqpQtUjf8Fk3 HqIqq8aSd5D+QA8IZwJ9rJutKtmJ6w2UNp/R3AGL7+QFHSI8LQCfBZHaLleAWLc++0BQ jkZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=M27bXCuT; 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 2si9050639ioz.84.2017.09.26.23.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 23:17:04 -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=M27bXCuT; 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 1dx5be-0002jO-BD; Wed, 27 Sep 2017 06:14:02 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bd-0002ho-Ed for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:14:01 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 11/21-02092-8A14BC95; Wed, 27 Sep 2017 06:14:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRWlGSWpSXmKPExsVyMfTAZt0Vjqc jDZbeY7H4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMWvr7PXDBfomLintuMDYy/hbsYuTiEBGYw Shy6cY0VxGERmMcs0bPlLiOIIyHQzyrxe/515i5GTiAnT2L7tMNMEHaaxMlVr9kh7HKJfx1Hw OJCAloSR0/NZoUYu4JJ4vLlz0DNHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIvG0hCWC BJ4sH6g2A2i4CqxMkdd8BsXgEficbrLVBHyEncPNcJZnMCxU/332aDWOwtcWllP+sERsEFjAy rGDWKU4vKUot0jUz1kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r1kvNzNzECg66egYFxB+Ou dr9DjJIcTEqivDX/T0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCd53A6UkiwKDU9tSItMwcY/ jBpCQ4eJRHeKJA0b3FBYm5xZjpE6hSjPceFO5f+MHF86b0BJA/suQUkO27e/cMkxJKXn5cqJc 5bBdImANKWUZoHNxQWr5cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfMmg0zhycwrgdv9Cug sJqCzeqeeADmrJBEhJdXAGFLiFTzp0MU7LbU1yypvXUzS+K9y4a/Oq7dHFff3H3dd0eqd/UFq BUubf+aGSVv2rz47gy13dVahSdrSvIP3bOYVrmNrlGx8XRD/523i1ROfYnaf36/f8TG5bFX9R vOt/2YY93WuN0/nEXkU3PnnRfPGXTIe1rduHosWf7pX8E3CR/soI1f9w0osxRmJhlrMRcWJAD 0+pYDSAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-206.messagelabs.com!1506492838!111798209!1 X-Originating-IP: [209.85.192.179] 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 11998 invoked from network); 27 Sep 2017 06:13:59 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:13:59 -0000 Received: by mail-pf0-f179.google.com with SMTP id r68so6749832pfj.3 for ; Tue, 26 Sep 2017 23:13:59 -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=M27bXCuTHC2l16U1Iy9e2RxkUrAEALlGCjFThuBRD9qn9H6Uctls4sm/LLqLR7TyWt swEdPj/S2HTSLzD3qyNcmr4wC7tuiRVUZSxLdYxr6sygnF9YxFB29Mf6Xk9fGw6ZzdBG HEL/2aRAIGw31noRGdZZUdmII6qEdwTSaH1cw= 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=ZXxvHt+zsPzygNt8bnx2r6x6qcRN+GCdkX6zONTPrRqkm98JsrE/vd7GYR8S2HvyQO OtrndUNR5Y5Rtorj+rucYUUw5tlr7Wde3e83HpNiENsA1/TjPKP8bj5SRG78FKN7r7Yv ROIdf6SnA8qDxGJwWdkUay5CK57biwu83sngXwux9jFYC5RXrw3e5COpMYsTdY7W91pe L/taELbVjVHzKt1KFKhCfohptIcSRbk8Bl75qAWunZiK2dHwe/1cIwtQ82gz52wwgJ2P LjkgkqCHTrS6SAci6gqHdtK2tOBsGOLFqq4AOhjMBYVOR3kbLc7I6Am8+he9ODVZ7lqA nxUw== X-Gm-Message-State: AHPjjUirA/bFvoTyc5Qya0h1Epc7YsZqUnFiAWDjgwRurSQ1Lbk//Nat gCG3FoJF3OUV87QVtjZm77DEyxisb9A= X-Google-Smtp-Source: AOwi7QAkMbI5O+5uLVndXryjZRbM5oeJQwUV+Wz5sZiJAC7kUvGD0uImC67pEotRe50MEQKN//HlYw== X-Received: by 10.159.198.71 with SMTP id y7mr334024plt.56.1506492838106; Tue, 26 Sep 2017 23:13:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:13:57 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:24 +0530 Message-Id: <1506492816-25954-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/27 v11] 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);