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 20659C433EF for ; Thu, 17 Feb 2022 13:11:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FF226B0074; Thu, 17 Feb 2022 08:11:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF776B0075; Thu, 17 Feb 2022 08:11:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84F3B6B0078; Thu, 17 Feb 2022 08:11:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 76F6C6B0074 for ; Thu, 17 Feb 2022 08:11:07 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 47C4412098F for ; Thu, 17 Feb 2022 13:11:07 +0000 (UTC) X-FDA: 79152307374.01.489CC84 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf17.hostedemail.com (Postfix) with ESMTP id 21CAC40008 for ; Thu, 17 Feb 2022 13:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645103466; x=1676639466; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=3j1F15BrCbKN2Xpg8Gu2Cb+UfX7fWFXHLd+x9nlgm/s=; b=jziW/xClDS3HIWj4fzMMa9JtivGNxni87xPzKfO3jpbNMnQ0mXCdQrVQ 1mgMkCDivDWudja8agjEv1QlPBSlkDO/Cnat1xzXzsTp9ySM1nOFLhM2X UPx9el7/9JhMC9Y39byBkuoMTtRtT8OTzAcVlz7GxVwZEJ/ggW75LwSYF T4qLNgWvg0d6BscBYOaLykhSKOP981jZ00JUPzbcHsrtqnqGsdBlOsx5+ bW4nDz7+TO/dTGqqu2KwLv+eDzopsVnLmKPEW3534/YJGojv5YgfIysMW SrdLEXsrhaSk+5gEsK7bfHqu+srrSeTCIjL4mkw2G5Hkd6M7s1pbVhcwX Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="249704897" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="249704897" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 05:11:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="704791747" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by orsmga005.jf.intel.com with ESMTP; 17 Feb 2022 05:10:57 -0800 Date: Thu, 17 Feb 2022 21:10:36 +0800 From: Chao Peng To: Mike Rapoport Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.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 , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com Subject: Re: [PATCH v4 04/12] mm/shmem: Support memfile_notifier Message-ID: <20220217131036.GC32679@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220118132121.31388-1-chao.p.peng@linux.intel.com> <20220118132121.31388-5-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 21CAC40008 X-Stat-Signature: ybpoe3jyrg1d5re9ydgazg6poxr96bxf X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="jziW/xCl"; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf17.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=chao.p.peng@linux.intel.com X-HE-Tag: 1645103465-17930 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 Tue, Feb 08, 2022 at 08:29:56PM +0200, Mike Rapoport wrote: > Hi, > > On Tue, Jan 18, 2022 at 09:21:13PM +0800, Chao Peng wrote: > > It maintains a memfile_notifier list in shmem_inode_info structure and > > implements memfile_pfn_ops callbacks defined by memfile_notifier. It > > then exposes them to memfile_notifier via > > shmem_get_memfile_notifier_info. > > > > We use SGP_NOALLOC in shmem_get_lock_pfn since the pages should be > > allocated by userspace for private memory. If there is no pages > > allocated at the offset then error should be returned so KVM knows that > > the memory is not private memory. > > > > Signed-off-by: Kirill A. Shutemov > > Signed-off-by: Chao Peng > > --- > > include/linux/shmem_fs.h | 4 ++ > > mm/memfile_notifier.c | 12 +++++- > > mm/shmem.c | 81 ++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 96 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > > index 166158b6e917..461633587eaf 100644 > > --- a/include/linux/shmem_fs.h > > +++ b/include/linux/shmem_fs.h > > @@ -9,6 +9,7 @@ > > #include > > #include > > #include > > +#include > > > > /* inode in-kernel data */ > > > > @@ -24,6 +25,9 @@ struct shmem_inode_info { > > struct shared_policy policy; /* NUMA memory alloc policy */ > > struct simple_xattrs xattrs; /* list of xattrs */ > > atomic_t stop_eviction; /* hold when working on inode */ > > +#ifdef CONFIG_MEMFILE_NOTIFIER > > + struct memfile_notifier_list memfile_notifiers; > > +#endif > > struct inode vfs_inode; > > }; > > > > diff --git a/mm/memfile_notifier.c b/mm/memfile_notifier.c > > index 8171d4601a04..b4699cbf629e 100644 > > --- a/mm/memfile_notifier.c > > +++ b/mm/memfile_notifier.c > > @@ -41,11 +41,21 @@ void memfile_notifier_fallocate(struct memfile_notifier_list *list, > > srcu_read_unlock(&srcu, id); > > } > > > > +#ifdef CONFIG_SHMEM > > +extern int shmem_get_memfile_notifier_info(struct inode *inode, > > + struct memfile_notifier_list **list, > > + struct memfile_pfn_ops **ops); > > +#endif > > + > > static int memfile_get_notifier_info(struct inode *inode, > > struct memfile_notifier_list **list, > > struct memfile_pfn_ops **ops) > > { > > - return -EOPNOTSUPP; > > + int ret = -EOPNOTSUPP; > > +#ifdef CONFIG_SHMEM > > + ret = shmem_get_memfile_notifier_info(inode, list, ops); > > +#endif > > This looks backwards. Can we have some register method for memory backing > store and call it from shmem.c? Agreed. That would be clearer. Chao > > > + return ret; > > } > > > > int memfile_register_notifier(struct inode *inode, > > -- > Sincerely yours, > Mike.