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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AD19C47424 for ; Fri, 4 Jun 2021 16:18:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 292756140C for ; Fri, 4 Jun 2021 16:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbhFDQUo (ORCPT ); Fri, 4 Jun 2021 12:20:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbhFDQUo (ORCPT ); Fri, 4 Jun 2021 12:20:44 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DAEF6613F4; Fri, 4 Jun 2021 16:18:57 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lpCX9-005W7b-U9; Fri, 04 Jun 2021 17:18:56 +0100 Date: Fri, 04 Jun 2021 17:18:54 +0100 Message-ID: <87r1hhzjpt.wl-maz@kernel.org> From: Marc Zyngier To: Sean Christopherson Cc: Matthew Wilcox , Yang Shi , Andrea Arcangeli , linux-mm@kvack.org, Paolo Bonzini , kvm@vger.kernel.org, Will Deacon Subject: Re: PageTransCompoundMap confusion In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: seanjc@google.com, willy@infradead.org, yang.shi@linux.alibaba.com, aarcange@redhat.com, linux-mm@kvack.org, pbonzini@redhat.com, kvm@vger.kernel.org, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 04 Jun 2021 16:50:20 +0100, Sean Christopherson wrote: > > +Will and Marc > > On Fri, Jun 04, 2021, Matthew Wilcox wrote: > > I'm a bit confused about what PageTransCompoundMap() is supposed to do. > > What it actually does is check that the specific page (which may or > > may not be a head page) is not mapped by a PTE. I don't understand why > > you'd care how some (other?) process does or does not have it mapped. > > What I _think_ you want to know is "Can I map this page with a PMD entry > > in the guest". And the answer to that is simply: > > > > bool kvm_is_transparent_hugepage(kvm_pfn_t pfn) > > { > > struct page *head = compound_head(pfn_to_page(pfn)); > > return compound_order(head) >= HPAGE_PMD_ORDER; > > } > > > > but maybe there's some reason you don't want to map hugetlbfs or other > > sufficiently large compound pages with PMDs? > > > > Looking at the one caller of kvm_is_transparent_hugepage(), I'd be > > tempted to inline the above into transparent_hugepage_adjust() > > and call get_page() directly instead of indirecting through > > kvm_get_pfn(). > > arm64 is the only remaining user of kvm_is_transparent_hugepage(). > > x86 purged its usage a while back, and instead looks at the host > PTEs via lookup_address_in_mm() to get the current mapping level. > The motivation was to consolidate the hugepage logic for THP, > HugeTLBFS, and DAX, and to naturally support both 2mb and 1gb for > all flavors of hugepages. > > Could arm64 do something similar and kill off > kvm_is_transparent_hugepage() entirely? Yup, we should be able to do that, although we get the additional fun of caused by having 3 different page sizes. I'll have a go at it next week. Thanks for the heads up, M. -- Without deviation from the norm, progress is not possible.