Re: [PATCH v10 12/26] gunyah: vm_mgr: Add/remove user memory regions
From: Srivatsa Vaddagiri
Date: Tue Feb 21 2023 - 07:44:31 EST
* Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> [2023-02-21 12:28:53]:
> > +void gh_vm_mem_reclaim(struct gh_vm *ghvm, struct gh_vm_mem *mapping)
> > + __must_hold(&ghvm->mm_lock)
> > +{
> > + int i, ret = 0;
> > +
> > + if (mapping->parcel.mem_handle != GH_MEM_HANDLE_INVAL) {
> > + ret = gh_rm_mem_reclaim(ghvm->rm, &mapping->parcel);
> > + if (ret)
> > + pr_warn("Failed to reclaim memory parcel for label %d: %d\n",
> > + mapping->parcel.label, ret);
>
> what the behavoir of hypervisor if we failed to reclaim the pages?
>
> > + }
> > +
> > + if (!ret)
> So we will leave the user pages pinned if hypervisor call fails, but further
> down we free the mapping all together.
I think we should cleanup and bail out here, rather than try continuing past the
error. For ex: imagine userspace were to reclaim with VM still running. We would
leave the pages pinned AFAICS (even after VM terminates later) and also not
return any error to userspace indicating failure to reclaim.