From patchwork Mon Mar 18 20:04:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13595781 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8777C54E69 for ; Mon, 18 Mar 2024 20:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QXXQs4tR59BhQC/bUWtd00YVgThBVo8KgE5TifBMp5k=; b=cOt5udSMF1fAzy 7t+SQZ657wPDWmdVjo0NY165OVlk5Syr26R05T232g1sFav09Oi9VjdpHWe74cMwoCGD+m8KrMJ3/ BpTkx2Esp4o3+cPdB7zZJW3OmS7IkdVqr6Dc0xMcFDAjEFGBNHeArpF2HWo4N3MeIbv1AP+PsY/oV robF2vJcquPu7/nn65hYaN6Zb/hTfnOPH05ZphMaTxTZKHxbREQYw8Y+++1+aoOwkgrhIU0CejfPA r3pqkaAPs/euKRUE8O72P8Y0ltwY3Ac4wJlCZ0s1qWI4i96ujEMhC7jJ7pWiV2nmTJjcIfYD37Bz2 mvUeWwi9Ptb1Iz/N+mmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJE9-00000009xbq-2qQZ; Mon, 18 Mar 2024 20:04:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJDc-00000009x78-2WWO for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 20:04:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792263; 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=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; b=fynwT17SJVsvl2nSZHqSMrQXVMepJMrapFOUyZJWtCsFp7S369yo33HwnwDqLaXGF6vxMW /7EuGbMsf2HZDBxPEWlWe3Acr6NIlEBf0UaBdMiy2MDpw8USTJjoMdYQY0dWYImY3l9GVd 7Pa67JTxBEKkh2U43zUDlHN4Hv3kx/8= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-aQYwoEcWOpaMDjhwMs-gJA-1; Mon, 18 Mar 2024 16:04:22 -0400 X-MC-Unique: aQYwoEcWOpaMDjhwMs-gJA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-430c76df729so6673191cf.0 for ; Mon, 18 Mar 2024 13:04:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710792262; x=1711397062; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; b=S15lt2QLj9juDJnxzIS83wVNR4XxqJAidAR45TtDySpWMROrUkk+/5TjwYzojQpZJ3 m3/UXe/rsBVC26PHm8MxKA5VTmPk+yXquK4OFpaXwFigAOD/6VpIj+q3Vuku1mHV0unu e4SVaEkPeINSwaYa7bczddLQzTp8Ru6ebLdHyEucnNt9zh/WZUrokyHs41vAFeO/OvAU D8HGkABBNh2pGaJZTetUaUN3FqGQR8X6cpoRIoz452/2X6z8LU0Kw07O3+sXGzUMVar6 LHJo6qtARBY4h51qmYFDYJegm5Y0RhgFLdgwxlbZoN+pVXUIyZjQxwsjikxNCKjoiMSO WLbQ== X-Forwarded-Encrypted: i=1; AJvYcCWcq1ku2j/9znPFiQUTwYWq87vt00sJZJEARIuyotyCsBzm1B+4SmRkZPK2Aex1JEayLtmExY+qCduGLJw2ydWkJPWJMZT14d9ZeFFp1xAab9kHEPY= X-Gm-Message-State: AOJu0YwdbncjATD4pLQc0WvfvVpuE6YJmZoJhBoJJ0QEZSGCtLTPYt4x bU5NFSx6oS5+Wq9vnePFRgW81DLQBmN3OW2GIioH3Bez3f1fVxWUhgccB8jn+/Ix3+oBUUYbwbT 48Uxh7OUMQJlDei00YAI9I0yiM7bkXzVFdAfyUeMHpltdwcBTUSFID85lHya9f8bO3WhcLatD X-Received: by 2002:a05:622a:15c8:b0:430:ae0a:c08f with SMTP id d8-20020a05622a15c800b00430ae0ac08fmr12238074qty.6.1710792261469; Mon, 18 Mar 2024 13:04:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQhMJRmPtSMLbLztL+aVkPHyOJfqD1JG0yGIJ+aGiheaz6nxeexYpcIdXvqwuavYhzTjiHrw== X-Received: by 2002:a05:622a:15c8:b0:430:ae0a:c08f with SMTP id d8-20020a05622a15c800b00430ae0ac08fmr12238049qty.6.1710792261015; Mon, 18 Mar 2024 13:04:21 -0700 (PDT) Received: from x1n.. ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hj10-20020a05622a620a00b0042ebbc1196fsm3484491qtb.87.2024.03.18.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:04:20 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , x86@kernel.org, Muchun Song , Mike Rapoport , Matthew Wilcox , sparclinux@vger.kernel.org, Jason Gunthorpe , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , linux-arm-kernel@lists.infradead.org, peterx@redhat.com Subject: [PATCH v2 10/14] mm/gup: Merge pXd huge mapping checks Date: Mon, 18 Mar 2024 16:04:00 -0400 Message-ID: <20240318200404.448346-11-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318200404.448346-1-peterx@redhat.com> References: <20240318200404.448346-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240318_130424_980484_B0437808 X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 802987281b2f..e2415e9789bc 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;