From mboxrd@z Thu Jan 1 00:00:00 1970 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=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 34D9FC433ED for ; Fri, 7 May 2021 07:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F080F61451 for ; Fri, 7 May 2021 07:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235589AbhEGHnv (ORCPT ); Fri, 7 May 2021 03:43:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53515 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231165AbhEGHnu (ORCPT ); Fri, 7 May 2021 03:43:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620373371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vsa8eoRAU/op3poaE3LMiG1JCafOvgbDI+OB1GR9vsw=; b=SpNUf/P3VvlfEwkxirfYSL1UM4kdac8Jr9n/i9oezfvKJpsrHjKXCX7ebUwyHjyu57wYN4 7TpyscWE02tyFpGdvOtltrOI86UOIgET9hxoKttqeE4vS94iYl36lgTQwyoYpjXj6EA+Ma Sxg7bSzmsg6tk14tHbyg5+keu4Tr+/Y= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-a_Ebj5S_P7ue2LrKqdRDiA-1; Fri, 07 May 2021 03:42:49 -0400 X-MC-Unique: a_Ebj5S_P7ue2LrKqdRDiA-1 Received: by mail-ed1-f72.google.com with SMTP id g17-20020aa7dd910000b029038843570b67so4011663edv.9 for ; Fri, 07 May 2021 00:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=vsa8eoRAU/op3poaE3LMiG1JCafOvgbDI+OB1GR9vsw=; b=Dga4ZxJmY2g4WqfXuInrN9yDXm2PSBIbMlvdeyxgmpJyPOm9cHu2iQWEN1KdvocZuQ DHVTPdLsnJyiYptsbCOCWPVEq8rsBL1czVmwbQxt9x3zSs865yeec2WGtOdrZIzp+cUA ZT+IcNkZYK2WbnV7S4YLPi4hxgj0v65yEZZJf1znpKTq0dU8IE+hWIHd9tcsD0+6Ax4W 0a0KCs0j0jVdOSl034X3JbNs/SkBJNOr0AO6PbWDP+sM6UWSdnqFfkByXSqd7qNb0Snl CB1q6I2KlaB+Ok5YmAXhCvKdfn0BmwysDgygLVd1U28wwZoqo3gDG6p06vNxb8GykIlA cHpA== X-Gm-Message-State: AOAM5310Ktz1w1BqEMRtVrRrvAvEtyKI7+5NjO4IyTJ92Ood0O2yKdbI iVItRNGVo+aA+BJkipHxSlWi/E5xGhkYOw648OGixHwHqKnQtu+piZqtBeU85MacGUq5+7ubDjS kNjH2B8b+4o0DAT42A1RhRdfn X-Received: by 2002:aa7:ccc4:: with SMTP id y4mr9565499edt.171.1620373368586; Fri, 07 May 2021 00:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4lQAaBrROI5moPobb0YQwseMCoxa7a0OaL+tWl07rMAc+ZBwZGj8pu8eJHfR3ilJxTw0IZQ== X-Received: by 2002:aa7:ccc4:: with SMTP id y4mr9565484edt.171.1620373368429; Fri, 07 May 2021 00:42:48 -0700 (PDT) Received: from [192.168.3.132] (p5b0c63c0.dip0.t-ipconnect.de. [91.12.99.192]) by smtp.gmail.com with ESMTPSA id r16sm3555325edq.87.2021.05.07.00.42.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 May 2021 00:42:48 -0700 (PDT) Subject: Re: [PATCH v3 1/8] KVM: x86/mmu: Deduplicate rmap freeing To: Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Peter Xu , Sean Christopherson , Peter Shier , Yulei Zhang , Wanpeng Li , Xiao Guangrong , Kai Huang , Keqian Zhu References: <20210506184241.618958-1-bgardon@google.com> <20210506184241.618958-2-bgardon@google.com> From: David Hildenbrand Organization: Red Hat Message-ID: <97d6a7da-2777-293a-4dab-668fe16dc2e9@redhat.com> Date: Fri, 7 May 2021 09:42:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210506184241.618958-2-bgardon@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06.05.21 20:42, Ben Gardon wrote: > Small code deduplication. No functional change expected. > > Signed-off-by: Ben Gardon > --- > arch/x86/kvm/x86.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cf3b67679cf0..5bcf07465c47 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -10818,17 +10818,23 @@ void kvm_arch_destroy_vm(struct kvm *kvm) > kvm_hv_destroy_vm(kvm); > } > > -void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) > +static void free_memslot_rmap(struct kvm_memory_slot *slot) > { > int i; > > for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) { > kvfree(slot->arch.rmap[i]); > slot->arch.rmap[i] = NULL; > + } > +} > > - if (i == 0) > - continue; > +void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) > +{ > + int i; > + > + free_memslot_rmap(slot); > > + for (i = 1; i < KVM_NR_PAGE_SIZES; ++i) { > kvfree(slot->arch.lpage_info[i - 1]); > slot->arch.lpage_info[i - 1] = NULL; > } > @@ -10894,12 +10900,9 @@ static int kvm_alloc_memslot_metadata(struct kvm_memory_slot *slot, > return 0; > > out_free: > - for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) { > - kvfree(slot->arch.rmap[i]); > - slot->arch.rmap[i] = NULL; > - if (i == 0) > - continue; > + free_memslot_rmap(slot); > > + for (i = 1; i < KVM_NR_PAGE_SIZES; ++i) { > kvfree(slot->arch.lpage_info[i - 1]); > slot->arch.lpage_info[i - 1] = NULL; > } > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb