From patchwork Fri Sep 22 08:23:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 113988 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3011279qgf; Fri, 22 Sep 2017 01:26:14 -0700 (PDT) X-Received: by 10.107.201.15 with SMTP id z15mr7261712iof.267.1506068773954; Fri, 22 Sep 2017 01:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506068773; cv=none; d=google.com; s=arc-20160816; b=fuCctZ/eH8eWrGUAC6NzozjYdAJeB1SM8LCDd5nhNIVLoT0iqvgUguB665G9BxCSWj 0j86rj30VdTHejjiTyr5fvPL52ldGC9yWEuwdugGUhSnpkznJP3bK+ELK3IY7/DmWWRi C6LIEJEcbD0gYawZCLPLcJxRoyKaIkqnPUx7XA1U9CH3bB6XK8nPg49S/xwzeAmZecxg XKa5YDFYIdS+dny5azpByG4alGj4S+JNKlaCL4kj3BM4+Fs56BlQESdvOGKDR7fDqlLZ v4BmIzGPnyu9WEKzAj0QvpJwD3XuWVx27NH++8Xe90vR8khFGSGtz9tDp6RCtRYEkHCY yuzA== 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=gi1IC4kJVSIsLwW0bgvpY6fQsQ9WzuOStbF3uCXdWj730wAX786HsiDMqGlDNUAVty S098f9zO1jXxZRHgulXcmQ8QUlqCxlGzITtzuIP3jyN6pEQzNQHzHHzOY7IWvjD4/hA4 7Tn38BWfd/6p7MkGDeIuEu2TikwcIUsI0kc0G1LpWTKWDAifNVMR04CQotDT0fhS6Vfm lkWfMVirzygScc7nk/HedfrVpUKxSiNYDQj6wjwQPMn8ZnJlUbL3NOK9NhNaAOk5NOc8 zvIl3nkDhi/Q5jrt0B6tK8+ccq94MsI6wUn6e6TR1Bi91qtPYj1ejLG3UGiWBwf2+tqM RHnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hJR0WF+L; 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 f63si3476911ite.29.2017.09.22.01.26.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 01:26:13 -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=hJR0WF+L; 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 1dvJG3-0004Ap-Rt; Fri, 22 Sep 2017 08:24:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJG2-00048T-BV for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 08:24:22 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 1F/EC-03422-5B8C4C95; Fri, 22 Sep 2017 08:24:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMfTASt0tJ45 EGlyZY2TxfctkJgdGj8MfrrAEMEaxZuYl5VcksGYsfH2fuWC+RMXEPbcZGxh/C3cxcnEICUxn lDgyaQUjiMMiMI9ZYs2baywgjoRAP6vE9xXbgTKcQE6exJL246wQdprE99+zgeIcQHalRPsjb ZCwkICWxNFTs1khpu5gkphx7g87SA2bgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtTLBpIQFk iS2HtpEzuIzSKgKvFz3jowm1fAR+LmyX52iL1yEjfPdTKD2JxA8bX/N7BALPaW2HrjKssERsE FjAyrGNWLU4vKUot0DfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQIDjgEIdjDu fO50iFGSg0lJlPfxkSORQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4a48D5QSLUtNTK9Iyc4ChD 5OW4OBREuENB0nzFhck5hZnpkOkTjFacly4c+kPE8eBPbeAZMfNu3+YhFjy8vNSpcR554M0CI A0ZJTmwY2DxeclRlkpYV5GoAOFeApSi3IzS1DlXzGKczAqCfPOApnCk5lXArf1FdBBTEAHla8 GO6gkESEl1cBYHZp1wWE1a07hK5MP0drGAS2a1fevJnj4Stmdm3frnzBTbJ/QjP8V157J+y32 aWVomqf1+V3IL4awd/YHI+SZmkSPL+YV5F5Y7ufOPbfwf8j3OzI3jrJuzd3x/8H5JbJTpvBJr r72QWzLyR1Tsr8+4Ihjlf6+cstDluWfCm5tDRHe2LnUdU6CEktxRqKhFnNRcSIA8i58U8oCAA A= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1506068659!118084281!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 37095 invoked from network); 22 Sep 2017 08:24:20 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Sep 2017 08:24:20 -0000 Received: by mail-pf0-f169.google.com with SMTP id y29so244152pff.0 for ; Fri, 22 Sep 2017 01:24:20 -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=hJR0WF+LQXCHKDSlAsnkrOBUuzHGx/p8j3K4MJWCC7ATaFBJlvqF5A0ocqyw7qOdOJ QLa1zzzn9whI5jmGmdSMY2SCVLcGc3VgKAZmSet4DIAI3Vg9ZoHUE2S5d+b3De9HiXMS fQ0KQTKNfEd3YWKME58Pbbgf6wC4aOE/x9ifY= 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=iN+QSR2GYuEf9+40Vh3uLABLLyV9m0SWinMMrYE5aLWaeA6TWEX8vfC3IH89MCdpPA /ErgNVec5NzKGhHoS41OIYSc7OUbFotVqA283Aqqjnwse2BswYT0NeVS/80HexMC61st 3EHzrB8APBoLe9wbJF4VgioqavcL6TcpFSUUE9/SiZcQx5Z1p177PoRMskNyXDCsNCq9 2kFOLgepGKImXvtvkx1Tb4qr/Vx/GHt+yO5YVDF5JxJx9K83MUgw/2Guo+2fCvRQZXIh 0eE3AxgJbCvGG1npeerP6uDDrB5Pljgo7jPGDke0MhFNUs9rTAzz56/PX3HHGYi7+UQe JEQw== X-Gm-Message-State: AHPjjUgHerowTC4GQGo1PlOdCEW88/KnKbh8oPs3k06LE6um1SDOnPk4 Lq1Th8qwaOFDOShTvevxtaBvQpZ3zxk= X-Google-Smtp-Source: AOwi7QBMtwEwqCIQgtPynAqn5MjesJUAciWeJ7AiJ7BfkHUEjGkH60E8LrKj9jL8zfI68G7ASN5XFg== X-Received: by 10.99.144.68 with SMTP id a65mr8816128pge.429.1506068659075; Fri, 22 Sep 2017 01:24:19 -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 f74sm5569284pfa.36.2017.09.22.01.24.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 01:24:18 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 22 Sep 2017 13:53:14 +0530 Message-Id: <1506068606-17066-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/27 v10] 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);