Re: [RFT][PATCH v2 2/4] ACPI: OSL: Add support for deferred unmapping of ACPI memory

From: Rafael J. Wysocki
Date: Mon Jun 22 2020 - 11:28:07 EST


On Mon, Jun 22, 2020 at 4:56 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
>
> On Mon, Jun 22, 2020 at 5:06 PM Rafael J. Wysocki <rjw@xxxxxxxxxxxxx> wrote:
> >
> > From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
> >
> > Implement acpi_os_unmap_deferred() and
> > acpi_os_release_unused_mappings() and set ACPI_USE_DEFERRED_UNMAPPING
> > to allow ACPICA to use deferred unmapping of memory in
> > acpi_ex_system_memory_space_handler() so as to avoid RCU-related
> > performance issues with memory opregions.
>
> ...
>
> > +static bool acpi_os_drop_map_ref(struct acpi_ioremap *map, bool defer)
> > {
> > - unsigned long refcount = --map->refcount;
> > + if (--map->track.refcount)
> > + return true;
> >
> > - if (!refcount)
> > - list_del_rcu(&map->list);
> > - return refcount;
> > + list_del_rcu(&map->list);
> > +
>
> > + if (defer) {
> > + INIT_LIST_HEAD(&map->track.gc);
> > + list_add_tail(&map->track.gc, &unused_mappings);
>
> > + return true;
> > + }
> > +
> > + return false;
>
> A nit:
>
> Effectively it returns a value of defer.
>
> return defer;
>
> > }

Do you mean that one line of code could be saved? Yes, it could.

>
> ...
>
> > @@ -416,26 +421,102 @@ void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
> > }
> >
> > mutex_lock(&acpi_ioremap_lock);
> > +
> > map = acpi_map_lookup_virt(virt, size);
>
> A nit: should it be somewhere else (I mean in another patch)?

Do you mean the extra empty line?

No, I don't think so, or the code style after this patch would not
look consistent.

> > if (!map) {
>
> ...
>
> > + /* Release the unused mappings in the list. */
> > + while (!list_empty(&list)) {
> > + struct acpi_ioremap *map;
> > +
> > + map = list_entry(list.next, struct acpi_ioremap, track.gc);
>
> A nt: if __acpi_os_map_cleanup() (actually acpi_unmap() according to
> the code) has no side effects, can we use list_for_each_entry_safe()
> here?

I actually prefer a do .. while version of this which saves the
initial check (which has been carried out already).

> > + list_del(&map->track.gc);
> > + __acpi_os_map_cleanup(map);
> > + }
> > +}
>
> ...
>
> > @@ -472,16 +552,18 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
> > return;
> >
> > mutex_lock(&acpi_ioremap_lock);
> > +
> > map = acpi_map_lookup(addr, gas->bit_width / 8);
>
> A nit: should it be somewhere else (I mean in another patch)?

Nope.

Thanks!