Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6879001rwb; Wed, 10 Aug 2022 02:49:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR7XvOaXirzn/tc7PHKDgc3649smypoF13igNWBf5Qf3icfmaccn0TpVztscUzMDd6QLBOrg X-Received: by 2002:a17:907:6e88:b0:730:e16e:b760 with SMTP id sh8-20020a1709076e8800b00730e16eb760mr18779771ejc.5.1660124963109; Wed, 10 Aug 2022 02:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660124963; cv=none; d=google.com; s=arc-20160816; b=hhB3tzl/GjDReuXuE7GX0U3Evoj/k9W9LXF21/8h860pET+8dklBRxzdEeKoZNWNxG 3DxXHJZMMMSXDH2+XOVJaL33hpITXAnl5Cz8Gk2957qbLl8GQNXsKNpVPYZgBt4+40NX qPR6gD90WznNOPLgxpmzwrLX88SC4ubKfOUES6k/DHdoqUrHnB8IqMMHiVm4X2P+xrFt SDqLsAZ2yB1hG7PgaZqJuwSvjzzHGEejhFtCrduZ10GS3DMTuTcmqepISscHiNpU6o4q EHhyWIlC47fA8QQlDXER+CbZcqpzpuRK9J5pACVFT/ngZpkX/ZBOAIoEaz/0XeizuM7x MUZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=m9RwcdbE135RLgIQTidnQ/zNOc1SX8Jwvi7nXKXVmpg=; b=KMdIas/gKBN4sVgkFCkBHMv1XPnrMM3HLXfQr3n21vhevwfu52m5Zz4z8UAPSnmXoK SWKydHOZx5scq/4P/PILvh9hx3Be8wCQN/CQpAshkv8vkJmIXJrojWP6oGXkCR+pt15W LbFetOBdpItmlgSkLH30zB3MD/BugrTTQfWjODLpcj/p+IGGH1+HvCAY1wijn+yyNgIl rp6qjZLr+aUSFiGJYF0G6CFT9XHxTSSAGb1j60+c+sctlRbFzs6RomsYn7oYXe7pjPsE TWb7tVF86G/wHOXm9Q/LyWim6bSNhWeYEc5/2H2Hd4oouwSO0amNb+76chyxqTRBnuuD hBeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="MM/P6jH6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a17090699c300b007330a081f1fsi1549160ejn.679.2022.08.10.02.48.57; Wed, 10 Aug 2022 02:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="MM/P6jH6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbiHJJ1m (ORCPT + 99 others); Wed, 10 Aug 2022 05:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbiHJJ13 (ORCPT ); Wed, 10 Aug 2022 05:27:29 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7D146B648; Wed, 10 Aug 2022 02:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660123648; x=1691659648; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=tUwaauJkG9H9jpzDjix3eFFhcAHzm8fbdGUPBBoncrI=; b=MM/P6jH6MliPsW0XXGQm0jiy++NWrykY/WTFdl9Jc01IEBqiretP+fpQ hGaRBEoOnUMsSrlpa429LIp4kagMjmbHkXqdNP0P84rpcs/wph62NHWD9 bktQIKk8sgWerQVShl45PjvqXGSr/oqob9WglaqCXg4c98TufQXDLATBo x9C0jCWj+ez5wC/+mTvfm5XWwbwwlY5nrbjPIW2DeB6iTBzaz3rWjEV6c 7jig7dUo/O+dreymwVjaqrLVay40KDxh9ROFzZ1p0xycaL7hcD8dFjyz1 5v/vxjgMEMc3AL7I6FurcDlLHgdgSe2Y/D2lJfcOQAO6uTX8/xx/6KS+j g==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="355042407" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="355042407" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.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> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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