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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 2780DC4708F for ; Fri, 4 Jun 2021 14:50:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C7BC76140B for ; Fri, 4 Jun 2021 14:50:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7BC76140B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 65E456B0096; Fri, 4 Jun 2021 10:50:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60C6B6B0099; Fri, 4 Jun 2021 10:50:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 487B46B009A; Fri, 4 Jun 2021 10:50:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 0A1E56B0096 for ; Fri, 4 Jun 2021 10:49:59 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9D20510F40 for ; Fri, 4 Jun 2021 14:49:59 +0000 (UTC) X-FDA: 78216326118.13.49285C6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id A99C8C01C099 for ; Fri, 4 Jun 2021 14:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=UkYO4kgIrmSYqJOD2dr1KMVGd/NjjhOMxYRFRaU03ZY=; b=u+PtbC1q+b0OmaDDFCRsvIx4kq FBWqGgQ2Vx2BUTNyH/NZ+dgFO7MSEozzd6h/G0Jl9ZghU/ijGgAMa6FPIHTjBAhWt2OcyOrwN25dV VOqcCthsnMMZnNIB0f2gafoNHfvEdpnGB1TAaJq4e1cuPnpQJ/q0hibRvV2vSWaMjA3q+ZqE4pykV 7ldFrFT/dO+ahA5XcAjDMBgc5YY+EOOZGSdPamxj6VqWx5BkCpUKh8uqTsyjoetLo10vLaSfpFEAg 1GW4z9eAdQ5LSOiF7twCjeZ7Ejw8FlTxEOBstwOQgoFP4ng0jCgPjoPn25dZQR/vXIFdoSQ+x2h1n PNC500uQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lpB8c-00DFwZ-HI; Fri, 04 Jun 2021 14:49:33 +0000 Date: Fri, 4 Jun 2021 15:49:30 +0100 From: Matthew Wilcox To: Sean Christopherson , Yang Shi , Andrea Arcangeli Cc: linux-mm@kvack.org, Paolo Bonzini , kvm@vger.kernel.org Subject: PageTransCompoundMap confusion Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Stat-Signature: jij7is1iqmhh8c1d31gurwpfe94r8x7n X-Rspamd-Queue-Id: A99C8C01C099 X-Rspamd-Server: rspam02 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=u+PtbC1q; dmarc=none; spf=temperror (imf22.hostedemail.com: error in processing during lookup of willy@infradead.org: DNS error) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1622818178-822151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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().