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 A26FFC00140 for ; Fri, 5 Aug 2022 13:23:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCD3A8E0002; Fri, 5 Aug 2022 09:23:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7D248E0001; Fri, 5 Aug 2022 09:23:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCE4E8E0002; Fri, 5 Aug 2022 09:23:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ABBB48E0001 for ; Fri, 5 Aug 2022 09:23:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 77588418D7 for ; Fri, 5 Aug 2022 13:23:04 +0000 (UTC) X-FDA: 79765604688.13.8AD001B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 744EB180025 for ; Fri, 5 Aug 2022 13:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659705783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cvTnOWMtENdA0lewWHSDMt4C5p+Z0vLjSaKneQSan0A=; b=iHMUxtcTYjY2UrwOyv3Xi0gmMh+7Bkox1NpSLYi4Eh8gsDf2iwLbBocutFX2mxJr1RIO1e OB1XhmfPVn65QcUUGz+LfN6rYK1IZ5zmLHzRF/g4dWcBHX5CiY6ayJiTVG2FSKj7seWwdj LkZIbbEfVjE7d93h8NoJ83WKZNWaRiw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-3k1Csbr6M2aEL0qKMU9GOg-1; Fri, 05 Aug 2022 09:23:02 -0400 X-MC-Unique: 3k1Csbr6M2aEL0qKMU9GOg-1 Received: by mail-wr1-f70.google.com with SMTP id x5-20020adfbb45000000b0021ee56506dfso496411wrg.11 for ; Fri, 05 Aug 2022 06:23:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=cvTnOWMtENdA0lewWHSDMt4C5p+Z0vLjSaKneQSan0A=; b=x7tZFnFLCL2udLAvBarVpqUCQUPBuAMwMkRDTpUiDjUIV+/4k2Y40v46DxnM9D+LI3 mqthEK7yF5S5RKr9n9DX4RReS6rbuTxC+ERt1+X1S9kUL1Ru/kZscv3Va4cX/OX/m/4x AWxIBXKBtjoqRVRqFGIF46qetUTk0i+AJSKG+66YdUbhOJO7l92IFmmNlsJjoL8SDsnT 4IIy1MBptCZF0U5XElQ0Kex2pvm6LSzfWltxgxLquajeUe3rivE3+sAqBczbr9MQZgDH wGaihiv78aM9kUt3/kJo0p5aVDFuEEqYtRA3+r3353q9+xCzC966Jlv6z/rey3GH3ISJ bpQw== X-Gm-Message-State: ACgBeo1ieU63ZmzGNBYEXDebnWT1faLRhKzfR8BdcL9Y6lSIJp6e6mZ9 mQyc5CtyL2J4anxiRT6721bh3/0qapcwA2BhU5NMu5BMLGniLB7TPnG3ekcQxHP5ImdNKqrWdJn VRuhM0nY7ZK4= X-Received: by 2002:adf:ce92:0:b0:220:5ef0:876d with SMTP id r18-20020adfce92000000b002205ef0876dmr4402390wrn.647.1659705781190; Fri, 05 Aug 2022 06:23:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4uPBaWEs/z4mc87PDNQd0FqLSk3+CEo5G4UY36ZDFdxSdxTMNZ5FFOGBR2vXXQe8nDaUxZUw== X-Received: by 2002:adf:ce92:0:b0:220:5ef0:876d with SMTP id r18-20020adfce92000000b002205ef0876dmr4402357wrn.647.1659705780923; Fri, 05 Aug 2022 06:23:00 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:fb00:f5c3:24b2:3d03:9d52? (p200300cbc706fb00f5c324b23d039d52.dip0.t-ipconnect.de. [2003:cb:c706:fb00:f5c3:24b2:3d03:9d52]) by smtp.gmail.com with ESMTPSA id h36-20020a05600c49a400b003a2c7bf0497sm4326304wmp.16.2022.08.05.06.22.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 06:23:00 -0700 (PDT) Message-ID: <13394075-fca0-6f2b-92a2-f1291fcec9a3@redhat.com> Date: Fri, 5 Aug 2022 15:22:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Chao Peng , 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 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 , 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 References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-4-chao.p.peng@linux.intel.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 03/14] mm: Introduce memfile_notifier In-Reply-To: <20220706082016.2603916-4-chao.p.peng@linux.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659705784; a=rsa-sha256; cv=none; b=597NEGJQBoMz2ejHExHtTRvijg8uQzTb/Mcpj4Tg5VIK2htDlC3MLZVScsGr4oi01YlJVD zuoFTz6SIWlX8dlwucuhuO8Vne9uWy7QzWzYR1ehG+kS0imXmTpn+/qx87DvbAkvwivlQk T5FTCYss3Aex9nvlJTiAROOBF7Y6q5c= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iHMUxtcT; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659705784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cvTnOWMtENdA0lewWHSDMt4C5p+Z0vLjSaKneQSan0A=; b=E5Gy3vtmhcVYXBUc/itQ4hZGtK4zltL0f2/5nhhRK0bZL/yDZO6tjmn1CVZpr7PA/IM+3g 2F3Mrg9ztsb3LC5Y2uD2ETSUQM66niEH5WHGtq7ulgIdL+ZhtbLhPYTqhMbRvvc+E98DOx z0klx92eH4q2IIQrxzDUkiZFp5ii8L8= X-Stat-Signature: a8ica8itwc7crjps43bcx79p96rtrj6f X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 744EB180025 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iHMUxtcT; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspam-User: X-HE-Tag: 1659705783-447502 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 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? > > 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? 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. -- Thanks, David / dhildenb