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 E65A1C3DA6E for ; Mon, 25 Dec 2023 06:30:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44A476B0075; Mon, 25 Dec 2023 01:30:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BF686B0078; Mon, 25 Dec 2023 01:30:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AF1D6B007B; Mon, 25 Dec 2023 01:30:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1CD276B0075 for ; Mon, 25 Dec 2023 01:30:10 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B1FCEA145B for ; Mon, 25 Dec 2023 06:30:09 +0000 (UTC) X-FDA: 81604365738.10.564F2B8 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) by imf25.hostedemail.com (Postfix) with ESMTP id B1A95A000E for ; Mon, 25 Dec 2023 06:30:07 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=h682B12Q; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf25.hostedemail.com: domain of muchun.song@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=muchun.song@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703485807; h=from:from:sender: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:dkim-signature; bh=mXkiPRdEVvfi9LIMu0a4pQRnrGa3opN+NyWjT9LajSI=; b=jbLMj7CO5ce3Hf405eL3FR3hIdXDUrShXoOfSxgw2CYVs/7sQu8milf7XFIy98d8x5v7j1 mDDnPxYDAsK4r3BFP0P2hk3fS4tEm2hGjitGLmw6t1peF+sY4PrW4ZO+YZ2lGTCWCy8P9N xx2JolX+HkMDc64/sCUfOQ0+G5lCv2s= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=h682B12Q; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf25.hostedemail.com: domain of muchun.song@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=muchun.song@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703485807; a=rsa-sha256; cv=none; b=gboK3lotEILvkOEtTWiDkYhSPJl431ym5AcXvwAfMWBcvz7mVFxNsii4VAycCzUg8OWemG DiEO8XY5PBlDQLfnYrlLLcKlRnYBeJAcYhju04fVycpgZmKyAv/SRntDeGbw8t88Km+qEB UM4Y2WYJ8i/sOj5uT+s1k+M4OOPc9jM= 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 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 X-Rspamd-Queue-Id: B1A95A000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kuzyqbhys1qpbz3i7ftriimacojoox5f X-HE-Tag: 1703485807-247025 X-HE-Meta: U2FsdGVkX189YVfpdpF8TiFJWIwxhojDqli4PpbzS7hvpDHTueF5FwyZRgMSPmqvlX0Z2xpbiAis3rf2k5yYaSgjT1Dh4qoDTLjn6bq3P9oy06MPlKUBgDeQsjJprRp1/EXipAVOLuHbPabCBN4Vx6lCRJbodhqXwLmCK2cs006WY8LNUyIcBDTPJ6kH1JfVW0cqoNe6gF9/o0bE4ndqXQJdogxs+Fr3fLUhoweRCwSEGpfYJHFuFoK1fxpBdLKZw5uDTSJtZJekg4aDhSMplyw4qx8+fprLnH+aCWz3T/P46aeO4laaKvnLHI0MGnh6WhtUPNS8cw7Z9QVzAEiU2sB3cYR7Rq+2NpCuFno2UOPxFgmYfLyMVrnHeC/NaxHwh0G53RgVRXZVXUsxnA9w+wVquLNmuDcrtTIGiNzt+4MpqluZd7KpEIrNHzvfBegsvVJNSKI2ewE4EVUp/9AKflTV+ZKeAGy58d0e5sZH6pa8qF71LoXYVCkk2W5Tys6yFL36SRqdFxXSW2yoD6YlpPhAirEkcQhmKmRuxqs6dVGadSP7XigYKXx+uhhajO2S1zxvoRpTdN4j5L6saj/1bPfXwtgyq9k1WRMZ8xm1lrok1+e/otei0QQiyyp2GgAO+5vhUM2L2YvCnOo+SR/EFc0/oNEhf3YosPS44zo2GhaLIgJ1MeQUir/jAxrY2mTpxAf7YUNlsZy5hxiqADFmO5fIIGszEZuC8D6ERajT6lwr755fCSeX4WJ8kFIDzVJ6cCsUrEGZ6sknZTbYlarUiK1TFM/qdboaWFl2LJEEQbVkgSVe1pFyOdWDGg8pOQ2g/qcsbS3IFTBurMLw34WjdZ0NOPQTsTp7rBlJudq6M8DdEIDonos2AoSRuumZSw/UPHbjJ3+qyJr0wmqyNxlAnHnfqyxBM4CbFmHZTdgTztmxRua26DZZY9v80rqmLKTS4vk4Uv755nOGJQ60kJ3 QIt1L7/r mUX1nICG6/PsA8vr3eqqYR84ycC8QCPjQDRGhYQrWrx0vsaiPvsy3vLN23fNgHN6SX4kXyq7sHe3vtosxJTcYETO0naEiM85KIdv1Hcf2R4nKLIlWqVbc+6GJILV/DD4H2b8yBLQK1J57+XtAjGhTR+zTKHfStVqkQzlIJoUi9/V+8UmdCKtNsPOWjw== 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: List-Subscribe: List-Unsubscribe: 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;