Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2174507rdb; Sun, 24 Dec 2023 22:30:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhrs1l25rxUqckTbmJLMXMtqxWb1uOoQMhHQePlq6oDnnllekj4gwbzkAvL7VcI5nQIWNG X-Received: by 2002:aa7:d787:0:b0:553:bd7c:569 with SMTP id s7-20020aa7d787000000b00553bd7c0569mr3732702edq.24.1703485817473; Sun, 24 Dec 2023 22:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703485817; cv=none; d=google.com; s=arc-20160816; b=e7bVacTwuGFfwPDLhaiQGRmCeNRsXE1EgY4JPbYdfaFSI/FkkdXHDkLn+R2/gQnBI3 p38mFOY6Nb/89lnB7LoVjwGUZL0gk5XKbIbqlCuAORXYntqIRsSxdfyGfawStjtf2Yuk jhs06LxFhgkI2kYa2PH9e3iLlKGOx4kfBODTGxQqSqT1B6t5jdpH1NWiP2Cy2ZkLn8Mf oCjExTyXsCHAG0n4ucc4b5ZmIanSuKerIvca1zJlf2k3P7xp2dEOJ5JlL9UYXTOvHdUK yQ/hhRFU8gj/1u8GwIoH8eV2M7tY5LfQqi3chSl3rfJy6NVPCSwxfp4g0LRaa5abDc14 7R7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature:message-id; bh=mXkiPRdEVvfi9LIMu0a4pQRnrGa3opN+NyWjT9LajSI=; fh=H835plC0NQRDQRl7o8po2FLfCsrxQawAk1cr1/GP8/c=; b=c+esZ7KPWR6ncrzMZC8urkAvxYa3lgXdjUG4/irMymNFqnnFSmOpIlBTUHokg26QZ+ JC3EoENQRRUZsN1q9Da/Gfan26hEFq/JS/wu/cVWMPbqY74kZZfwiwBak4/3uqmjS/AR FU+YxqwYA3a4ku25umpUxXux3n9fmZAxD0EpGnzYUQxaeTKQ+jrsN31rB9Kbcv0pNbeC vHhvlqi0WPXwWL7Jilm4D1ZJi2k1Uu+CwQvKr784ZUdCuaJmbpXm/y6bL/TnItnODXfO tLzsHr+ryVGg04PJSk2I7EcdrzLdMwEQUwbaz8d6YO3B1ySFY1EwFcbmHqawNhPL2qIJ 8l1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=h682B12Q; spf=pass (google.com: domain of linux-kernel+bounces-10903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id de28-20020a056402309c00b00553f85c589csi2388296edb.29.2023.12.24.22.30.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 22:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=h682B12Q; spf=pass (google.com: domain of linux-kernel+bounces-10903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3EE3E1F213EC for ; Mon, 25 Dec 2023 06:30:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FE0115C6; Mon, 25 Dec 2023 06:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="h682B12Q" X-Original-To: linux-kernel@vger.kernel.org Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFBE2110E for ; Mon, 25 Dec 2023 06:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <135b3189-f459-4b57-9861-bb8acb999d91@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703485805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mXkiPRdEVvfi9LIMu0a4pQRnrGa3opN+NyWjT9LajSI=; b=h682B12QYqT/ZiBDMXBg7hxqm2zl3GqlcPYEpS6y3r1bGCN3rdgqF0yDtrO4pW4CUYWVXI sTJy5rRK3CQjhtBukguGXtqnO65rzWMecb3dF6Bh7A7RdO4oHUmUtz51k8Yklj7jcfBANa Xv5L0ZESaqeE7oGtj7aq7bWJxH5I2r4= Date: Mon, 25 Dec 2023 14:29:53 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 03/13] mm: Provide generic pmd_thp_or_huge() To: peterx@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Christophe Leroy , Lorenzo Stoakes , David Hildenbrand , Vlastimil Babka , Mike Kravetz , Mike Rapoport , Christoph Hellwig , John Hubbard , Andrew Jones , linux-arm-kernel@lists.infradead.org, Michael Ellerman , "Kirill A . Shutemov" , linuxppc-dev@lists.ozlabs.org, Rik van Riel , linux-riscv@lists.infradead.org, Yang Shi , James Houghton , "Aneesh Kumar K . V" , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli , Axel Rasmussen References: <20231219075538.414708-1-peterx@redhat.com> <20231219075538.414708-4-peterx@redhat.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20231219075538.414708-4-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2023/12/19 15:55, peterx@redhat.com wrote: > From: Peter Xu > > ARM defines pmd_thp_or_huge(), detecting either a THP or a huge PMD. It > can be a helpful helper if we want to merge more THP and hugetlb code > paths. Make it a generic default implementation, only exist when > CONFIG_MMU. Arch can overwrite it by defining its own version. > > For example, ARM's pgtable-2level.h defines it to always return false. > > Keep the macro declared with all config, it should be optimized to a false > anyway if !THP && !HUGETLB. > > Signed-off-by: Peter Xu > --- > include/linux/pgtable.h | 4 ++++ > mm/gup.c | 3 +-- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index af7639c3b0a3..6f2fa1977b8a 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1355,6 +1355,10 @@ static inline int pmd_write(pmd_t pmd) > #endif /* pmd_write */ > #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > +#ifndef pmd_thp_or_huge I think it may be the time to rename to pmd_thp_or_hugetlb, the "huge" is really confusing. thp is not huge? Actually, it is huge. It is better to make it more specific from now on, like "hugetlb". BTW, please cc me via the new email (muchun.song@linux.dev) next edition. Thanks. > +#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) > +#endif > + > #ifndef pud_write > static inline int pud_write(pud_t pud) > { > diff --git a/mm/gup.c b/mm/gup.c > index 0a5f0e91bfec..efc9847e58fb 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -3004,8 +3004,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo > if (!pmd_present(pmd)) > return 0; > > - if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || > - pmd_devmap(pmd))) { > + if (unlikely(pmd_thp_or_huge(pmd) || pmd_devmap(pmd))) { > /* See gup_pte_range() */ > if (pmd_protnone(pmd)) > return 0;