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 45D57C00140 for ; Wed, 10 Aug 2022 09:27:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D55158E0002; Wed, 10 Aug 2022 05:27:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D04B28E0001; Wed, 10 Aug 2022 05:27:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA5568E0002; Wed, 10 Aug 2022 05:27:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AA6FA8E0001 for ; Wed, 10 Aug 2022 05:27:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B94E120550 for ; Wed, 10 Aug 2022 09:27:31 +0000 (UTC) X-FDA: 79783155102.09.112DD0C Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf23.hostedemail.com (Postfix) with ESMTP id 869D7140163 for ; Wed, 10 Aug 2022 09:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660123650; x=1691659650; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=tUwaauJkG9H9jpzDjix3eFFhcAHzm8fbdGUPBBoncrI=; b=E7F0KgtbRwZUV03ZZjlHUymsFyid9XTAm/0HpFxuEhRoDph7D450n6+Q dxqp6gnqDjQb61+6dPxpORi8pxCbGoazBq9UP1axfy1bYssoK2dPnfsTM BzpAhbIoyAxu6FZLu+JtjKAkDe68jMAWNcBgnXp/+ss78rC7srJWfpAIa Z7gLpt8BwXvp5EG991HYy8YN0Ldrz/B/UWwwB0KRgVAH+1/xhS6TjA6dn uLgNU/Uf9VHNRB20lbx49KmedM1UKpvzikPsJqeZ9Zeek3zRyP9oTJi5F 38CkY/ofjleNbz0HixPOdZW+/vBnVBkETqV95JPuvtJmZ0HURoAtJrXV3 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="291829404" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="291829404" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 02:27:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="664820289" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by fmsmga008.fm.intel.com with ESMTP; 10 Aug 2022 02:27:17 -0700 Date: Wed, 10 Aug 2022 17:22:32 +0800 From: Chao Peng To: David Hildenbrand Cc: 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 , 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 , 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, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song Subject: Re: [PATCH v7 03/14] mm: Introduce memfile_notifier Message-ID: <20220810092232.GC862421@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-4-chao.p.peng@linux.intel.com> <13394075-fca0-6f2b-92a2-f1291fcec9a3@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13394075-fca0-6f2b-92a2-f1291fcec9a3@redhat.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660123651; a=rsa-sha256; cv=none; b=AjDUIinmI7553j4dju+c2AC4zJsbLD+xNAZp315h3vOmroZcz6JlyKoqARXjWpeyMR6Vq3 BtXFDaTlXPSeJhIygxdX3cJHvJoIQWd031kAuZiGsQ8yMhl7sie28OLXzCLGFet7HmuszY plUX0NrUmFDuS2RI6082VKHOz1PS0z0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=E7F0Kgtb; spf=none (imf23.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=chao.p.peng@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660123651; 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=m9RwcdbE135RLgIQTidnQ/zNOc1SX8Jwvi7nXKXVmpg=; b=fK6S4t4QVb8XSrTxvLflh4THn+zni+GJqxKp/7xrocwTc0Eki12d4ZrZRGn1N7TsaERwlK ++kRxyu4uIFITJC/tZ+b2zXqUdQh8oc/RKq29Af5wkWbGHG0by9cLBjk8UtKSF9U30AAUx WrZJ42l2Dz6dQ7NgV3xXplyp6w1ZIoc= X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: my1yb7xn7dxm9bowxrqs3pau6msbfc9s X-Rspamd-Queue-Id: 869D7140163 Authentication-Results: imf23.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=E7F0Kgtb; spf=none (imf23.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=chao.p.peng@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-HE-Tag: 1660123650-245697 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 Fri, Aug 05, 2022 at 03:22:58PM +0200, David Hildenbrand wrote: > On 06.07.22 10:20, Chao Peng wrote: > > This patch introduces memfile_notifier facility so existing memory file > > subsystems (e.g. tmpfs/hugetlbfs) can provide memory pages to allow a > > third kernel component to make use of memory bookmarked in the memory > > file and gets notified when the pages in the memory file become > > invalidated. > > Stupid question, but why is this called "memfile_notifier" and not > "memfd_notifier". We're only dealing with memfd's after all ... which > are anonymous files essentially. Or what am I missing? Are there any > other plans for fs than plain memfd support that I am not aware of? There were some discussions on this in v3. https://lkml.org/lkml/2021/12/28/484 Sean commented it's OK to abstract it from memfd but he also wants the kAPI (name) should not bind to memfd to make room for future non-memfd usages. > > > > > It will be used for KVM to use a file descriptor as the guest memory > > backing store and KVM will use this memfile_notifier interface to > > interact with memory file subsystems. In the future there might be other > > consumers (e.g. VFIO with encrypted device memory). > > > > It consists below components: > > - memfile_backing_store: Each supported memory file subsystem can be > > implemented as a memory backing store which bookmarks memory and > > provides callbacks for other kernel systems (memfile_notifier > > consumers) to interact with. > > - memfile_notifier: memfile_notifier consumers defines callbacks and > > associate them to a file using memfile_register_notifier(). > > - memfile_node: A memfile_node is associated with the file (inode) from > > the backing store and includes feature flags and a list of registered > > memfile_notifier for notifying. > > > > In KVM usages, userspace is in charge of guest memory lifecycle: it first > > allocates pages in memory backing store and then passes the fd to KVM and > > lets KVM register memory slot to memory backing store via > > memfile_register_notifier. > > Can we add documentation/description in any form how the different > functions exposed in linux/memfile_notifier.h are supposed to be used? Yeah, code comments can be added. > > Staring at memfile_node_set_flags() and memfile_notifier_invalidate() > it's not immediately clear to me who's supposed to call that and under > which conditions. I will also amend the commit message. Chao > > -- > Thanks, > > David / dhildenb