[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 04/24] vfio-user: add region cache
From: |
John Johnson |
Subject: |
Re: [PATCH v1 04/24] vfio-user: add region cache |
Date: |
Thu, 2 Feb 2023 05:21:05 +0000 |
> On Dec 12, 2022, at 3:42 AM, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 9/11/22 00:13, John Johnson wrote:
>> cache VFIO_DEVICE_GET_REGION_INFO results to reduce
>> memory alloc/free cycles and as prep work for vfio-user
>> Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
>> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
>> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
>> ---
>> hw/vfio/ccw.c | 5 -----
>> hw/vfio/common.c | 41 +++++++++++++++++++++++++++++++++++------
>> hw/vfio/igd.c | 23 +++++++++--------------
>> hw/vfio/migration.c | 2 --
>> hw/vfio/pci-quirks.c | 19 +++++--------------
>> hw/vfio/pci.c | 8 --------
>> include/hw/vfio/vfio-common.h | 2 ++
>> 7 files changed, 51 insertions(+), 49 deletions(-)
>
>
>> void vfio_put_base_device(VFIODevice *vbasedev)
>> {
>> + if (vbasedev->regions != NULL) {
>> + int i;
>> +
>> + for (i = 0; i < vbasedev->num_regions; i++) {
>> + g_free(vbasedev->regions[i]);
>> + }
>> + g_free(vbasedev->regions);
>> + vbasedev->regions = NULL;
>> + }
>> +
>> if (!vbasedev->group) {
>> return;
>> }
>> @@ -2432,6 +2451,17 @@ int vfio_get_region_info(VFIODevice *vbasedev, int
>> index,
>> {
>> size_t argsz = sizeof(struct vfio_region_info);
>> + /* create region cache */
>> + if (vbasedev->regions == NULL) {
>> + vbasedev->regions = g_new0(struct vfio_region_info *,
>> + vbasedev->num_regions);
>> + }
>> + /* check cache */
>> + if (vbasedev->regions[index] != NULL) {
>> + *info = vbasedev->regions[index];
>> + return 0;
>> + }
>
> What about simply allocating/releasing once regions[] in
> vfio_instance_init / vfio_instance_finalize?
I think this is done already, except with _realize and
_instance_finalize.
e.g,, vfio_realize() -> vfio_get_device() -> vfio_get_all_regions allocates
and
vfio_instance_finalize -> vfio_put_device -> vfio_put_base_device deallocates
JJ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v1 04/24] vfio-user: add region cache,
John Johnson <=