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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D5FDC4332F for ; Wed, 1 Nov 2023 07:26:41 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=R2ehDQm6; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SKz8b3dykz3cQD for ; Wed, 1 Nov 2023 18:26:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=R2ehDQm6; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=134.134.136.65; helo=mgamail.intel.com; envelope-from=xiaoyao.li@intel.com; receiver=lists.ozlabs.org) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SKz7Z30Psz2xps for ; Wed, 1 Nov 2023 18:25:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698823546; x=1730359546; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=qWRVoltW9FVs6NYX3CWyFfOjxesJ7ml8CJp5xBKO3/4=; b=R2ehDQm6FkRLwsMPVgLCZdXfNTJobMStjH9rD6Q139vuEgz6+HkLOKTL nLe1XmO8UFKp3CsM0ahEfuxQvCsihbA9146yeUtZj+C2EvNG9QQ1KJY5L ysWrY4uqyjX43HD7N9N/RFY6KfGchrgnVcQCrczY9/XIpYlniP+f9tini ph+2KbG36r2PKEOAF1/GkPUiM/K3HJVTSJ/OUgVxR7JyuGZMNEq9i5EE9 ASUXO2ffDP1sSQ1zUoz6zsYAk1ENQfMWLK72IL81v3cEXU8bjFi+pEYM8 IuLleJ9pszaYMIgFAVp4dgL8NldRn7CKGaruqaIWq5j8nhifeB+7WOiOm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="392307411" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="392307411" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 00:25:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="8964294" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.93.9.145]) ([10.93.9.145]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 00:25:26 -0700 Message-ID: <92ba7ddd-2bc8-4a8d-bd67-d6614b21914f@intel.com> Date: Wed, 1 Nov 2023 15:25:23 +0800 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 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-18-seanjc@google.com> <7c0844d8-6f97-4904-a140-abeabeb552c1@intel.com> From: Xiaoyao Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chao Peng , linux-riscv@lists.infradead.org, Isaku Yamahata , Marc Zyngier , Huacai Chen , "Matthew Wilcox \(Oracle\)" , Wang , Fuad Tabba , Yu Zhang , Maciej Szmigiero , Albert Ou , Vlastimil Babka , Michael Roth , Ackerley Tng , Alexander Viro , Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, =?UTF-8?B?TWlja2HDq2wgU2FsYcO8?= =?UTF-8?Q?n?= , Isaku Yamahata , Christian Brauner , Quentin Perret , Liam Merwick , linux-mips@vger.kernel.org, Oliver Upton , David Matlack , Jarkko Sakkinen , Palmer Dabbelt , "Kirill A . Shutemov" , kvm-riscv@lists.infradead.org, Anup Patel , linux-fsdevel@vger.kernel.org, Paolo Bonzini , Andrew Morton , Vishal Annapurve , linuxppc-dev@lists.ozlabs.org, Xu Yilun , Anish Moorthy Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 10/31/2023 10:16 PM, Sean Christopherson wrote: > 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 But it's different than MADV_HUGEPAGE, in a way. Per my understanding, the failure of MADV_HUGEPAGE is not fatal, user space can ignore it and continue. However, the failure of KVM_GUEST_MEMFD_ALLOW_HUGEPAGE is fatal, which leads to failure of guest memfd creation. For current implementation, I think maybe KVM_GUEST_MEMFD_DESIRE_HUGEPAGE fits better than KVM_GUEST_MEMFD_ALLOW_HUGEPAGE? or maybe *PREFER*?