Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp808121pxb; Thu, 17 Feb 2022 15:27:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnH/heIqRokkFT5tLfpVnis+luYTm2Qd6aIOt0E0p5aV5FpfH+Y4e/cHI3hoHDTdpDq7tF X-Received: by 2002:a17:90b:4a12:b0:1b8:d015:66db with SMTP id kk18-20020a17090b4a1200b001b8d01566dbmr5465765pjb.66.1645140462936; Thu, 17 Feb 2022 15:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645140462; cv=none; d=google.com; s=arc-20160816; b=wI8F9NWEzMiSSFc+9DNoP0PofaiEBjkQ+qxt5MeLCNWoiCgtTORV61A51f9gtdWhht 1p7OVm6cH+E5VQ5q2YHsV44zUECJxnjLhp/twwN797hbDyNRvCbYcnVmF9vhdyvqLHlU EkGmd6HiufuCeq+HP37Iy1TgGzYK3zqIQGLl2HwPj8btkEC0zxISFeZm9xLFa4zQuUgZ R0QTmEm/+Sy/cFkAWYUjRu+UNyHFHjSHOytQqDObH0B3TKWruKm9gxolHMBmkRZrbzbe 2EII3Mk1CXymqB9JmKnjv5WDZCeuE1IHeBsgVe6BQ+oji/i7hptSBXWPlnQ4T6DT7w9F yWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=KS0L6iNKNvfKjrU9ZDvs5EGXvhlJjcmjdLsUkAi5ecc=; b=Z81mf8ZkEqiKOAJzAABkIT3M30vZ4JGIqQ/aYwRuEhkbqPI4IcV+mgDNe5bD5zNUIV solMzkvDe2qhl5fzxIWlXcvY0tRroIRSiQr0R2KbhEFWhsSHzBs3vxU7ubwq4jDggYrA oLgKTxVzOc30zjr9Awpp2uGd8EWAl2x+HRjPx8Mwfzp9zxz2ZuH98gX0ujWqeC1aGHGF yZxr/w6ceEwhJsq/maNpHPNtYqi4d/eCJGBOh35kZBY6UHqsyXL20HGpRa++qIhxwfZ/ vzckKkx94Oib9O0DBO3WsKqhGCh4HPJfUmgD5cCInIvuGOk4+vSyrEf+NR0YWJMaLXzf auLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=B4TkHEmt; 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=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j72si9118327pge.724.2022.02.17.15.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:27:42 -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=@intel.com header.s=Intel header.b=B4TkHEmt; 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=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A3B05261E; Thu, 17 Feb 2022 15:11:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240745AbiBQNLU (ORCPT + 99 others); Thu, 17 Feb 2022 08:11:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232797AbiBQNLT (ORCPT ); Thu, 17 Feb 2022 08:11:19 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41EBA2AE285; Thu, 17 Feb 2022 05:11:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645103465; x=1676639465; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=3j1F15BrCbKN2Xpg8Gu2Cb+UfX7fWFXHLd+x9nlgm/s=; b=B4TkHEmt5MSPJ9UQlPQXluKIH+UFiTk4m0rIdL97p2J6nuLfZvS56Nmb hdjxUa7riYQJUN+PMZyFpGNTrbHsMecQ6ibTEnPpDVvhqxcyh5uMTXHew f7c/5nxA/tw8mO+n2e2VAAu/wi3ExIXP5kSHDK4ACJiF6o9aW4qxZjPOv kFId2eP8ZfSdZ9yJg4iB9FRtWD0DS8DyMABtoPrRTtZlXUZESnvOnsyPj CJuOi4twDnwGOJ4uYyu3KIzi4ej1Qev3b0BYnXuhtu32NTlucr2cnXj8v VyKy/U6porYWldpuFxumskQ6Uam2+o6LbY1coH4FWyL2D+5BwZoCpArbJ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="248465322" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="248465322" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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.