From nobody Sun Feb 8 06:05:40 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 F17592144D4 for ; Fri, 10 Jan 2025 18:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736533323; cv=none; b=NRykFE04GKsdQV5E1W+DdXmF4YgiSXfLmdQlr9UVgVis44kcDTd9xFlT/q35Yu48jIzPlbwoj43ka35aghNJYbv1ZSvmKTJOaAcEkf+px7zbKNdcXs+hdREA/+/KwSz0iL3bWdaJA7GC2COqR9FgVh/2J3in4yDisixetp49n1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736533323; c=relaxed/simple; bh=x+jx+lZFi9RdGo//UuHj5uXGcSqk3aKdpGA/LUS/wTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DbJtT9UjcXT+aPyjqst9GwukVijHxMR5GHPji3BJNiOEx40itj+X+KhzgPMbHCczt1F/zHKOF3gMgrZa7exhFgev5GhvPvXvuMAAw+/l+4EYv0HkjS5O6TbrugnGSwoBde8PPTMbAMWY7JcVOYsPdtRIx7vE7R2udI8kG5DtJm4= 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=ddud1pXY; arc=none smtp.client-ip=170.10.133.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ddud1pXY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736533320; 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=tRBcf145a4wbVi9jTDlwWferknOn1sr5Qv/yEdUMYsU=; b=ddud1pXY8Kk/NaNB/k2flYjZqOwr5s+yAXzOTP0b2pIOSdW0ocarCUcgDxONxhov6cFYHQ kUNac905y23ttkiU9t3RFY0kXdPX+sw+FoxaHC89h8uNS8knvh6/3zUYpnfLdqqYE3hZkT FV1WsrCfEpOB1eSfMOlva7CCunEALkI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-7pl9SbOgP5GVT4ODLqOIFw-1; Fri, 10 Jan 2025 13:21:59 -0500 X-MC-Unique: 7pl9SbOgP5GVT4ODLqOIFw-1 X-Mimecast-MFC-AGG-ID: 7pl9SbOgP5GVT4ODLqOIFw Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3862c67763dso921854f8f.3 for ; Fri, 10 Jan 2025 10:21:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736533318; x=1737138118; 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=tRBcf145a4wbVi9jTDlwWferknOn1sr5Qv/yEdUMYsU=; b=f0IJQC+8ti2dRFxNPP5X0Fv7S2uesdwpMw8OOKFRG87m/GzbeZuj0gsRUI2Msyl9pI JSjk/Vebi7OM2MQSyzUdMZQRJsBuKquzGMM7Ayej88ijbTVJ35twUJdNu/epkbMD3/63 bt9ubM/UNQpauSx1KeoA6JVghrIoDg+mXxR1m+EaPC0rHnPAU7NOXB0zhyozxffsELOx ouIHTghuCX3/+ZFnj9M446gnI57KABDx96oX3n9i9evysYFjmO9zcF5emn2PqsKXVFkI 4FUjL9qoegp1RnFeab6I4QSY81JoPDt6BdkyJls9637Dh4dQOB9ZeMQ3vmPaJJi7JQ9O 0Neg== X-Gm-Message-State: AOJu0YxRRmPsXs0FqVC9dTUeseUBpfm0sGZh8iij2Wmd6Py+KdOgxFXI D3rwQQV4eeGJRky8ApozV8UxgwDVgpBmK2S5qsayNirgwA5Z3lxwER+jwgU7N75EkIvAZaIP3NU Mz9vbbPftUDcEmiNO2W2EF90ZgjotlknOxh2hXyxvmqRwOtDE0D/4FquY3kh3hluFDwtBQ/lw0q FKeE78aR3bf9qrAFbRhyPVFOZcp73osE1fVhO7YRci1mq7 X-Gm-Gg: ASbGncu3zh5kdJtbk3DMCt/7radPD1Ep/NSZXB8gySau0xZZMgvqMeO9ehwucUUowgf obYepp92f3N+u5fSiv42WN2WORwY4aDbmzAt6DV08rTqD6APUlur50mt6vVyxr/ilNXJ0+ohA1c YroXvlWdvzW+1tZxOMTnZMi38qEnAAxXPxbi8tBJXoAgiiFEPmONvW/diQGvjsoPDnz+1d81JDf 5WsmWyOjp3NTr8LLwRzJ60AmjNmH9nfipgmP8XSPuTnEdgX7XHt1EL02/wifdrdO0wblSE0avIt R5CylaYnog+iomtMge4VrdGKKyg/0j16S/9FIZoAVQ== X-Received: by 2002:a5d:64ce:0:b0:385:f092:e16 with SMTP id ffacd0b85a97d-38a87358eaamr10067260f8f.55.1736533317703; Fri, 10 Jan 2025 10:21:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQVVcAg2GfKFgY/NCz7qN+LDaq6+VWQgH7WNixvGBrnqPMWFIuBEKOik8O9disKHaGf0f0SA== X-Received: by 2002:a5d:64ce:0:b0:385:f092:e16 with SMTP id ffacd0b85a97d-38a87358eaamr10067233f8f.55.1736533317258; Fri, 10 Jan 2025 10:21:57 -0800 (PST) Received: from localhost (p200300cbc708e1004f41ff29a59f8c7a.dip0.t-ipconnect.de. [2003:cb:c708:e100:4f41:ff29:a59f:8c7a]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38a8e3838a3sm5187851f8f.33.2025.01.10.10.21.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 10:21:56 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" Subject: [PATCH v1 2/6] mm/hugetlb: rename isolate_hugetlb() to folio_isolate_hugetlb() Date: Fri, 10 Jan 2025 19:21:45 +0100 Message-ID: <20250110182149.746551-3-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110182149.746551-1-david@redhat.com> References: <20250110182149.746551-1-david@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: quoted-printable Content-Type: text/plain; charset="utf-8" Let's make the function name match "folio_isolate_lru()", and add some kernel doc. Signed-off-by: David Hildenbrand Reviewed-by: Baolin Wang Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/hugetlb.h | 4 ++-- mm/gup.c | 2 +- mm/hugetlb.c | 23 ++++++++++++++++++++--- mm/mempolicy.c | 2 +- mm/migrate.c | 6 +++--- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 49ec2362ce926..c95ad5cd7894d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -153,7 +153,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long fr= om, long to, vm_flags_t vm_flags); long hugetlb_unreserve_pages(struct inode *inode, long start, long end, long freed); -bool isolate_hugetlb(struct folio *folio, struct list_head *list); +bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool un= poison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared); @@ -414,7 +414,7 @@ static inline pte_t *huge_pte_offset(struct mm_struct *= mm, unsigned long addr, return NULL; } =20 -static inline bool isolate_hugetlb(struct folio *folio, struct list_head *= list) +static inline bool folio_isolate_hugetlb(struct folio *folio, struct list_= head *list) { return false; } diff --git a/mm/gup.c b/mm/gup.c index 00a1269cbee0a..2cc3a9d28e70e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2344,7 +2344,7 @@ static unsigned long collect_longterm_unpinnable_foli= os( continue; =20 if (folio_test_hugetlb(folio)) { - isolate_hugetlb(folio, movable_folio_list); + folio_isolate_hugetlb(folio, movable_folio_list); continue; } =20 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9a5596022c4b3..da98d671088d0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2808,7 +2808,7 @@ static int alloc_and_dissolve_hugetlb_folio(struct hs= tate *h, * Fail with -EBUSY if not possible. */ spin_unlock_irq(&hugetlb_lock); - isolated =3D isolate_hugetlb(old_folio, list); + isolated =3D folio_isolate_hugetlb(old_folio, list); ret =3D isolated ? 0 : -EBUSY; spin_lock_irq(&hugetlb_lock); goto free_new; @@ -2893,7 +2893,7 @@ int isolate_or_dissolve_huge_page(struct page *page, = struct list_head *list) if (hstate_is_gigantic(h)) return -ENOMEM; =20 - if (folio_ref_count(folio) && isolate_hugetlb(folio, list)) + if (folio_ref_count(folio) && folio_isolate_hugetlb(folio, list)) ret =3D 0; else if (!folio_ref_count(folio)) ret =3D alloc_and_dissolve_hugetlb_folio(h, folio, list); @@ -7417,7 +7417,24 @@ __weak unsigned long hugetlb_mask_last_page(struct h= state *h) =20 #endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ =20 -bool isolate_hugetlb(struct folio *folio, struct list_head *list) +/** + * folio_isolate_hugetlb: try to isolate an allocated hugetlb folio + * @folio: the folio to isolate + * @list: the list to add the folio to on success + * + * Isolate an allocated (refcount > 0) hugetlb folio, marking it as + * isolated/non-migratable, and moving it from the active list to the + * given list. + * + * Isolation will fail if @folio is not an allocated hugetlb folio, or if + * it is already isolated/non-migratable. + * + * On success, an additional folio reference is taken that must be dropped + * using folio_putback_active_hugetlb() to undo the isolation. + * + * Return: True if isolation worked, otherwise False. + */ +bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list) { bool ret =3D true; =20 diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f83b73236ffe7..bbaadbeeb2919 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -647,7 +647,7 @@ static int queue_folios_hugetlb(pte_t *pte, unsigned lo= ng hmask, */ if ((flags & MPOL_MF_MOVE_ALL) || (!folio_likely_mapped_shared(folio) && !hugetlb_pmd_shared(pte))) - if (!isolate_hugetlb(folio, qp->pagelist)) + if (!folio_isolate_hugetlb(folio, qp->pagelist)) qp->nr_failed++; unlock: spin_unlock(ptl); diff --git a/mm/migrate.c b/mm/migrate.c index caadbe393aa21..80887cadb2774 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -128,7 +128,7 @@ static void putback_movable_folio(struct folio *folio) * * This function shall be used whenever the isolated pageset has been * built from lru, balloon, hugetlbfs page. See isolate_migratepages_range= () - * and isolate_hugetlb(). + * and folio_isolate_hugetlb(). */ void putback_movable_pages(struct list_head *l) { @@ -169,7 +169,7 @@ bool isolate_folio_to_list(struct folio *folio, struct = list_head *list) bool isolated, lru; =20 if (folio_test_hugetlb(folio)) - return isolate_hugetlb(folio, list); + return folio_isolate_hugetlb(folio, list); =20 lru =3D !__folio_test_movable(folio); if (lru) @@ -2203,7 +2203,7 @@ static int __add_folio_for_migration(struct folio *fo= lio, int node, return -EACCES; =20 if (folio_test_hugetlb(folio)) { - if (isolate_hugetlb(folio, pagelist)) + if (folio_isolate_hugetlb(folio, pagelist)) return 1; } else if (folio_isolate_lru(folio)) { list_add_tail(&folio->lru, pagelist); --=20 2.47.1