From patchwork Wed Mar 6 10:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583882 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 7EC92C5475B for ; Wed, 6 Mar 2024 10:43:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AE246B00A8; Wed, 6 Mar 2024 05:43:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 15D5A6B00A9; Wed, 6 Mar 2024 05:43:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 024DE6B00AA; Wed, 6 Mar 2024 05:43:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E30C76B00A8 for ; Wed, 6 Mar 2024 05:43:25 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AFDC040B70 for ; Wed, 6 Mar 2024 10:43:25 +0000 (UTC) X-FDA: 81866277570.29.166A2FA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 27EBD2000B for ; Wed, 6 Mar 2024 10:43:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U/saFQoS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721804; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e0nyH5cfLKLNUyYVewKsf1JegzIgt6HCOMbuZo9oALU=; b=Pkjs/5Qg5w3QxLE2uu/dcCvUTK7LHFqf5Fzs3h3e9GYbx73DBEEqC0IX7cT0p/Rp2sUGBZ g3vf5bJdeFqek2nwWGdQUhN39TgYxGHjJnpYAozbV6GbjhM/iHfzLISizs1vFXxvpNGYgI aYnyn2rydSNJa6/moB6tG0P6lragtIE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U/saFQoS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721804; a=rsa-sha256; cv=none; b=RHdHyeISb0X5APj2bicDb7cZxrpWBkbNdP+afeJop7BBA84tGZny0o9PyIN8GDP/CEwx2C wx7OD83JwuJUPYyACDJZLa8miWotlaoCMdN4mmeiWY+vv5pCbF5PCDc6lj+xqtiZwQmZg6 YyKNx7ZupZehgYIk7Uly+HL/+3NQt0k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e0nyH5cfLKLNUyYVewKsf1JegzIgt6HCOMbuZo9oALU=; b=U/saFQoSaa2gLQYIAVmfL84J4eagyTmcQlO374bDKZJV1U8VefCN9s4za3pyYcaXHYdfyZ ekGTs0QLpJ2xTYY1yqHLk6Kc4iFcs1orZdyD8TAbbq4SJl6x8HRd5M0fw0+q90T7jfm4tJ HddCfmC+LXHL8Peyto0oPJTJ84dL9Pw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-Hl-hIAJEPjGHPHHTtG8PNw-1; Wed, 06 Mar 2024 05:43:17 -0500 X-MC-Unique: Hl-hIAJEPjGHPHHTtG8PNw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21BBC1C0513A; Wed, 6 Mar 2024 10:43:17 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id D539F111DCFF; Wed, 6 Mar 2024 10:43:10 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , Muchun Song , Jason Gunthorpe , peterx@redhat.com, Matthew Wilcox , Mike Rapoport , Christophe Leroy , x86@kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 10/13] mm/gup: Merge pXd huge mapping checks Date: Wed, 6 Mar 2024 18:41:44 +0800 Message-ID: <20240306104147.193052-11-peterx@redhat.com> In-Reply-To: <20240306104147.193052-1-peterx@redhat.com> References: <20240306104147.193052-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: 27EBD2000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3ztfjbij4y6oggd5c9khe51g4jdowtwz X-HE-Tag: 1709721803-272238 X-HE-Meta: U2FsdGVkX19c3pffKg0WnZUE+3e6I71QbwFw+t9k+kLSvyp5bmQDXqLVHSrt/ao7hxUHweRc4z043IvTF1Gyg8A5I/Qt2tX6KtaqRnS9gVFzFdlXHZUZvTxwUFpUsE74oOcQ7Dv/t9SQsfca7RrrfnFjJD40CGHkVstBo8kR0qpT/y074z0z4kOIQ4Q0AJepkqWBdtljaW5NUuYcUfMDR9uypN+TYU2QUJEKUeQ3KQ9pKGnSW2J/D8tCx+2gpi/qlvw2Tzc9CY5aUidRCnRTEXpk/GyNUgENIYl12HYtK7FDJN2hEWDjJGi/O/wEcHIlrEmut2kZq0SkYZaOWH/eHcLcWzH4yH4HXeFS/nAOLyMUxaYVis27boo1lwIYOhnwZ9V+cLirPRyj118KxAcB26WO3v2bvNeOzhJzTHe01h5O9+ZuAqHEo6jaxOGqsaZQOpm30HBRj4PIaqDVnU8M8ilVPhgWUHbXMric27wWm7i3VHgzfAM9m8ZMNSGsmb1XZDkFJGu6TShYDuIZr7ebxsuRjpwu4d6HDVVlVzyx/g203eN9iwjZbEKE30Hx+hwJ8S2m6tlOyntWo7DkUvc3hisR6KaECgPVCk6etL2SnIyZA5/pa+E5pzv/YQN1DlbbsDGh9hJ/qhzlm5YyWBtCK0Qfr9myI4YoovMrOflcto+DBxabZ0vYYVhk5h7CekoVETHb5PFYaWljKfrfRa1dvIJHEi8SIbplq+lvY3fErVJP1w29XuHYjloldUwc4kh9MYDxuv0bXorhLLg8YksRjldnDyrnXEsSCqGw+nsVALXDn+LfRvuVgNgwI16zKfahzF/v+qOXIzXAM5tMhHHpeoXRD1EFOL1WbEyoFyqZe+jL+BHxg2ziWSa8zYuKPsUqT3gWI2XA88Q2EcaIRFw4rQ== 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: From: Peter Xu Huge mapping checks in GUP are slightly redundant and can be simplified. pXd_huge() now is the same as pXd_leaf(). pmd_trans_huge() and pXd_devmap() should both imply pXd_leaf(). Time to merge them into one. Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index f87a7d90f2ae..de7188d2af86 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3005,8 +3005,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_leaf(pmd))) { /* See gup_pte_range() */ if (pmd_protnone(pmd)) return 0; @@ -3043,7 +3042,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud))) return 0; - if (unlikely(pud_huge(pud) || pud_devmap(pud))) { + if (unlikely(pud_leaf(pud))) { if (!gup_huge_pud(pud, pudp, addr, next, flags, pages, nr)) return 0; @@ -3096,7 +3095,7 @@ static void gup_pgd_range(unsigned long addr, unsigned long end, next = pgd_addr_end(addr, end); if (pgd_none(pgd)) return; - if (unlikely(pgd_huge(pgd))) { + if (unlikely(pgd_leaf(pgd))) { if (!gup_huge_pgd(pgd, pgdp, addr, next, flags, pages, nr)) return;