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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DEAEC433EF for ; Mon, 18 Jul 2022 15:26:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79A9B6B0072; Mon, 18 Jul 2022 11:26:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 724186B0073; Mon, 18 Jul 2022 11:26:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C2B06B0074; Mon, 18 Jul 2022 11:26:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 494456B0072 for ; Mon, 18 Jul 2022 11:26:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F3C9174C for ; Mon, 18 Jul 2022 15:26:39 +0000 (UTC) X-FDA: 79700597760.09.58871AB Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf25.hostedemail.com (Postfix) with ESMTP id AE4AEA0098 for ; Mon, 18 Jul 2022 15:26:39 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id v4-20020a17090abb8400b001ef966652a3so18520905pjr.4 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=f4nq6uPxLPbtheX3zo4i6W/w1g5sXHKE9URnbn8b/1frWsiMwM3cZodoTu3bp11NqV 1d2aCZhbR9WTelrhs7q23nioCtm6rFsw9U/DOtwOGSEE57Q6RVp36UZ5u56J9RTv21N+ 8fA7eFll2AmsSr4Dq8VQgEhVYaTBg8o0k+Gl39hvD/ePfIbtBRnHRvzhhnHwNkfnf0hL rIUpXXddmIt9NfxjqJ1GsZnzRgHtrmu6F9V9qlflL+IUosikKmHYy3zVxSOqN95F7yrx B5SLfft5km1UEWNe7oEfxgB2WGsLZEz+ho/Id78yvOJ8tK0JTUUSgDzHzJvpCmZTDlUr iUbA== X-Gm-Message-State: AJIora/yFvg8RVz/g7viZChd4y+X53/FKL59ktXWtkI6vwbig5KMQdv3 bRmVxQtK1j9XdyAZ/5rzXdeOoQ== 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> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658157999; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yt9oE0kz3TmH5FGxe6pEDCKgvRvBbOAA/ay7EMCbyEc=; b=WQjc4FUGT+uxsE7t3ofv08lFgs0nrUIe6cL2D0tqo4ZjKz/6HL5Qq8E0bL503HIktY7Sig gkBnJiMQUZxgaOXe7xNyQFZ7NXxjFe8RbeDHa0YXrOtrtcjugpZu8/37FNmOU0VmEelqDW CQG6XJtBGE3eGhBimKbSVfMAef7rcBk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658157999; a=rsa-sha256; cv=none; b=XJIJa0Bn70B0GSTZ9B0+ZeOz5Nf5AqthaRHSp6fQtc+gGnhjwUdbr6HWX4CtePeTQt0rUK ux3SbczKyWhKecQLjGkeb+hdo1+wj60v/oACPtk26NelUX1+EIXSmXfq6ealrWPcZuhPu3 3fIVD9VFncOkBGP4/2ahFgSsfS3/aSs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Uff3ivfi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of seanjc@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=seanjc@google.com X-Stat-Signature: jfb79g1wts6wix83ics59etehjcz77cm X-Rspam-User: X-Rspamd-Queue-Id: AE4AEA0098 X-Rspamd-Server: rspam10 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Uff3ivfi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of seanjc@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=seanjc@google.com X-HE-Tag: 1658157999-812022 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.