From patchwork Tue Apr 1 02:10:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vishal Moola (Oracle)" X-Patchwork-Id: 14034297 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 E29B4C3600C for ; Tue, 1 Apr 2025 02:11:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D46280004; Mon, 31 Mar 2025 22:11:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECDD8280001; Mon, 31 Mar 2025 22:11:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9426280004; Mon, 31 Mar 2025 22:11:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BBB32280001 for ; Mon, 31 Mar 2025 22:11:36 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ADDFC80468 for ; Tue, 1 Apr 2025 02:11:37 +0000 (UTC) X-FDA: 83283848634.14.AE9EF83 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf26.hostedemail.com (Postfix) with ESMTP id C8C2F14000C for ; Tue, 1 Apr 2025 02:11:35 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EfALAMYS; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743473495; 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=qRYvR1rAvbssstSNgyfi531UoTXrgDsOkqVWHoYG9I0=; b=HbTvQHaLJw2dEMbLhqvyKIAM7WePsAtOnwV9GPAzBXdB2ml6PiQBWXKLpk4XiXJc0pGFHP qf4NtescvTRHCCe2QUdTlG6cuxHSPUi/ZrGn44XABjoJO+mCAtQ83GPc9nckxw1CsLyG8B XyjZY3rF05hbuKY6+AxT0vV9qHQwP44= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EfALAMYS; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743473495; a=rsa-sha256; cv=none; b=Oo4uOhObjjwRdojBP0mAxJ2BTs+W3ha3CCygWFSRJPaoN5hFFUex8tEOTae0+hJONaGMys x6MUno5VbJppqp51AFvx/uBbzDKL3eZzvlYgQjMv05kToQ45mUsyIrMnn+ysyO5OQPu89n EsRvVS+E5tZ6+IymQ/FM+BS/y4DWILs= Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2ff6cf448b8so11011875a91.3 for ; Mon, 31 Mar 2025 19:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743473494; x=1744078294; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qRYvR1rAvbssstSNgyfi531UoTXrgDsOkqVWHoYG9I0=; b=EfALAMYSmKWP5v1hBilbGnZ74HkQegP2GEAIC4JUs48GsDAzo371I8vkNLNfPfu4hE 10sOyKlH6dBOYk3U4MXn2QAHRAse2gQ17v16Njm9aAyOPL9qdfuL+7v5iqhVPsod0/dt leNGO6CIJoWjYcz0FGvh6kCFUTSoWMKIzbgy8QVShqhU+Ug6f2Ri3dI3g9j1FzlXQqEw yRiKwaCfF59p2CjmPmCTkfdEhbvvP6W+cjJKtltflieUes9tiIJo9xukr9aXcYXsiX+5 DuOy5VDdfetFSOo8cJ/A6H83Ezvsj0wmMgypOcp9vHA1FXWTRSDPvo/VdKL7UVJn+Vip 4OTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743473494; x=1744078294; 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=qRYvR1rAvbssstSNgyfi531UoTXrgDsOkqVWHoYG9I0=; b=XhrhPtFtWhZX2j60VC40vs7tMK7936L276/K3FYRveg1oRgTB06JgQpKzfQswAhB2N mXS4DxtZG/M+qxdVl5XK5+w12Npp1dZdp+RSAupihKYPBUPoBKNGqsblGYHWxKM/KhAe n4yCwQCpCAGmJ5c/wfY2+y441C2cPEeZvgyC5H25pHwG5pmgje3xLcaFzKj0nKoDSWHI wEeAI2JwCCMR3BMFg19WW11yWtQoJ8eHmGCRZtHLOj8wQxwKqVEawxm1BCZHcFN8rngd rMiBY9uRayCnfN3lFd4VJNvtEmUGAGlGOrYJvWzeckllZCONjsE5QCxZJ+3exDj36AFO NPZQ== X-Gm-Message-State: AOJu0YxT4wSVFMSCgPcAhFbUW6OAjlwzL7iJbxeeKXL2vGJENEP4DQvJ dpGGfguvCxLRDlCYFw6aO/x5bUlN7IOoOvuYk+u/5uj3OYYxJi0BbwuYpj7R X-Gm-Gg: ASbGnctsoN6PLyoPrZvqnfqBUwceWsqozJQrNLgRmxSzpuYHy1iHVpJtg88nd2E8ET4 NaUaNNWmnmyJDHKp74/uA9y3OUwNHcGHL6K35Zs3QxqL8aWedeYbzyaPg4Wi9Uh5lkxbfsTTLsM 6z+/RQNBZipqLFtqS3IDiySSzTezsMcfk0cyMjjz9ycRHdCTAJysN5Iy1DuvQFBDLesSpQFa1A8 el97w3pra3VoHvG0Z8ZjCh3cJ1n8ztqZoX08yzL259e+QHlMDzCWt7b3/0613g59PK9niyfdbG4 DIpQpq8YmAjEonjFXcqyouZaOZBlQxdq7IOdcFkNpndlU+nK+Pl5FihRwIYkRAOj9I0q7OeA0Z6 LLpl6BcFAYqtDBg== X-Google-Smtp-Source: AGHT+IFXzch+myvH4/yZk2PGZtAv8bQ8slVe8J3+jLushY9riWFNOq8lTpZCJ8ILTx/tWy4ScCL63Q== X-Received: by 2002:a17:90b:4a52:b0:2fe:8c22:48b0 with SMTP id 98e67ed59e1d1-305320afc4dmr16080685a91.15.1743473493827; Mon, 31 Mar 2025 19:11:33 -0700 (PDT) Received: from fedora.. (c-67-164-59-41.hsd1.ca.comcast.net. [67.164.59.41]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-30516d3ce04sm8074118a91.9.2025.03.31.19.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Mar 2025 19:11:33 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev, "Vishal Moola (Oracle)" Subject: [PATCH] mm/compaction: Use folio in hugetlb pathway Date: Mon, 31 Mar 2025 19:10:25 -0700 Message-ID: <20250401021025.637333-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401021025.637333-1-vishal.moola@gmail.com> References: <20250401021025.637333-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C8C2F14000C X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: upgq7a1k7gb14rj4xe1g4fbhqj7sakef X-HE-Tag: 1743473495-599819 X-HE-Me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cP0D31x698yyC0hn0BTOzjMIXivKp1bIy3X1/l8krVnLkyH2bPNxBU0dPjSd05cn5H+S4kv0a8kn+Gl3iUg6fCjLqbAZSgtEOuhymmjK7Tbx85+cuSs/8hMehBqBBNWM8Hy8+yiHYsrlujpo1jS+1TTPcFosMYwj3AA9ZJqvR7EzRrCChywusqecsQcS5LHJq5JErDSNRtoPBKlFNKOC8OjKP+FYEPzvU02dOYGItBFwufEXP7s+517z3ttkCBEG75IwAunQUK5x7aaWR88c3FWvXzZPHtEiv8ZS57YymnXoWrJj2AlPzjtsHKmSvjti7vgx0SBvErN6fbRNt1YVehLbxMm8YfxOvbfNb41QIZxE1vwwWVVqwBamrCqv2PlQ/L/wIGkXeG9vK3u8bLENGW+6E2hmu6Mdck+7 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: Use a folio in the hugetlb pathway during the compaction migrate-able pageblock scan. This removes a call to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Oscar Salvador --- include/linux/hugetlb.h | 4 ++-- mm/compaction.c | 8 ++++---- mm/hugetlb.c | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 8f3ac832ee7f..a57bed83c657 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -695,7 +695,7 @@ struct huge_bootmem_page { bool hugetlb_bootmem_page_zones_valid(int nid, struct huge_bootmem_page *m); -int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list); +int isolate_or_dissolve_huge_folio(struct folio *folio, struct list_head *list); int replace_free_hugepage_folios(unsigned long start_pfn, unsigned long end_pfn); void wait_for_freed_hugetlb_folios(void); struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, @@ -1083,7 +1083,7 @@ static inline struct folio *filemap_lock_hugetlb_folio(struct hstate *h, return NULL; } -static inline int isolate_or_dissolve_huge_page(struct page *page, +static inline int isolate_or_dissolve_huge_folio(struct folio *folio, struct list_head *list) { return -ENOMEM; diff --git a/mm/compaction.c b/mm/compaction.c index ca71fd3c3181..dd868c861774 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1001,10 +1001,11 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, locked = NULL; } - ret = isolate_or_dissolve_huge_page(page, &cc->migratepages); + folio = page_folio(page); + ret = isolate_or_dissolve_huge_folio(folio, &cc->migratepages); /* - * Fail isolation in case isolate_or_dissolve_huge_page() + * Fail isolation in case isolate_or_dissolve_huge_folio() * reports an error. In case of -ENOMEM, abort right away. */ if (ret < 0) { @@ -1016,12 +1017,11 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, goto isolate_fail; } - if (PageHuge(page)) { + if (folio_test_hugetlb(folio)) { /* * Hugepage was successfully isolated and placed * on the cc->migratepages list. */ - folio = page_folio(page); low_pfn += folio_nr_pages(folio) - 1; goto isolate_success_no_list; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 39f92aad7bd1..93bc8c4c904b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2896,10 +2896,9 @@ static int alloc_and_dissolve_hugetlb_folio(struct hstate *h, return ret; } -int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list) +int isolate_or_dissolve_huge_folio(struct folio *folio, struct list_head *list) { struct hstate *h; - struct folio *folio = page_folio(page); int ret = -EBUSY; /*