Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp20809rdb; Fri, 1 Sep 2023 21:01:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4hvwmwmDZiJSG6TLl925qZ2U3lHWanu+eX3sRBK57nNSQk5uGLETKzrCmQPv+dNCPCI7c X-Received: by 2002:a19:7706:0:b0:500:bf56:cca6 with SMTP id s6-20020a197706000000b00500bf56cca6mr2343003lfc.53.1693627310969; Fri, 01 Sep 2023 21:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693627310; cv=none; d=google.com; s=arc-20160816; b=nhnZd4Ml+RhnFkm4HSCaZHoHtxwXvk36EQ5k3+oJ3NbxTk6b/WGn4cnX+jkfP27pDe NVuntwrkU2dzLdxadIkqraBIenQ79BApBtNA0KWPpZD0T9NWy2ax0EXCKbl5ZjSx/3J2 avCxFTu3TtjsYQt/PZdAp6d/MYXtMPIucyOjfWYiv/KmlfHkLhi+Xu08/wYV7c6QX2Ni 8LOsLUWZQNrmW/NJJQuNeF90F7yJRkoPILjQQ/hu/qXWTpC7Bx76flfXqH5Vg9o/YuLd XqnCC5cb4ERJ9MdpFlmw6tGAy6dR1Ot9IUOthAzToUFexN0/OU3XNsXBO6Nk9wIsuwSt 4m3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version :in-reply-to:date:dkim-signature; bh=xCon5474F9WwphxhfgFhUzbwn0ALvK9xFv6P5Xz3AWM=; fh=ihFhJ8u1imu6e/bk3TGo9w5OTCG4UZapmcyqDnEqMOM=; b=nEGqrq3xkgGPTVMePfkHICqxTSwxjjyIAeg4ta/cXQg1J5l2FwKRm62neqrRoYLLIW FMs5a6WfmP3is2AEHKnWfkeU3Wz50BCP564z9yVzYu2LD3S9d3KdYwxsY5VD2NH0TMJn nk1E5To/5AbU5H6Lhg34Rp88Tmj0+tyc5VircVDUU1F5J0JG2NrID/Lfm9aPU3+HO4GF qgQWPMoZV31uHbh4DPa991eToH0v0/zvjVXilhAi5QnFSR5LIn9Hr/IHeoEUx3fsOh1m le9OMmLYKKB6gqr7o4PNmBMeH8PVen2jdjXxa6RCRWMRhV/TAtpEjdu9R7q7fq1KODk3 OY/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hqU4wmxb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020aa7c645000000b00529fa153875si3338927edr.481.2023.09.01.21.01.21; Fri, 01 Sep 2023 21:01:50 -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=@google.com header.s=20221208 header.b=hqU4wmxb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245400AbjIAQqh (ORCPT + 99 others); Fri, 1 Sep 2023 12:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345685AbjIAQqg (ORCPT ); Fri, 1 Sep 2023 12:46:36 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44335E72 for ; Fri, 1 Sep 2023 09:46:33 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-26d1ec91c8aso2482754a91.2 for ; Fri, 01 Sep 2023 09:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1693586793; x=1694191593; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date:from:to :cc:subject:date:message-id:reply-to; bh=xCon5474F9WwphxhfgFhUzbwn0ALvK9xFv6P5Xz3AWM=; b=hqU4wmxbesZHmpksagWiQXpeohEWVSELxtPPYGBcPYGHLzd4PgAZfKgihohM8nieNL x3j7YDZ7OFe1og77j691yrddLu54oFaBwlTOnLguDHh5p7+BR6+/NS0Pvahur84Awr49 bkuD34JPS3lDemn9o374Aub5/hANryTKiGgwBpMkhQipD2xt1GjE8Tr7x8dvTJm1yuUP N4OflW4yEADxpThIY2D6fG6q7dWUsDZ8Me2Lye9Qu/RXCmRg6gJabmzXwP2Q72T9eIcR awghr/9a/lXoGNWrdpu9mabpbW5iiXix8awk61LcoVpzwdYHAKz7wJ9oNjs2LMhAzZ1M yjWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693586793; x=1694191593; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xCon5474F9WwphxhfgFhUzbwn0ALvK9xFv6P5Xz3AWM=; b=EddSTv9oQxjsJVGz/F0TT/kSFK3uCzzjUyzwoA97QuXEtYxhRjTvCakw9qYQZa41PX 3XMvqpTSDgxm4vdvQdxbtFjuE7souFOr5H/gjv013s+nVZXZ81bbGUepfFKOSrZ7c0Sp bPR6NC70s8l8T65Afjg5EQv6dXsbCB+5H1Y5rzPXc5uq0gKd9Atxl+IF6BJtmnLMCZA5 vx/SgLrhRx8iuwrLIKbAaTBnIgG6Tpn17HG0BxDjWnERUvdiY54/KZSDwTmCApJgYyc1 d24bEzRqFrW0D+YceGQBV4r1ZBcfjr9OlmxVtxKscCRujkmtJdyye/PAWiTBmehm8Ykh tlJg== X-Gm-Message-State: AOJu0YySfS3ojLE2V05t9HpjRLc2qOdqfKg9TP8h35AEOYuAg/sM1USj RoMNy78dHccF/CEI54VKBePBJapT67ur1z3vRA== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:902:e887:b0:1bc:e6a:205e with SMTP id w7-20020a170902e88700b001bc0e6a205emr1066486plg.5.1693586792693; Fri, 01 Sep 2023 09:46:32 -0700 (PDT) Date: Fri, 01 Sep 2023 16:46:31 +0000 In-Reply-To: (message from Binbin Wu on Fri, 1 Sep 2023 11:45:43 +0800) Mime-Version: 1.0 Message-ID: Subject: Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory From: Ackerley Tng To: Binbin Wu Cc: kvm@vger.kernel.org, david@redhat.com, yu.c.zhang@linux.intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, chao.p.peng@linux.intel.com, linux-riscv@lists.infradead.org, isaku.yamahata@gmail.com, maz@kernel.org, paul@paul-moore.com, anup@brainfault.org, chenhuacai@kernel.org, jmorris@namei.org, willy@infradead.org, wei.w.wang@intel.com, tabba@google.com, jarkko@kernel.org, serge@hallyn.com, mail@maciej.szmigiero.name, aou@eecs.berkeley.edu, vbabka@suse.cz, michael.roth@amd.com, paul.walmsley@sifive.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, qperret@google.com, seanjc@google.com, liam.merwick@oracle.com, linux-mips@vger.kernel.org, oliver.upton@linux.dev, linux-security-module@vger.kernel.org, palmer@dabbelt.com, kvm-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, pbonzini@redhat.com, akpm@linux-foundation.org, vannapurve@google.com, linuxppc-dev@lists.ozlabs.org, kirill.shutemov@linux.intel.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 Binbin Wu writes: > > >> >> I'm not sure whose refcount the folio_put() in kvm_gmem_allocate() is >> dropping though: >> >> + The refcount for the filemap depends on whether this is a hugepage or >> not, but folio_put() strictly drops a refcount of 1. >> + The refcount for the lru list is just 1, but doesn't the page still >> remain in the lru list? > > I guess the refcount drop here is the one get on the fresh allocation. > Now the filemap has grabbed the folio, so the lifecycle of the folio now > is decided by the filemap/inode? > This makes sense! So folio_put() here is saying, I'm not using this folio anymore, but the filemap and the lru list are stil using the folio. >