From: Paolo Bonzini Subject: Re: [PATCH V4 12/15] x86/hyper-v: Add HvFlushGuestAddressList hypercall support Date: Mon, 15 Oct 2018 12:30:08 +0200 Message-ID: <1fece0bb-ca24-5f4d-2215-93e9705144fd@redhat.com> References: <20181013145406.4911-1-Tianyu.Lan@microsoft.com> <20181013145406.4911-13-Tianyu.Lan@microsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: sthemmin@microsoft.com, kvm@vger.kernel.org, rkrcmar@redhat.com, haiyangz@microsoft.com, x86@kernel.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, michael.h.kelley@microsoft.com, mingo@redhat.com, hpa@zytor.com, Lan Tianyu , tglx@linutronix.de, vkuznets@redhat.com To: lantianyu1986@gmail.com Return-path: In-Reply-To: <20181013145406.4911-13-Tianyu.Lan@microsoft.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" List-Id: kvm.vger.kernel.org On 13/10/2018 16:54, lantianyu1986@gmail.com wrote: > > +static int fill_flush_list(union hv_gpa_page_range gpa_list[], > + int offset, u64 start_gfn, u64 pages) Pass the entire struct hv_guest_mapping_flush_list to this function, it's simpler and it hides the gpa_list argument from range->parse_flush_list_func. > + if (!range->flush_list) > + gpa_n = fill_flush_list(flush->gpa_list, gpa_n, > + range->start_gfn, range->pages); > + else if (range->parse_flush_list_func) > + gpa_n = range->parse_flush_list_func(flush->gpa_list, gpa_n, > + range->flush_list, fill_flush_list); > + else You are making the code more complicated in order to avoid making fill_flush_list public. Just make it public and always go through the parse_flush_list_func case. In fact: - make parse_flush_list_func an argument of hyperv_flush_guest_mapping_range - drop struct hyperv_tlb_range completely, instead just pass a void* to hyperv_flush_guest_mapping_range and pass it back to the callback. The void * can point to the start_gfn/pages pair, it can be the flush_list, or anything else. Paolo