Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1828028pxb; Wed, 9 Feb 2022 05:27:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+/sQC6dTNUo6EuSXk+v7NByPFNcWTuq3EP2w7rhUAJN1Tdp4Kehq+F7/6pH2rQviwo+Pd X-Received: by 2002:a17:902:c94c:: with SMTP id i12mr2092273pla.139.1644413272941; Wed, 09 Feb 2022 05:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644413272; cv=none; d=google.com; s=arc-20160816; b=gqVIfGuF4To7TpxF7Z7AmN4g0tetpIPhSe9gauaOlwfT8Fq2p0kmmMHYAVTJaUMi/u hBWihzWYoNyjEeZdRVBJK9C05F+Q4irDWaBKFEJF7ZQwY3K6WnBnYC75rDl3IJkCYuN4 qf2qwUXgONX6Ho/KIFD1cjpujgmnUHswPL+pbK1PPxzpiqU9ngtfC4u3kYuB6TzXfRFS 0+3HM3ynYg1gOd9enEgddQTAIy3HILY0jDVZDkumVBMSdvcKChMCWJj72coQPYzjgt4C 09C3OjlHjBIEqlk6apumvEOVD21XEpDCw4NF2zg/vGRQqKj8MJ5HplMexsx++zBp95KB JqPA== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=HNFpiX0tDzYsTPOwIN5sAyU/3LRm/ntUvP+mZCHIDuI=; b=FYtjNa8k5V4Mt7EDl2asqDHYDROkY46MRUWwpnavk8IVcau+r/IEmJWFv8DiOfn2hZ jn1yHwrLhxT6/F9BVHayqUrRjFYBGvgrLvtu6CS8YfR12l1G1Z4eT8QRjZk2Nas/Ikxy 0Wf7IQYKQDs20nQZuicGfh7PuXuX4WKCF0KDulMeUGMsRJ3eOqxcJZQ2l9igkjyttjrI sBgLT1KGOw4b4znOJqKaUUsSp1jdBxfgoAjCi7lRrKif6OFZkh1MZviBvcgpY1ghJ5Kj YOyE8wMYo9QK4JYxmPNdmE01FkWAb0ku5z2rnmoL0tHTgZm/WL24EmhbikVMDGa9fbO3 mpDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="hU0/lVYy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id fz21si5161528pjb.58.2022.02.09.05.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:27:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="hU0/lVYy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04C4EE04A477; Wed, 9 Feb 2022 02:12:55 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384949AbiBHSaS (ORCPT + 99 others); Tue, 8 Feb 2022 13:30:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240912AbiBHSaP (ORCPT ); Tue, 8 Feb 2022 13:30:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187D9C061576; Tue, 8 Feb 2022 10:30:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 826EB60C03; Tue, 8 Feb 2022 18:30:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE202C004E1; Tue, 8 Feb 2022 18:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644345012; bh=K1+hCMMTsSLAKEwPC2EsRQPw6UUAUoQD7/b994l5uXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hU0/lVYyJT31vQOIQHTGA9EAF5MsH0yBJrrzVhzs5zFaILZgEK67dSeqfC+QFLTOv wDEHu/wGnGQw/izyM8f2rVPRjKCmfSIBJWN6OXDQqz9FlGcsE9HTE8xL9T+wK1nCqo VYSc96T4yxQHoazACG8qE7ItaZZ0/+e5f4t9qECopa0WKxq14XUpwujb/465+ADL4l ZrqaO8XGD1kFMx77cphrzAUlOLE0AJ1YRnylOk654H7ZFivYUhkhnpZdMA+z4jUb9o osb53N7WGxlLdzYzz0RvOz0lLWVajHKxZvJpjtYwCPk76/Ufz4GDZ4WuwK6HIcASMh DEm/eb7KgyCbQ== Date: Tue, 8 Feb 2022 20:29:56 +0200 From: Mike Rapoport To: Chao Peng 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: 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: <20220118132121.31388-5-chao.p.peng@linux.intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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? > + return ret; > } > > int memfile_register_notifier(struct inode *inode, -- Sincerely yours, Mike.