Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp466665lqt; Mon, 18 Mar 2024 13:06:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJT89teJORLHJ4odU0NgcyN8hZ9TrjZPJXBy9qcXqONpG8NWyxwEXB8bIh9eoF5yOwUPvcqigkz2wmU4r0HRVM0JZ+/cnCkvhn4CppgA== X-Google-Smtp-Source: AGHT+IGU/MvkfyBHbcz3W5K5MuPtlTFevKM4Em/UIZDNmGPVgZyVMZy8jbeFzSXKWW0qEmmjHcrY X-Received: by 2002:a19:e04b:0:b0:513:c50d:db59 with SMTP id g11-20020a19e04b000000b00513c50ddb59mr6364428lfj.15.1710792404925; Mon, 18 Mar 2024 13:06:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710792404; cv=pass; d=google.com; s=arc-20160816; b=h/63TYwOyeh144FN2PYV/bCiWSDsvk5MVtdRS2EPIKYEE49SJKeMzUzhjfuw1m95KR nZgvyc4sNpaxnv7E/MTWDvbJWQKV5HcaqWFiDQGctA5R7PZoFaKw7YQ1pk8bHX5u9mhO SCyUrhnlAlEXRRsOhYB2tizlzQuxpID1AimzP4i3TXmRg6+PuanZxcSZl324N379/idS KtB6hHuL9zy0GZH7RP09YQcdnArOqsHkZs9YK7/JdDG/0My+xLtT73vrIgejOW1HPhbx G8LA+InrQYLbz9Vh+W6Je99T/D9Ispvb7IpRNsxjdLRzi93eBaxKnVVefAzXmk3b522X w3FA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; fh=yQ5R9Xwbdb9sgJ4JDw2dbtafcs9T0Ak6Iyb4To4N+xc=; b=R5lS1Iqc9vs9IFrMV3JM6zIv6cfb86unBoPO/nxnDW44c31q3IIadZioMAizKgNXKd Jplg4ZmMaZ5uXQ/OfhMfaILIu8VDogMp/9sY1M+bHOBqjVF4flrmTlFPTaINHcxJTmQz AB+sesqsedSZWs/8QVWtIEeYhii/MB7spmhozw5ptPWnBF2Xk0XfYhJLa6wvf67ldlHq p8QEfriYsgiZTki8DJOT4P0QRtLoHmKVCKD+ehD0OExZU4SgY9Q3HdaN9AvY8obbk5X6 BjwnriqOJpp7UtRk2fkvKIGqG0CVDERWvvU4KGSZSGuYvLXNe1T/UfJkxCRM/wZ1bKuL Lc8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jpv8PxWJ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k13-20020a1709061c0d00b00a4605866c13si4499704ejg.1035.2024.03.18.13.06.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106606-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=@redhat.com header.s=mimecast20190719 header.b=Jpv8PxWJ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 794C21F2404F for ; Mon, 18 Mar 2024 20:06:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 105C75B68C; Mon, 18 Mar 2024 20:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Jpv8PxWJ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C351C5B5C1 for ; Mon, 18 Mar 2024 20:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792266; cv=none; b=VpnEBzEjKiaSXlC0XdB8fW8YNZJQhInDpkfrojADusBsNWiWC18e0OBtpZITwhJF5NXrzyDJas+KZ5OJqX0Z6zNNM2BDd8rXxfNKQosnubuxGWD2uYbTE9WxCPsk+Bv9xAQ1I/NVLYKe2hjALwquyGm+l5UTpuYMhQVKmsjwhtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792266; c=relaxed/simple; bh=iQQgqfXsWxx8LbxXDlwC+eVTcKSnHUToAbw1far1TeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p8kxN/liqTBypE7L/dDgFWuyMDfOqvAe4CTzH3PY39rNNZfQh+JuHjq+WYxSioWVpt0oEtTuLuiX54ImJ/g827Lrys4DbwFY89T0IgZB4obeWXHh2cXQCFi4Sb5wNzTcSh/WGnKLqOmsKZgUszIXj1mFdvWJFztioKytnNbl5sA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Jpv8PxWJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; b=Jpv8PxWJQZKZ1IYVe15VrpiUDORHnFCxDPRbj7iLMce03wnLpBVVBsu4860HTjYgz+y1As VLJn46csO+VBKepkhO+s+lyspsmnnW3he32J7W4QrPKQlu54YJxqcLKUlDqf63rsMcRyfZ AvYt6wdzv9RNSU8xGUeUdjkvAPWjr3M= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-bRwYtrB2M5KSKKFXxEvceQ-1; Mon, 18 Mar 2024 16:04:22 -0400 X-MC-Unique: bRwYtrB2M5KSKKFXxEvceQ-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-430c76df729so6673221cf.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=Jc+IuFA5dzxNPUyV7TbspOiDF8J59y5aSpq3dwnrVQ/dOcPfgr1BcjmWtVjuMqiTiW sWgX0PVbeu56L8rbg08kkU2TFJg0XPP4xUTW2V3ltrUUIfeq9/UigZ5IE6HhflOa+BQM NAY0dNXlHbPTR6oSzKU5zsbONDBXSeVFQO4T+TuDPzYuLVUEqeZKBrutstmKNbrqJCDe /i9UIhYQdSVKkZ9ArYTdq3FCyk5ID2gtzz1pe5yl8FtyXv7izxD5rUp+a89nrJrVPaMA 9nibTQWCmQSUOyqccUHGR/0ooX0AnRS5YJoezpsMAKZ1sjkF3P4iwopg+5hnW9JhuBLP HHdw== X-Gm-Message-State: AOJu0Yw0MRYKzqCaoAAJ2hfiVcEl8clpK42SfwsV+Hyf37J7+mftsjcM BmxDkBB5PyVZRHZTygK4QjG7Ma1EzZObgLKSVTRkxv0AojU3xLEp5fVUlbrZsn+sgRw2gHP7lAA rTdV7zr2MK4JA22h3zRlr0nOluwgCIHu5yVLLjLQjqiYDVbsyowHb/2lP1F7Yz8+DC6fXHFyArw pYNiqKARo1nWv5s38rDQeS6z3QdmFuwkyTlkGtfKYJD1w= X-Received: by 2002:a05:622a:15c8:b0:430:ae0a:c08f with SMTP id d8-20020a05622a15c800b00430ae0ac08fmr12238091qty.6.1710792261614; Mon, 18 Mar 2024 13:04:21 -0700 (PDT) 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.44.0