From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTYZ-0007mI-IJ for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:01:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfTYT-00082a-Hx for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:00:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTYS-0007uE-Kl for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:00:52 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id CAB0B2F90FE for ; Fri, 25 Sep 2015 14:00:50 +0000 (UTC) From: Markus Armbruster Date: Fri, 25 Sep 2015 16:00:41 +0200 Message-Id: <1443189647-11417-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC 0/6] Throttle event VSERPORT_CHANGE separately by "id" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, marcandre.lureau@redhat.com, lersek@redhat.com VSERPORT_CHANGE is emitted when the guest opens or closes a virtio-serial port. The event's member "id" identifies the port. When several events arrive quickly, throttling drops all but the last of them. Because of that, a QMP client must assume that *any* port may have changed state when it receives a VSERPORT_CHANGE event and throttling may have happened. Make the event more useful by throttling it for each port separately. Marc-Andr=C3=A9 recently posted 'monitor: throttle VSERPORT_CHANGED by "id"' to do the same thing. Why am I redoing his work? Let me explain. In master, event throttling works per QAPIEvent. Throttling state is kept in MonitorQAPIEventState monitor_qapi_event_state[]. Going from event to throttling state is a simple array subscript. Marc-Andr=C3=A9's series makes the code governing throttling pluggable pe= r event. MonitorQAPIEventState gets two new members, the governor function and an opaque. It loses the actual throttling state. That one's now in new type MonitorQAPIEventPending. The standard governor has the opaque point to a single MonitorQAPIEventPending. The governor for VSERPORT_CHANGED has the opaque point to a hash table mapping "id" to MonitorQAPIEventPending. In my review, I challenged the complexity of this solution, but Marc-Andr=C3=A9 thinks it's justified. That leaves me two choices: conce= de the point, or come up with something that's actually simpler. My solution doesn't make anything pluggable. Instead, I simply generalize the map from event to throttling state. Instead of using just the QAPIEvent as key for looking up state, I permit additional use of event-specific data. For VSERPORT_CHANGED, I additionally use "id". monitor_qapi_event_state[] becomes a hash table. No callbacks, no type-punning, less code, and fewer code paths to test. RFC because it's compile-tested only. Compile-tested only because I want to give my feedback to Marc-Andr=C3=A9's work as soon as I can (although "as soon as I can" still means "frustratingly late", I'm afraid). PATCH 1+2 clean up the code some before I start. PATCH 2 may fix bugs, but to be sure I'd have to think some more about the old code. PATCH 3-5 do the actual work. PATCH 6 fixes docs to mention throttling. Diffstat for monitor.c Marc-Andr=C3=A9's series: 201 insertions(+), 55 deletions(-) mine: 109 insertions(+), 77 deletions(-) Markus Armbruster (6): monitor: Reduce casting of QAPI event QDict monitor: Simplify event throttling monitor: Split MonitorQAPIEventConf off MonitorQAPIEventState monitor: Turn monitor_qapi_event_state[] into a hash table monitor: Throttle event VSERPORT_CHANGE separately by "id" docs: Document QMP event rate limiting docs/qmp/qmp-events.txt | 12 ++++ docs/qmp/qmp-spec.txt | 5 ++ monitor.c | 186 ++++++++++++++++++++++++++++--------------= ------ 3 files changed, 126 insertions(+), 77 deletions(-) --=20 2.4.3