Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38AAAC4727F for ; Wed, 30 Sep 2020 11:43:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5D7F20738 for ; Wed, 30 Sep 2020 11:43:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="HPDHZ9Py" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5D7F20738 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.608.2016 (Exim 4.92) (envelope-from ) id 1kNaVR-0007sv-HW; Wed, 30 Sep 2020 11:42:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 608.2016; Wed, 30 Sep 2020 11:42:45 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNaVR-0007so-Eb; Wed, 30 Sep 2020 11:42:45 +0000 Received: by outflank-mailman (input) for mailman id 608; Wed, 30 Sep 2020 11:42:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNaVQ-0007sj-O1 for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 11:42:44 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0a6a49a1-618f-4f95-b9a5-ee53b51b95a9; Wed, 30 Sep 2020 11:42:42 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNaVQ-0007sj-O1 for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 11:42:44 +0000 X-Inumbo-ID: 0a6a49a1-618f-4f95-b9a5-ee53b51b95a9 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0a6a49a1-618f-4f95-b9a5-ee53b51b95a9; Wed, 30 Sep 2020 11:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1601466162; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=mdXgkOu3ylqnn1zoExFL9VmyUXl2+ZCZhLSNKounvE0=; b=HPDHZ9PyPVQS+nOvE4FpI4pIyqJz8jxo2ZyOoBasxNEWFolkPAXqLitx 7QV+ZRVNsfjTelrKqH8n/pTUh7io+gsnWlQWzAMWJ2L86ck1wtYTk2Zl0 MemLhbLXv87OPNySpLRB4+qsexd8pY9KXEoYoeM6GVjBqDfa6oGGUBvOj k=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: KZcH2yqEPGmYgpzCTQcnwziklCfV47GiZR8knMGcUdCcnTps/6KmpdcJ622fhTxdV82dJAis3J 2h8YJqGkF6XeXtdjDeoAvXkVaMoD3BZua/wq0b4bOLKp0EqmXGR1E/Re5SmzzdbDVRO00olDxp n2puov22Mo+pb15T1y6U8wsCF0LJOB2Lr4rCT75MECzfp8em1LGtzr7cjm045GJ2e0V1LL+4or Oe82Ph0iCoysiNr0mwQwAzK2MvXEHjgVLnsjdS9mCw+L47c/mG3ctCZ8Pw0mSG3vKNXlnL3Njq u5k= X-SBRS: None X-MesageID: 28964510 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,322,1596513600"; d="scan'208";a="28964510" Date: Wed, 30 Sep 2020 12:42:35 +0100 From: Anthony PERARD To: Paul Durrant CC: , , Paul Durrant , Jerome Leseinne , "Edwin Torok" , Stefano Stabellini Subject: Re: [PATCH] xen-bus: reduce scope of backend watch Message-ID: <20200930114235.GL2024@perard.uk.xensource.com> References: <20200923155731.29528-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200923155731.29528-1-paul@xen.org> On Wed, Sep 23, 2020 at 04:57:31PM +0100, Paul Durrant wrote: > From: Paul Durrant > > Currently a single watch on /local/domain/X/backend is registered by each > QEMU process running in service domain X (where X is usually 0). The purpose > of this watch is to ensure that QEMU is notified when the Xen toolstack > creates a new device backend area. > Such a backend area is specific to a single frontend area created for a > specific guest domain and, since each QEMU process is also created to service > a specfic guest domain, it is unnecessary and inefficient to notify all QEMU > processes. > Only the QEMU process associated with the same guest domain need > receive the notification. This patch re-factors the watch registration code > such that notifications are targetted appropriately. > > Reported-by: Jerome Leseinne > Signed-off-by: Paul Durrant > > diff --git a/hw/xen/xen-backend.c b/hw/xen/xen-backend.c > index 10199fb58d..f2711fe4a7 100644 > --- a/hw/xen/xen-backend.c > +++ b/hw/xen/xen-backend.c > @@ -41,6 +41,11 @@ static void xen_backend_table_add(XenBackendImpl *impl) > g_hash_table_insert(xen_backend_table_get(), (void *)impl->type, impl); > } > > +static void **xen_backend_table_keys(unsigned int *count) > +{ > + return g_hash_table_get_keys_as_array(xen_backend_table_get(), count); That could be cast to (const gchar **) as the GLib doc suggest, or (const char **) since gchar and char are the same. https://developer.gnome.org/glib/stable/glib-Hash-Tables.html#g-hash-table-get-keys-as-array > +} > + > static const XenBackendImpl *xen_backend_table_lookup(const char *type) > { > return g_hash_table_lookup(xen_backend_table_get(), type); > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c > index 9ce1c9540b..c83da93bf3 100644 > --- a/hw/xen/xen-bus.c > +++ b/hw/xen/xen-bus.c > @@ -430,7 +430,13 @@ static void xen_bus_unrealize(BusState *bus) > trace_xen_bus_unrealize(); > > if (xenbus->backend_watch) { > - xen_bus_remove_watch(xenbus, xenbus->backend_watch, NULL); > + unsigned int i; > + > + for (i = 0; i < xenbus->backend_types; i++) { > + xen_bus_remove_watch(xenbus, xenbus->backend_watch[i], NULL); We should check if backend_watch[i] is NULL. > + } > + > + g_free(xenbus->backend_watch); > xenbus->backend_watch = NULL; > } > The rest of the patch looks fine. Next improvement is to only look at only one backend type in xen_bus_backend_changed() since there is now a watch per backend type :-), but that would be for another day. Cheers, -- Anthony PERARD