Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E919C4332F for ; Tue, 23 Nov 2021 14:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237928AbhKWO20 (ORCPT ); Tue, 23 Nov 2021 09:28:26 -0500 Received: from mga05.intel.com ([192.55.52.43]:64722 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237624AbhKWO2X (ORCPT ); Tue, 23 Nov 2021 09:28:23 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10176"; a="321261534" X-IronPort-AV: E=Sophos;i="5.87,257,1631602800"; d="scan'208";a="321261534" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2021 06:25:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,257,1631602800"; d="scan'208";a="509427091" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by orsmga008.jf.intel.com with ESMTP; 23 Nov 2021 06:25:06 -0800 Date: Tue, 23 Nov 2021 22:24:20 +0800 From: Chao Peng To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org, Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, john.ji@intel.com, susie.li@intel.com, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com Subject: Re: [RFC v2 PATCH 09/13] KVM: Introduce kvm_memfd_invalidate_range Message-ID: <20211123142420.GB32088@chaop.bj.intel.com> Reply-To: Chao Peng References: <20211119134739.20218-1-chao.p.peng@linux.intel.com> <20211119134739.20218-10-chao.p.peng@linux.intel.com> <4041d98a-23df-e9ed-b245-5edd7151fec5@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4041d98a-23df-e9ed-b245-5edd7151fec5@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 23, 2021 at 09:46:34AM +0100, Paolo Bonzini wrote: > On 11/19/21 14:47, Chao Peng wrote: > > + > > + /* Prevent memslot modification */ > > + spin_lock(&kvm->mn_invalidate_lock); > > + kvm->mn_active_invalidate_count++; > > + spin_unlock(&kvm->mn_invalidate_lock); > > + > > + ret = __kvm_handle_useraddr_range(kvm, &useraddr_range); > > + > > + spin_lock(&kvm->mn_invalidate_lock); > > + kvm->mn_active_invalidate_count--; > > + spin_unlock(&kvm->mn_invalidate_lock); > > + > > > You need to follow this with a rcuwait_wake_up as in > kvm_mmu_notifier_invalidate_range_end. Oh right. > > It's probably best if you move the manipulations of > mn_active_invalidate_count from kvm_mmu_notifier_invalidate_range_* to two > separate functions. Will do. > > Paolo