From patchwork Mon Mar 31 08:13:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033796 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 6E090C3600B for ; Mon, 31 Mar 2025 16:33:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05ABE28000B; Mon, 31 Mar 2025 12:33:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 008B8280005; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E128A28000B; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) 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 C240A280005 for ; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 996E8140D7F for ; Mon, 31 Mar 2025 08:14:02 +0000 (UTC) X-FDA: 83281133124.24.CCB1390 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id CCBDA40009 for ; Mon, 31 Mar 2025 08:14:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ioFZUj5t; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408840; 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=o7TFDmuhd1kibEufM0EW11EDmCZ8boAIcxccfqu0TA0=; b=2fYaegcnewf0P6Cnh45yLpW1n3VLHUNQelk5WS+xgys2hULqxCgCaR9ISy5QT3NmgRtnqt 3B77lcBQVN5hiMuMYuD+wrIuLmHNsRANEIAbeXphBkBKq6RCWaIY2aFXuOB789FBWV/hhT GjLOF4zbafguSHY7tbfIDJ1CGgBaaZk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ioFZUj5t; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408840; a=rsa-sha256; cv=none; b=kM2mFa/Geix15Aykhp+qLdSquJDpB2CiwThnU19RaRe6kg7jJ2Xv+pP9GC0DxXHVbvYvo6 3xlg7VZV+HqrrBWpfELc9trN45fjmSO0+dpqq6oCy9XaDUSXIfdFAXYgm8+t3nhJjCbXdR aKbDCMA3O9PR5y4sEss/spdpFUDBYkI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408840; 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=o7TFDmuhd1kibEufM0EW11EDmCZ8boAIcxccfqu0TA0=; b=ioFZUj5tX7pBI8XAyvWRTEv2I46fHZZ5KTJtGoO3PxnXZg9lx2IeIvkeFQBKMIufXjUhBF S0++kCmxJTBtPdv2E/Ou4WcgX5Uq3lhwyRC12vXEfAk4maYByqr1RF+6qW/msDYwf0Ij4c G+p+/SNLGj422VjVxIyWFHRHgHbC30w= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-BaTzCZBMPDWfogDH-E7-JQ-1; Mon, 31 Mar 2025 04:13:57 -0400 X-MC-Unique: BaTzCZBMPDWfogDH-E7-JQ-1 X-Mimecast-MFC-AGG-ID: BaTzCZBMPDWfogDH-E7-JQ_1743408836 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7379319560B8; Mon, 31 Mar 2025 08:13:51 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49E231955BEF; Mon, 31 Mar 2025 08:13:47 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 4/7] mm/gup: remove gup_fast_pgd_leaf() and clean up the relevant codes Date: Mon, 31 Mar 2025 16:13:24 +0800 Message-ID: <20250331081327.256412-5-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: CCBDA40009 X-Rspam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Xkc eQ71897ByEG3QXrH68jgizdS+ujyDgegoXqfftYY2L9rUpB2lmCri+diIV3i32aKaZXFnUjMDbMISp/MuTjC//N9BOA//vcTe31JrwM9S4cxy+8MKJ7934R+EM5/e3A5zDYueBIUSytusj+swd0zSoBSpX9ULSafmoY8fdUZahQ6w+gNFRtdGddBxyC4XtFOLucwtXK60gq40UPsnux70O+p8SkpgQjDGjSoSbEaWJJ0vX3+g2WVbD7N8pk2Md6WPG6mIioZBKrrVPNihyrclrTnQL4MBydreOASAvcPQSLAXMHXO7CCUmJPWGw4kZbSaz8eBH324J8qG8ioo+pD/ByoLkfHJJJMqycrJ3iWSQ4kl8Mt/EJnApdAbYg== 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: In the current kernel, only pud huge page is supported in some architectures. P4d and pgd huge pages haven't been supported yet. And in mm/gup.c, there's no pgd huge page handling in the follow_page_mask() code path. Hence it doesn't make sense to have gup_fast_pgd_leaf() in gup_fast code path. Here remove gup_fast_pgd_leaf() and clean up the relevant codes. Signed-off-by: Baoquan He Acked-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/gup.c | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a15317cf6641..58cdc5605a4a 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3168,46 +3168,6 @@ static int gup_fast_pud_leaf(pud_t orig, pud_t *pudp, unsigned long addr, return 1; } -static int gup_fast_pgd_leaf(pgd_t orig, pgd_t *pgdp, unsigned long addr, - unsigned long end, unsigned int flags, struct page **pages, - int *nr) -{ - int refs; - struct page *page; - struct folio *folio; - - if (!pgd_access_permitted(orig, flags & FOLL_WRITE)) - return 0; - - BUILD_BUG_ON(pgd_devmap(orig)); - - page = pgd_page(orig); - refs = record_subpages(page, PGDIR_SIZE, addr, end, pages + *nr); - - folio = try_grab_folio_fast(page, refs, flags); - if (!folio) - return 0; - - if (unlikely(pgd_val(orig) != pgd_val(*pgdp))) { - gup_put_folio(folio, refs, flags); - return 0; - } - - if (!pgd_write(orig) && gup_must_unshare(NULL, flags, &folio->page)) { - gup_put_folio(folio, refs, flags); - return 0; - } - - if (!gup_fast_folio_allowed(folio, flags)) { - gup_put_folio(folio, refs, flags); - return 0; - } - - *nr += refs; - folio_set_referenced(folio); - return 1; -} - static int gup_fast_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned long end, unsigned int flags, struct page **pages, int *nr) @@ -3302,12 +3262,9 @@ static void gup_fast_pgd_range(unsigned long addr, unsigned long end, next = pgd_addr_end(addr, end); if (pgd_none(pgd)) return; - if (unlikely(pgd_leaf(pgd))) { - if (!gup_fast_pgd_leaf(pgd, pgdp, addr, next, flags, - pages, nr)) - return; - } else if (!gup_fast_p4d_range(pgdp, pgd, addr, next, flags, - pages, nr)) + BUILD_BUG_ON(pgd_leaf(pgd)); + if (!gup_fast_p4d_range(pgdp, pgd, addr, next, flags, + pages, nr)) return; } while (pgdp++, addr = next, addr != end); }