Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1726490rwb; Fri, 5 Aug 2022 06:57:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5HI2KAsqi0wTMtQ33nwBXpfklsgd9OIpKT+I5BvciGJSqKxwwtwPVPfj7GHoCXKda+lzDg X-Received: by 2002:a05:6402:1d4c:b0:43d:debb:5667 with SMTP id dz12-20020a0564021d4c00b0043ddebb5667mr6679240edb.140.1659707825547; Fri, 05 Aug 2022 06:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659707825; cv=none; d=google.com; s=arc-20160816; b=zMR0f7JCV67mYTPk4K2C1059mPHnGukDi6tf+SJPTq2cLEfAEWGNUbKGkbxjo5YD+k gmFGYWgboABTuq30KsLAC7ItWt2bygidglkbjpm7ZFskRAjMUIW1ewbcoqJ6vV2C04lE WwQlh9ohb2dIx5PvCZFbOz6kWQT9Bf+XWtk5f465ZV4cV9mgLScv/OTyBMhiqr446+U3 SYRRaUVqDkfE5umWMkKKBC0ckdKjbB/PpMssVCRw9wUK93KUEQn6Pb/hldVKxJx+gMEM RyI+Nc2U1fkfYd785J8M7dU/gaH/15UgvxzipC5/Ht6IvvncqNXvwQfbwLJzNP+heuUe J3Cw== 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:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=cvTnOWMtENdA0lewWHSDMt4C5p+Z0vLjSaKneQSan0A=; b=i749GYLSdJNxvg5LdyfOY5ecKb3gXefDRij4/wcANJsVwjaBZQpCrBFeb5zWK1Mh/2 Abwse5Co9+pWUVdmRr+/DRNza4CsvU+A0Uokwk3TREUW5mmhMEtOMF438h8MK948xhic QXBYJmYRHTOhE61QjddAsbe+HOGSMA3rkpg3xuhiWPABFI8p9hAUMxfkOMrZQkS4u6XS L8Q0h1q9dhJ5VzVVPnuJ4pBwbtyZFVQ8Ar9MEMiiOJTM101dvLpiqLkw+5amUgdVabQ0 gjVgq+sIZUVruvSVLYjln7wpFv60x+tsxOsoK2vcU6IW1VdlKrRLuufOSDESpsEhcMEB mfIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MSyBv72b; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a1709065e4e00b00730663586fbsi3391148eju.868.2022.08.05.06.56.40; Fri, 05 Aug 2022 06:57:05 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=MSyBv72b; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235412AbiHENXH (ORCPT + 99 others); Fri, 5 Aug 2022 09:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235985AbiHENXG (ORCPT ); Fri, 5 Aug 2022 09:23:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C65C1C122 for ; Fri, 5 Aug 2022 06:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659705784; 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=MSyBv72bxSAo5Jj4RwDbNpd9f/GBm559GaoTwgDIYTbTQnfMuYfxvbcvotyTLkkQ3KWSl2 n4GBLE+/3XrE3DbREuWYBKluAANbXpp59GH4kGMhmWHdlKVamAxNMrIJ7jUkRx9detw+0K lETpc2KbxTxmqpq9VGdyJ9Q6iFD8+eM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-344-JY_XTT3YNhmMSYy2Juz4AA-1; Fri, 05 Aug 2022 09:23:02 -0400 X-MC-Unique: JY_XTT3YNhmMSYy2Juz4AA-1 Received: by mail-wr1-f72.google.com with SMTP id v5-20020adfa1c5000000b002205c89c80aso489879wrv.6 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=T8XYwWJyj1btZsdK6j9N6RJd2F0InPSi0VJyHRa83Hxr27vo/aukruVHHsQlnmB5Sc jQZQg1kxHGREuDDd+L9lpHJ5sMyWNdG+fdGmzq4/fLuuSq6ZzGGO4CD1VicNV0MsNqEm maTHG0+8KqEJlMViO3RRr5FJucJPOLPdBOkgUBdi183Bzgb2N3xDh2iuOR+zkxS4fcBZ Wpt0KKcNNJ7zXPEYgk+ENaM3V+OoNPo+m4Xk411G0hc1nOUj4vB08kQdtkyJr6/xAe/p Q/o1lSkCD/9AQPdLnC8vtRwjHRnUy/H2U9ogWQFNn3rnO97A+Xnn8ZFkxIMgTMSLU9Bj oa/A== X-Gm-Message-State: ACgBeo1wzXX1s19RUAXQEi8Z0Gfo2p7tG45yCnjD/Wvsz7jByYnauf05 ICx3QVi/qhAOhSNyag5DP8nxNPDqmUsR0cYb2XiwccAlZlHQAgmurQgya8usWTIY6fPDgIzGzW1 cksxfQmbTYllTS+QemVesDfpv X-Received: by 2002:adf:ce92:0:b0:220:5ef0:876d with SMTP id r18-20020adfce92000000b002205ef0876dmr4402383wrn.647.1659705781190; Fri, 05 Aug 2022 06:23:01 -0700 (PDT) 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 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, 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 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_NONE,SPF_HELO_NONE,SPF_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 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