Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4385538pxb; Sat, 12 Feb 2022 03:26:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOOAGv09co/GTBq8wH1W6K4EfvLGtJTIOW2QmfVV2DHtvK/6XvCheM8JUBCowGig8vy3jS X-Received: by 2002:aa7:c647:: with SMTP id z7mr6312449edr.228.1644665192820; Sat, 12 Feb 2022 03:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644665192; cv=none; d=google.com; s=arc-20160816; b=gesrKcCVbUI7viQzKJxicPnwJHfFo+974ndgewKPBhRu6XTifZd9l5+A2hFX977q33 wY1WmBGDlLQTo0pC0ta8Kh2Di9EhXl5O5ZNeebUBl0/Pavsq7XDyUufjKArjldSH5/gb e5VREqZQJnE1IWfLvkRTMyFsEOuyDo7QqWJn9RZhTrD++af3RwQ/zmHLQ1UEJyaN+8cv cXQAzQB7HTM9+jIo3nsk9tZGAPC39jnh4Sc/S2IoTZqbk1F394d9RYcIZa1AB25eM1RE LuiERgHkEtdFjV0k7ZFvWvWncBKiRQ8WhOiNic/IDz3kkqrmn4UN3IFcxJrQER9s9Fds w5+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=MiD/PIuEx7fcHswYzGn9Yl7plcZ0o0VPROgnGKxZ6qQ=; b=R8THmBlaB8hH3f1rKNu1SUdrATbf9CZEqQN+33iNJtt8SX9JSnDpYSywuVmylbZ9ZU cg585mMlFTcP0W3ygRzpXd2Kwquwh77kyfhjfKHL8oLdVhH9m5M/n+Wq7qTHk90C2C2g M0G7HZU5k9nBdOh3P2Z61RGRnitphUjv3JDZC75xJ81ZaOjA/gcV9Y9QdZ/I8/+Akp+s j4zxDxdTpjcSvQdKMXRBhRY1IuzTD9FF7nnROgWyeWs9VqRpNfGnFCGrM7Vz0qC7tttg WysfXn/OO77erkKeRXZS1ngp9vSG2JT8Z5W3xdmyUX2H28IQvGsQrFWt7knRB2E4CXPo 0BMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HxHkOQCy; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17si13914797ejm.469.2022.02.12.03.26.09; Sat, 12 Feb 2022 03:26:32 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=HxHkOQCy; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354255AbiBKXkV (ORCPT + 93 others); Fri, 11 Feb 2022 18:40:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238960AbiBKXkQ (ORCPT ); Fri, 11 Feb 2022 18:40:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA6ECF9; Fri, 11 Feb 2022 15:40: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 ams.source.kernel.org (Postfix) with ESMTPS id 10433B82DD0; Fri, 11 Feb 2022 23:40:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6B73C340E9; Fri, 11 Feb 2022 23:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644622811; bh=qjDhoyLBnjObhE+qaWk23jxLof4n/h4IluDmsF4S+Zc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HxHkOQCy8wBjoXjL70TshCgTZJSE9ew2DxDnJ18jj/4/DZV2JSnnbrH8FYWN5XOpz 7Ti0r5fW2KunCYfy9nEiI8B7VECUh3JugBLGRtdOucxqELydi8URSwwK5ypcHOgllo JURaNYZHo4Vvle1HwR+VFcqPtgpSAnhTW53ToVTE6/tophEv+r9/HuKCXdTKs+SzCs XXl3/zxMMecQoDvxqQcHzdXmfIB4/8dL1CNJeB9yr2QyMFVgooY3uJs2SsYqA9Nr/i 6cmkPGk37vDLzgx5UttouMfTOmgXCX6jZbciQMJBcUR5bRSeqHpTIXNgrJGAVebGls Ml6ubZ55tvGsw== Message-ID: <314affa4-fbcb-2cb9-deb7-f61a2ac99260@kernel.org> Date: Fri, 11 Feb 2022 15:40:09 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 04/12] mm/shmem: Support memfile_notifier Content-Language: en-US To: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org Cc: 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" , jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com References: <20220118132121.31388-1-chao.p.peng@linux.intel.com> <20220118132121.31388-5-chao.p.peng@linux.intel.com> From: Andy Lutomirski In-Reply-To: <20220118132121.31388-5-chao.p.peng@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,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 1/18/22 05:21, 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 > 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 > + return ret; > } > +int shmem_get_memfile_notifier_info(struct inode *inode, > + struct memfile_notifier_list **list, > + struct memfile_pfn_ops **ops) > +{ > + struct shmem_inode_info *info; > + > + if (!shmem_mapping(inode->i_mapping)) > + return -EINVAL; > + > + info = SHMEM_I(inode); > + *list = &info->memfile_notifiers; > + if (ops) > + *ops = &shmem_pfn_ops; > + > + return 0; I can't wrap my head around exactly who is supposed to call these functions and when, but there appears to be a missing check that the inode is actually a shmem inode. What is this code trying to do? It's very abstract.