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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 0D592C4727C for ; Thu, 1 Oct 2020 08:03:59 +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 9BF8120872 for ; Thu, 1 Oct 2020 08:03:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="imOcekMO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BF8120872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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.1096.3593 (Exim 4.92) (envelope-from ) id 1kNtYp-00089Z-Nc; Thu, 01 Oct 2020 08:03:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1096.3593; Thu, 01 Oct 2020 08:03:31 +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 1kNtYp-00089S-Jd; Thu, 01 Oct 2020 08:03:31 +0000 Received: by outflank-mailman (input) for mailman id 1096; Thu, 01 Oct 2020 08:03:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNtYn-00089N-Vl for xen-devel@lists.xenproject.org; Thu, 01 Oct 2020 08:03:30 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4cbf1905-828f-475f-9b13-84d3264b6b0a; Thu, 01 Oct 2020 08:03:28 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id k15so4505948wrn.10 for ; Thu, 01 Oct 2020 01:03:28 -0700 (PDT) Received: from CBGR90WXYV0 (54-240-197-224.amazon.com. [54.240.197.224]) by smtp.gmail.com with ESMTPSA id l5sm3022012wrv.24.2020.10.01.01.03.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2020 01:03:26 -0700 (PDT) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNtYn-00089N-Vl for xen-devel@lists.xenproject.org; Thu, 01 Oct 2020 08:03:30 +0000 X-Inumbo-ID: 4cbf1905-828f-475f-9b13-84d3264b6b0a Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4cbf1905-828f-475f-9b13-84d3264b6b0a; Thu, 01 Oct 2020 08:03:28 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id k15so4505948wrn.10 for ; Thu, 01 Oct 2020 01:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=OTrEnhNBN5R4+dyvqauB0Y5OwRj53IzJUx91Bcl+i78=; b=imOcekMOnoMaah3UJlqcpTJVMYjVhigkPyz40HYVmXhEJ4xWp4/P1BNO1ZVr9chui+ +7spsDUSjId3ROYCISatnycAeCmnB5oOcaliX8csdcJswDj4+NH+z5Ohvk7XiF0OkzTz OSI3COJMjpjLSEzPBcyVgJVXNjY1duYV1xTSTjMmCgkSNIAY9ESlRqo/TLU4ftp7leDD 0jJsmgC0EyDWxq2Uzx//u2JmVSZ1n2dRFb2FR1Jsrr4NjkNUPyuw14gS+/5m7juQi6Xl a5+POY0TW6Opv4xfeLe/6oniu0rGle8XxdIYJpdgK/NJDvPc205QeL+Q3l+rH85YCNp3 jvpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=OTrEnhNBN5R4+dyvqauB0Y5OwRj53IzJUx91Bcl+i78=; b=NRluWBUnSGnyRWQ+/gnEA/9hFrUvzWXQSyGr8Uj1ABf626T95eZC23qLpyMsJRXgO6 3IdyxMK2/PvY6DmlFrlSGKDrx/gU0nNuM0MoedHBrU0+qj6MhVlIukzhXum3U6W/ZB+z YAd7s1ucsepWxWL6cFL5LruBwfc4jYHskdJNJsoZeHrTfwrvoCvUWMMFa5UpU+iGxgtN PL39Ihv8MYqqeMJHKABVJsGCntJFd+ZZHMLk9NQfkfzSLqdG/gRaL3erhQl+cbtxYUHT 1nf1XNNrTXrBV7zMLMi+pMg+6QNRq7nagHE1a29wMIbrSZMOt0ZcMHIMc2tvkrCMNA2K KXzg== X-Gm-Message-State: AOAM531l0+2wzOczcC23Uqn08Zn4M01l2kepIhS4JlNx/4QZ35JmC9/o 9YMfodW8PIotK6WhKRxngA8= X-Google-Smtp-Source: ABdhPJwan3nlRJEN7HKE69zar2eImtVpRpYFlhfsKXozjX7PA3CNyjJoF03MdM73/nxESr0z2OvvMw== X-Received: by 2002:a5d:5583:: with SMTP id i3mr7158520wrv.119.1601539407387; Thu, 01 Oct 2020 01:03:27 -0700 (PDT) Received: from CBGR90WXYV0 (54-240-197-224.amazon.com. [54.240.197.224]) by smtp.gmail.com with ESMTPSA id l5sm3022012wrv.24.2020.10.01.01.03.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2020 01:03:26 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" Reply-To: To: "'Anthony PERARD'" Cc: , , "'Paul Durrant'" , "'Jerome Leseinne'" , "'Edwin Torok'" , "'Stefano Stabellini'" References: <20200923155731.29528-1-paul@xen.org> <20200930114235.GL2024@perard.uk.xensource.com> In-Reply-To: <20200930114235.GL2024@perard.uk.xensource.com> Subject: RE: [PATCH] xen-bus: reduce scope of backend watch Date: Thu, 1 Oct 2020 09:03:25 +0100 Message-ID: <008c01d697c9$579520a0$06bf61e0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQFwzHOYQKlt73iXJ/fB9mI5UZbIzgHcxvtVqj8StGA= > -----Original Message----- > From: Anthony PERARD > Sent: 30 September 2020 12:43 > To: Paul Durrant > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Paul Durrant ; Jerome > Leseinne ; Edwin Torok ; Stefano Stabellini > > Subject: Re: [PATCH] xen-bus: reduce scope of backend watch > > 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 > Ok, I'll re-arrange the const-ing to cast at the inner level. > > +} > > + > > 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. > Yes, I'll add a check. > > + } > > + > > + 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. > Might not be too tricky. I'll see if I can come up with a follow-up patch. Paul > Cheers, > > -- > Anthony PERARD