Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp20701rdb; Wed, 1 Nov 2023 15:29:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHqd8llbeNZ0e4LCHeyJ4gxUJ6TCWlc3x3t/wIPX0QLBsV48blp/F13E9MtFeNHV8Kt2v5 X-Received: by 2002:a05:6a20:e10c:b0:17e:498c:bff7 with SMTP id kr12-20020a056a20e10c00b0017e498cbff7mr5712325pzb.7.1698877782997; Wed, 01 Nov 2023 15:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698877782; cv=none; d=google.com; s=arc-20160816; b=zoU/B87RWwQoJuNlS2TpXlvyHtKr87ZPDEW8tGGrMa0gKBgmCXjMCeaFK/O4Dnu/z3 QHYR8tC4otTFxIJKFqqB5qLM6hWQLmzF9LnTn2DekYRNY2pKjI3Z8asW6M8qXs94OL10 DRXlFAS4ITQJPxgx3k2ZsOA/fjdHjODXUCceS/QEZFVQ8mWxpwpHlWLoqRiibg2wX08i /mZHrLlLICNE/YmzOGHmjdyV08ftMcpUpDHd6X1fjYHG8rqFifNkQUvgN1gvLC3tM+ox 6fSPie/NQX83ZILXM7Wu9SsIuRz+JRl32NtKZVz4jL6sO5bPwj9MGeW/o7z2pzIiP+XF pVpw== 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:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=nWC5vyDZZRfa5huOPZv7psvbbvGG3qdcqN7MjpARvfI=; fh=iPK2Z2Sm2FQ79EBZwi8qTuYC4m+RG+tsn4pG16fm8PQ=; b=ffmoqcy8hQ/ZZlerB9s11a2b8sVBke+y1yAsy0rPZVxPHADobmlgHuFqxpySpR6PMO B7RWbShmZ7/8Ou+t1mdMFSwP0uhpQS0aSOt026TL8g0lkczor06ai2UuK8xoYeJZKl9W iCzuy6iqTPmrdPX6STh4BBVYTA1GqEZKvzHVgK3j7fhBfdxmv3UmanhvpUVov4yfsY3Z D731BtxswHZ18gIsbI8XR/XSBzXYShSF4vp5mJHYml8xf8QN+3wSNJD9IdMqobRzqYcI 7XR+GEfx6BrNDSl/6fIowhb5kcJm5J7R1ilGYgigIyvgQRS1V0yqOF+fTEVg9U4nt2Az 4BCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iy5abpAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k7-20020a633d07000000b005b9999ac677si685288pga.598.2023.11.01.15.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 15:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iy5abpAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8D1978065834; Wed, 1 Nov 2023 15:29:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345637AbjKAW32 (ORCPT + 99 others); Wed, 1 Nov 2023 18:29:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbjKAW31 (ORCPT ); Wed, 1 Nov 2023 18:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E1E119 for ; Wed, 1 Nov 2023 15:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698877718; 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:autocrypt:autocrypt; bh=nWC5vyDZZRfa5huOPZv7psvbbvGG3qdcqN7MjpARvfI=; b=Iy5abpAVlBU0rjwDZfNTX3y5q5dLKfAa6jjyyXvzsCo4OomRb/tnXx2EBMsuC+teTGH4Va 5tDi5vjUG88umytjNo/8E4xOEDasb/MIHV2yrah/oqZBnL1FONofEx6qxGGvhcy/O1KpOd GWFNcPX6hy9VY5YlsMp0ymm2kSatDdo= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-asciMCkhNHOerQilp-6LHw-1; Wed, 01 Nov 2023 18:28:36 -0400 X-MC-Unique: asciMCkhNHOerQilp-6LHw-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5400c8c6392so165866a12.1 for ; Wed, 01 Nov 2023 15:28:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698877715; x=1699482515; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nWC5vyDZZRfa5huOPZv7psvbbvGG3qdcqN7MjpARvfI=; b=PhLUItvp+BUH2tO5/1J2NnvMPyxzcXqa7IoE0qERq2ZwLiOWO3XNtzF689hXEepqvM MZH4cMGrT6V75Go0AluVfyYsDs7oYAqx+vftNj/PP4CCh1aNd8bsc08hTRCk1hn9qGmR Q4QYOtthGUXsNisidd6lU8mJVhu5XL6QoA3bd2qsbJAnUVTBkrsNqp4FFI2c7vll6hMt dngv1vLpe/x7m3t7Bl7PaesxzIfjVaGKNkQDAPAz2RZSkCOWn7/E6gyEnb/xn4m2ZiPn sRPnXtqgzhJfBRkytvr9dcWXB5u48iMjfi94fTAnlJucXTZDFmSuTVkomqekV1u/J+Fu F9pQ== X-Gm-Message-State: AOJu0YwsXV8v+97qAdYACl+ZOZ3jeJudscssOic3IwFM1FkcTYhWI6qN 2hZ2MNWoJZFT69jlQhmrbA3kmlq59ilLdX5wRFhzuVOGcrbelSGR4OhSnGaOKgzAzZYe99HLJB3 DSBOrOaLoh2470EhZE6/r1Gf+ X-Received: by 2002:aa7:dac2:0:b0:540:4b90:3dc3 with SMTP id x2-20020aa7dac2000000b005404b903dc3mr13507202eds.14.1698877715782; Wed, 01 Nov 2023 15:28:35 -0700 (PDT) X-Received: by 2002:aa7:dac2:0:b0:540:4b90:3dc3 with SMTP id x2-20020aa7dac2000000b005404b903dc3mr13507163eds.14.1698877715440; Wed, 01 Nov 2023 15:28:35 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.googlemail.com with ESMTPSA id z5-20020a509e05000000b0052e1783ab25sm1584481ede.70.2023.11.01.15.28.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Nov 2023 15:28:34 -0700 (PDT) Message-ID: <4ca2253d-276f-43c5-8e9f-0ded5d5b2779@redhat.com> Date: Wed, 1 Nov 2023 23:28:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 17/35] KVM: Add transparent hugepage support for dedicated guest memory Content-Language: en-US To: Sean Christopherson Cc: Xiaoyao Li , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8?= =?UTF-8?Q?n?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-18-seanjc@google.com> <7c0844d8-6f97-4904-a140-abeabeb552c1@intel.com> <92ba7ddd-2bc8-4a8d-bd67-d6614b21914f@intel.com> From: Paolo Bonzini Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92Lrax0hjiX DResHSt48q+8FrZzY+AUbkUS+Jm34qjswdrgsC5uxeVcLkBgWLmov2kMaMROT0YmFY6A3m1S P/kXmHDXxhe23gKb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qr bQ4tlFFuVjArBZcapSIe6NV8C4cEiSTOwE0EVEJx7gEIAMeHcVzuv2bp9HlWDp6+RkZe+vtl KwAHplb/WH59j2wyG8V6i33+6MlSSJMOFnYUCCL77bucx9uImI5nX24PIlqT+zasVEEVGSRF m8dgkcJDB7Tps0IkNrUi4yof3B3shR+vMY3i3Ip0e41zKx0CvlAhMOo6otaHmcxr35sWq1Jk tLkbn3wG+fPQCVudJJECvVQ//UAthSSEklA50QtD2sBkmQ14ZryEyTHQ+E42K3j2IUmOLriF dNr9NvE1QGmGyIcbw2NIVEBOK/GWxkS5+dmxM2iD4Jdaf2nSn3jlHjEXoPwpMs0KZsgdU0pP JQzMUMwmB1wM8JxovFlPYrhNT9MAEQEAAcLBMwQYAQIACQUCVEJx7gIbDAAKCRB+FRAMzTZp sadRDqCctLmYICZu4GSnie4lKXl+HqlLanpVMOoFNnWs9oRP47MbE2wv8OaYh5pNR9VVgyhD OG0AU7oidG36OeUlrFDTfnPYYSF/mPCxHttosyt8O5kabxnIPv2URuAxDByz+iVbL+RjKaGM GDph56ZTswlx75nZVtIukqzLAQ5fa8OALSGum0cFi4ptZUOhDNz1onz61klD6z3MODi0sBZN Aj6guB2L/+2ZwElZEeRBERRd/uommlYuToAXfNRdUwrwl9gRMiA0WSyTb190zneRRDfpSK5d usXnM/O+kr3Dm+Ui+UioPf6wgbn3T0o6I5BhVhs4h4hWmIW7iNhPjX1iybXfmb1gAFfjtHfL xRUr64svXpyfJMScIQtBAm0ihWPltXkyITA92ngCmPdHa6M1hMh4RDX+Jf1fiWubzp1voAg0 JBrdmNZSQDz0iKmSrx8xkoXYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 01 Nov 2023 15:29:40 -0700 (PDT) On 11/1/23 17:36, Sean Christopherson wrote: >>> "Allow" isn't perfect, e.g. I would much prefer a straight KVM_GUEST_MEMFD_USE_HUGEPAGES >>> or KVM_GUEST_MEMFD_HUGEPAGES flag, but I wanted the name to convey that KVM doesn't >>> (yet) guarantee hugepages. I.e. KVM_GUEST_MEMFD_ALLOW_HUGEPAGE is stronger than >>> a hint, but weaker than a requirement. And if/when KVM supports a dedicated memory >>> pool of some kind, then we can add KVM_GUEST_MEMFD_REQUIRE_HUGEPAGE. >> I think that the current patch is fine, but I will adjust it to always >> allow the flag, and to make the size check even if !CONFIG_TRANSPARENT_HUGEPAGE. >> If hugepages are not guaranteed, and (theoretically) you could have no >> hugepage at all in the result, it's okay to get this result even if THP is not >> available in the kernel. > Can you post a fixup patch? It's not clear to me exactly what behavior you intend > to end up with. Sure, just this: diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index 7d1a33c2ad42..34fd070e03d9 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -430,10 +430,7 @@ int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args) { loff_t size = args->size; u64 flags = args->flags; - u64 valid_flags = 0; - - if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) - valid_flags |= KVM_GUEST_MEMFD_ALLOW_HUGEPAGE; + u64 valid_flags = KVM_GUEST_MEMFD_ALLOW_HUGEPAGE; if (flags & ~valid_flags) return -EINVAL; @@ -441,11 +438,9 @@ int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args) if (size < 0 || !PAGE_ALIGNED(size)) return -EINVAL; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE if ((flags & KVM_GUEST_MEMFD_ALLOW_HUGEPAGE) && !IS_ALIGNED(size, HPAGE_PMD_SIZE)) return -EINVAL; -#endif return __kvm_gmem_create(kvm, size, flags); } Paolo