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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B677C43334 for ; Mon, 18 Jul 2022 15:26:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235422AbiGRP0r (ORCPT ); Mon, 18 Jul 2022 11:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235428AbiGRP0n (ORCPT ); Mon, 18 Jul 2022 11:26:43 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850F429800 for ; Mon, 18 Jul 2022 08:26:39 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id s18-20020a17090aa11200b001f1e9e2438cso146613pjp.2 for ; Mon, 18 Jul 2022 08:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Yt9oE0kz3TmH5FGxe6pEDCKgvRvBbOAA/ay7EMCbyEc=; b=Uff3ivfihawnDb3MVf5QlQ2jPMMai38C6bP4DepEErQNRp/Kc0gYVje6cUTN3mqgBa 8e/i6cCNzLQRIo6XA6wMXV8Z208mTTLPAFevNS72jjatByWcRHbhRuXNC/PzoiNVlj0A G9sTexZ1nkBq8bHjUgqFI7BC1X8Fl1pf5ZeLZgS5QdWIqKzWIGGLSvIy/UwP2bykPTMR S0KDUdaMZvJIWXXz6SkPgu1okTxSS3xRe0n7hIARn0g4omp+/4Oqj1iwRKhLmSvwxOC1 gHiiZYsDVdI0DS6/yoOU3d2IjW3kS0u9umKDtPmgnjR6gLoFlRAZm1r5c55NFjc5PcWF DbCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Yt9oE0kz3TmH5FGxe6pEDCKgvRvBbOAA/ay7EMCbyEc=; b=M0x/CDrKQSf5rtx0Pf/j7MTWbcgQ/c6Y7mPqMX0U9astsppNhfXIxkWN6i43oqmyBT INgOPO7C0SQBJNLoOZSHH+UbJQiTogT13GRIgSEE2s24qZ0XDE42QexwpW7n0TVtuL9L lBCHI9UfUKNvaszdbvKRXI4vN0p3NNudDArOAXslvPE6NgqOueGqJoJXnvIwRnkhjBQm x5tlrEMODcidm3E4Q5fBR9L/rMQkmI/vU89U5sNERd146X3Sd3J8Co96qhJCtsfiB4qp JiIfq9xxkCh235rizXkk/RyGLCbMY0E5QMKkMf6qDoli/g3puQBELx/CatNAXwxjOY7G KL5g== X-Gm-Message-State: AJIora92K1SNtqoI+ET6fgc1Z/XY0NB5+8YEQdoruoD4lG8UoxZ9lLwk HCp0NQNlxOzYxAUOpib3Ctld6g== X-Google-Smtp-Source: AGRyM1vgtGvBYkyh0ni5e/mqVLrnNK1+XKLqZyiT0UcMq2k28Wiwo9nZP6ot9un6Y/cxDUraL3c4cg== X-Received: by 2002:a17:903:1208:b0:16b:81f6:e992 with SMTP id l8-20020a170903120800b0016b81f6e992mr29233754plh.55.1658157998529; Mon, 18 Jul 2022 08:26:38 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id h14-20020a63e14e000000b004161b3c3388sm8342392pgk.26.2022.07.18.08.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:26:38 -0700 (PDT) Date: Mon, 18 Jul 2022 15:26:34 +0000 From: Sean Christopherson To: Chao Peng Cc: "Gupta, Pankaj" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org, Paolo Bonzini , Jonathan Corbet , 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 , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song Subject: Re: [PATCH v7 07/14] KVM: Use gfn instead of hva for mmu_notifier_retry Message-ID: References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-8-chao.p.peng@linux.intel.com> <20220718132950.GA38104@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220718132950.GA38104@chaop.bj.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022, Chao Peng wrote: > On Fri, Jul 15, 2022 at 01:36:15PM +0200, Gupta, Pankaj wrote: > > > Currently in mmu_notifier validate path, hva range is recorded and then > > > checked in the mmu_notifier_retry_hva() from page fault path. However > > > for the to be introduced private memory, a page fault may not have a hva > > > > As this patch appeared in v7, just wondering did you see an actual bug > > because of it? And not having corresponding 'hva' occurs only with private > > memory because its not mapped to host userspace? > > The addressed problem is not new in this version, previous versions I > also had code to handle it (just in different way). But the problem is: > mmu_notifier/memfile_notifier may be in the progress of invalidating a > pfn that obtained earlier in the page fault handler, when happens, we > should retry the fault. In v6 I used global mmu_notifier_retry() for > memfile_notifier but that can block unrelated mmu_notifer invalidation > which has hva range specified. > > Sean gave a comment at https://lkml.org/lkml/2022/6/17/1001 to separate > memfile_notifier from mmu_notifier but during the implementation I > realized we actually can reuse the same code for shared and private > memory if both using gpa range and that can simplify the code handling > in kvm_zap_gfn_range and some other code (e.g. we don't need two > versions for memfile_notifier/mmu_notifier). This should work, though I'm undecided as to whether or not it's a good idea. KVM allows aliasing multiple gfns to a single hva, and so using the gfn could result in a much larger range being rejected given the simplistic algorithm for handling multiple ranges in kvm_inc_notifier_count(). But I assume such aliasing is uncommon, so I'm not sure it's worth optimizing for. > Adding gpa range for private memory invalidation also relieves the > above blocking issue between private memory page fault and mmu_notifier.