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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF3E3C433EF for ; Fri, 13 May 2022 03:30:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F4F96B0073; Thu, 12 May 2022 23:30:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A2D86B0075; Thu, 12 May 2022 23:30:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E862D6B0078; Thu, 12 May 2022 23:30:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D56AA6B0073 for ; Thu, 12 May 2022 23:30:57 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 9D18780A72 for ; Fri, 13 May 2022 03:30:57 +0000 (UTC) X-FDA: 79459293354.04.E195750 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id BCFD1400AD for ; Fri, 13 May 2022 03:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=T1n6CcgxVlaaTJq+CdhKBBc8cwWaDbssBxSXTzNNfzc=; b=Uh0b9OF+M0Iy4RqjTa7JTtdqBX gPYpgBZ+O+hVvylStq4jCTOEeZ9/6LK8ZXcj3k9j1W8l30iIa/AvoEIGzsaFFHCeHPRJmrrMJzPvF ZQWunK73NroWy7jaO/cLtZxf8JKohHYnYM/uIGxs3yEwKeM3L327h+PJ4HWm/DAKL6/dZDFHMV7V3 Q2ovOXFAUUxKQNJo7tgGDMVvmv70if+iLO33uni/E7DrwZUeYx8XgUoQpn2mBSYRhP4Mf3BkY8AMY FJ3koHZejPnDySmDdc/BENU89RUJP7wV10SMcXjHCkgz/tyC4GaUXBRZBuiiFzePkQIhPFH3Ng8H/ OF9xsqHg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1npM0y-0070UD-8n; Fri, 13 May 2022 03:30:52 +0000 Date: Fri, 13 May 2022 04:30:52 +0100 From: Matthew Wilcox To: Yang Shi Cc: songmuchun@bytedance.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm: pvmw: check possible huge PMD map by transhuge_vma_suitable() Message-ID: References: <20220512174551.81279-1-shy828301@gmail.com> <20220512174551.81279-2-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220512174551.81279-2-shy828301@gmail.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BCFD1400AD X-Stat-Signature: twp9fi1kf5d53dsf1kmroaiybfad8on3 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Uh0b9OF+; spf=none (imf11.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1652412651-167930 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000062, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 12, 2022 at 10:45:51AM -0700, Yang Shi wrote: > IIUC PVMW checks if the vma is possibly huge PMD mapped by > transparent_hugepage_active() and "pvmw->nr_pages >= HPAGE_PMD_NR". > > Actually pvmw->nr_pages is returned by compound_nr() or > folio_nr_pages(), so the page should be THP as long as "pvmw->nr_pages > >= HPAGE_PMD_NR". And it is guaranteed THP is allocated for valid VMA > in the first place. But it may be not PMD mapped if the VMA is file > VMA and it is not properly aligned. The transhuge_vma_suitable() > is used to do such check, so replace transparent_hugepage_active() to > it, which is too heavy and overkilling. > > Fixes: 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs") I think Fixes is a bit much. There's no bug being fixed here. This is just an optimisation. Is it an important optimisation? We could put a bool into page_vma_mapped_walk() so we only have to ask the page whether it's PMD-mappable once per walk rather than for each VMA.