Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp276148rdb; Tue, 31 Oct 2023 07:16:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqCKAMVIEsL0NT9aZZljhFxHBJ0TYub0OuxNXO3kybatuNrSSvwMuBZ5ffUpXsUKBV7kSv X-Received: by 2002:a05:6402:14cf:b0:543:8891:e142 with SMTP id f15-20020a05640214cf00b005438891e142mr506355edx.11.1698761809955; Tue, 31 Oct 2023 07:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761809; cv=none; d=google.com; s=arc-20160816; b=ocSWaufLUPxP3AMy/SYSR/7n56Ha3mcgpK6E0pqsJ/yjU/FwkhuejmIEmLwXFVvyZJ ujMiXtt455rW6aZJ5prlocJTp0g1MSu4IBK5K77wT7NH2l38/TyQhp0gqsocKGvxmtcE E3FVGAt9cuy/h2FkshO+c+UKcVs+bAB/eWCTrjHYPO7/CqWmbYToaCmfWcR8P75vnbaR XOg60ZWFsHRnkDlcr1dbFun7Pr4UPcN/eEKZseU62CMB0sBjBXl0KS9/26e9ZCTbdiiI igey4EJjA3dfvBCqltI+7BJjimt/J6kik3rRrWLVtEfXhRapPKMk+PdbtcZvLUFBmXc7 bs+g== 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:references :mime-version:in-reply-to:date:dkim-signature; bh=+SCWDVcx1K76tZHWI6JguONJ6NnGeKLP7+QbYfrb3Rs=; fh=1N3tQc5hMawYHUzIVFjUTPHHuyyOH103pPs30XYrSwQ=; b=xLr1/YT+XxbpT35W+5nT4BVudH5Tr344mD8xgeLzBOJD1xap29ebdIrThQXhB9DySf HjZ5xTMligMRymjDup3PfrwuWdNAUxm78e/0hX/SqvUpfj6AOHOz6kr8qBBfBZdPHI1n hA9CDPizXic/wLX6oCujEQh1DV4DCWgLk6QyfxPkSnDWwhavRe2x7REnrXihA8j5FGaf 2//YSWn30vShA8spiJDx6mFiTTKWP6KG98mrs29SxnkuyScAmLe6v+jvlO5BSJwtjemG THZ5QOvqYSTJL8oCzU0IV21qElmXG+arUwA0s8h2N4+hfl52vtErKViNajTkUM09S+dY Z/Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3LTiG76G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h16-20020a05640250d000b0053de76d82f1si643542edb.453.2023.10.31.07.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3LTiG76G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1C74880764B1; Tue, 31 Oct 2023 07:16:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343746AbjJaOQV (ORCPT + 99 others); Tue, 31 Oct 2023 10:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343636AbjJaOQU (ORCPT ); Tue, 31 Oct 2023 10:16:20 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE077F7 for ; Tue, 31 Oct 2023 07:16:17 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1cc1ddb34ccso31626065ad.1 for ; Tue, 31 Oct 2023 07:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698761777; x=1699366577; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+SCWDVcx1K76tZHWI6JguONJ6NnGeKLP7+QbYfrb3Rs=; b=3LTiG76GVOEc8lRq/TWhVMCBV8LuspBYlB/0ZIqRRak+sx2n46riS4bQtfSIk4aJnK ntUUHuodNmr6cOqafV7BjMw8U5tKd+L0HzhZeZsO1dOTZIcaN83bqsc5u0PJrHIXnUdH APf4M1tVvArfQk9bmox4Dgl8MvFDpXVQpuSqG1VX6yeO5/kYbwCjbCcT78UghJs4YwnI GPr3vgcKx3TG8dDPsz4v7hYyYBhF9AX1XGKsRyoQ1D8y2xbDFp/W/DVu5jXfFLA15Joz bGeQrIXuFRBDriN1OItvIqOh0QyQ3CMm62EVBPD98LhSaU/AWmprxKRG1r3hTvx/H04n o+Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698761777; x=1699366577; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+SCWDVcx1K76tZHWI6JguONJ6NnGeKLP7+QbYfrb3Rs=; b=AgcaeTFY0F/tkoSqCCPqJ0xWbh+qiceODeWlDEHQqKwqITV8Glc3Jw9uU8EiHzMxX3 OhbSnx4PftAYjrhcmgGEbEQYADU5rS1MWI2SVhukGdiMOQynkFD9CPqmnZkfW82U4fLO GSUTuHpXTtlwawWxtULxIHweH/LKlsJz+0alvOshz2VGVpk7LBxtDjqbf3OyanwfZBoP xBJC7hERaD2GqV+35n6Afy6JB0pSLOfWggRp7mlPI5L+j5l7uwrS1FPeLOfEZj07tzXM PUopk7uhqVvcjyJIAy7L5DwFY9uOAonNaURxjfpgrOEeU/auiZQSD2Sc2T6m70vbXYVC JRGg== X-Gm-Message-State: AOJu0Yx7ovWp3pkAq4mibhQEiSLyIw1FnINyNejM34qUJHmy/k1q9n8+ sf2eSLAXgD51wh6CPm4IVfqOh7tJPfY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2616:b0:1cc:2549:c281 with SMTP id jd22-20020a170903261600b001cc2549c281mr206233plb.13.1698761777291; Tue, 31 Oct 2023 07:16:17 -0700 (PDT) Date: Tue, 31 Oct 2023 07:16:15 -0700 In-Reply-To: <7c0844d8-6f97-4904-a140-abeabeb552c1@intel.com> Mime-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-18-seanjc@google.com> <7c0844d8-6f97-4904-a140-abeabeb552c1@intel.com> Message-ID: Subject: Re: [PATCH v13 17/35] KVM: Add transparent hugepage support for dedicated guest memory From: Sean Christopherson To: Xiaoyao Li Cc: Paolo Bonzini , 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?Q?Micka=C3=ABl_Sala=C3=BCn?=" , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, 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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 07:16:31 -0700 (PDT) On Tue, Oct 31, 2023, Xiaoyao Li wrote: > On 10/28/2023 2:21 AM, Sean Christopherson wrote: > > Extended guest_memfd to allow backing guest memory with transparent > > hugepages. Require userspace to opt-in via a flag even though there's no > > known/anticipated use case for forcing small pages as THP is optional, > > i.e. to avoid ending up in a situation where userspace is unaware that > > KVM can't provide hugepages. > > Personally, it seems not so "transparent" if requiring userspace to opt-in. > > People need to 1) check if the kernel built with TRANSPARENT_HUGEPAGE > support, or check is the sysfs of transparent hugepage exists; 2)get the > maximum support hugepage size 3) ensure the size satisfies the alignment; > before opt-in it. > > Even simpler, userspace can blindly try to create guest memfd with > transparent hugapage flag. If getting error, fallback to create without the > transparent hugepage flag. > > However, it doesn't look transparent to me. The "transparent" part is referring to the underlying kernel mechanism, it's not saying anything about the API. The "transparent" part of THP is that the kernel doesn't guarantee hugepages, i.e. whether or not hugepages are actually used is (mostly) transparent to userspace. Paolo also isn't the biggest fan[*], but there are also downsides to always allowing hugepages, e.g. silent failure due to lack of THP or unaligned size, and there's precedent in the form of MADV_HUGEPAGE. [*] https://lore.kernel.org/all/84a908ae-04c7-51c7-c9a8-119e1933a189@redhat.com