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 1A5E9C43334 for ; Thu, 21 Jul 2022 11:07:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A00D88E0003; Thu, 21 Jul 2022 07:07:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B1798E0002; Thu, 21 Jul 2022 07:07:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 853EC8E0003; Thu, 21 Jul 2022 07:07:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 76D1A8E0002 for ; Thu, 21 Jul 2022 07:07:50 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AE072160876 for ; Thu, 21 Jul 2022 09:50:25 +0000 (UTC) X-FDA: 79710636810.03.8AB6B7F Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf24.hostedemail.com (Postfix) with ESMTP id 74F59180008 for ; Thu, 21 Jul 2022 09:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658397024; x=1689933024; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=Ac+0RLuL49DbuWul8+wP6iRaArHsOfPE0tmeiZTP7OA=; b=N5prSzc6M5cg8s9nItwwlJ6hNmbA+aCD4LRaf3yH4ZcjMxMUwVx8bVwS KAHqLmjl71wNXkcki6WAF0rDxFm/en5OwQ5+kyLaUf3y5USBizetNBc4H FEGcVESAv/x2IXAeDPo3f/VeLZ+bd1yXupZfZSLU5OQO7GMf8da9Z9G+o mduxkmfCgiSykW3R0GoSMPqWb82xnmYeuuoCUTjk7it14jiVZM9ukpRRd fzAnxqbU2PL+EwlUFNaqiepxz1/GMXjmBIDpnJ94ETY61o0v5D/Agyql8 F/OgMjbv3B8t/F0XX5Xk+jIQIYOjg/YSsb+gp7BbFKtaAkjxSYhJF18eD A==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="267401036" X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="267401036" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 02:50:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="626050085" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga008.jf.intel.com with ESMTP; 21 Jul 2022 02:50:12 -0700 Date: Thu, 21 Jul 2022 17:45:23 +0800 From: Chao Peng To: Vishal Annapurve Cc: Xiaoyao Li , Sean Christopherson , Michael Roth , "Nikunj A. Dadhania" , kvm list , LKML , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86 , "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Yu Zhang , "Kirill A . Shutemov" , Andy Lutomirski , Jun Nakajima , Dave Hansen , Andi Kleen , David Hildenbrand , aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , mhocko@suse.com Subject: Re: [PATCH v6 6/8] KVM: Handle page fault for private memory Message-ID: <20220721094523.GC153288@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220519153713.819591-1-chao.p.peng@linux.intel.com> <20220519153713.819591-7-chao.p.peng@linux.intel.com> <20220624090246.GA2181919@chaop.bj.intel.com> <20220630222140.of4md7bufd5jv5bh@amd.com> <4fe3b47d-e94a-890a-5b87-6dfb7763bc7e@intel.com> <5d0b9341-78b5-0959-2517-0fb1fe83a205@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658397025; h=from:from:sender:reply-to: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=MSlvy4NJIOPTojEOT0cLhsUyDkOZ69G7WvNu72wmJRM=; b=AN7Rx/Xf0L5LsBpbvVMUY6DaFtTVmlJhXNMAh8oQzsE9jbtihRV4ZQq1iT6pTpdQYN1Ryk LF2nasLk71d3r6xPcg/swr5MAkBAa9a2YRJ8DVEy1HAdSIo/Tk9bKnjMdb/EZdcTDqZhiz 2/cvWmZfS6aiVGsQTFFmiOnI7hMOq80= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658397025; a=rsa-sha256; cv=none; b=JDVXqCHwIUrbiWF3c7WNDdAyqjwN65yWU+NeB1XpIx48cz/povHSeXqhNnVX/lUofpDfpH TRSBCcBG0jMQSbNADassi1jZWETq4ZOaQIZQq5PwhPkWUxE+sZxIPpR2hQaxNtKm5Zo2VD BCEdHXO7GUn8t+1jipUATLYeVHOBTec= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=N5prSzc6; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf24.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=chao.p.peng@linux.intel.com X-Rspamd-Queue-Id: 74F59180008 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=N5prSzc6; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf24.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=chao.p.peng@linux.intel.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: uz6zxm956bs6f5uszdi7dzsoot4cqios X-HE-Tag: 1658397024-355714 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 Wed, Jul 20, 2022 at 04:08:10PM -0700, Vishal Annapurve wrote: > > > Hmm, so a new slot->arch.page_attr array shouldn't be necessary, KVM can instead > > > update slot->arch.lpage_info on shared<->private conversions. Detecting whether > > > a given range is partially mapped could get nasty if KVM defers tracking to the > > > backing store, but if KVM itself does the tracking as was previously suggested[*], > > > then updating lpage_info should be relatively straightfoward, e.g. use > > > xa_for_each_range() to see if a given 2mb/1gb range is completely covered (fully > > > shared) or not covered at all (fully private). > > > > > > [*] https://lore.kernel.org/all/YofeZps9YXgtP3f1@google.com > > > > Yes, slot->arch.page_attr was introduced to help identify whether a page > > is completely shared/private at given level. It seems XARRAY can serve > > the same purpose, though I know nothing about it. Looking forward to > > seeing the patch of using XARRAY. > > > > yes, update slot->arch.lpage_info is good to utilize the existing logic > > and Isaku has applied it to slot->arch.lpage_info for 2MB support patches. > > Chao, are you planning to implement these changes to ensure proper > handling of hugepages partially mapped as private/shared in subsequent > versions of this series? > Or is this something left to be handled by the architecture specific code? Ah, the topic gets moved to a different place. I should update here. There were more discussions under TDX KVM patch series and I actually just sent out the draft code for this: https://lkml.org/lkml/2022/7/20/610 That patch is based on UPM v7 here. If I can get more feedbacks there then I will include an udpated version in UPM v8. If you have bandwdith, you can also play with that patch, any feedback is welcome. Chao > > Regards, > Vishal