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: 1908725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=U/saFQoS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=ex9a=km=vger.kernel.org=sparclinux+bounces-539-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TqTb23fzVz1yX3 for ; Wed, 6 Mar 2024 21:44:46 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4TqTb23CGBz4wbr for ; Wed, 6 Mar 2024 21:44:46 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4TqTb238Pfz4wc8; Wed, 6 Mar 2024 21:44:46 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=U/saFQoS; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-539-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4TqTb20p3Mz4wbr for ; Wed, 6 Mar 2024 21:44:46 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D5F8B28A811 for ; Wed, 6 Mar 2024 10:44:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCF8160EC5; Wed, 6 Mar 2024 10:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U/saFQoS" X-Original-To: sparclinux@vger.kernel.org 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 558C960877 for ; Wed, 6 Mar 2024 10:43: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=1709721805; cv=none; b=hq7G7wOsP6KRP4i/V4Ep8T/Y9ziZq79yu//1mjjqYPf9zQI61QzAacDfifwKzh7VArUs81IBt2o0wV8KAItwK5qwX27iePAVxn4hi4/d78jnJoFej4NNSlcZIf+7c2E3KCcwnHx898qXhg7m48O5nYhgZC8bWw1kdgsg4xKCG58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721805; c=relaxed/simple; bh=G6OxanI3sTRxSNp5lhYS2YR/ic0+r3tVkIbUpPCZPlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vBwWnC4uxwcwhnB+guIo02dVctiUZQd6GsJIqjdDN8znG8hztVFCqkgah7+A7DAXaUYOg4XOlWNlqlzSeeKU/2OaRzWdwjX+E1NZfLqRrX6nks+YBfA/escOLC2AlGSAL8IsYYx1JRlvi2U3h60uZeMk3WHDtsUwiRulR6Vn13Y= 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=U/saFQoS; 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=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> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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;