From nobody Fri Dec 19 07:43:42 2025 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 8458C22C33C for ; Mon, 13 Jan 2025 13:16:45 +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=1736774207; cv=none; b=MB1aeRlreqm924NLMTmr76HbIHA1fP0qSU4KV/bRMKL0XfEwGuiQfnJe0hm2Q+LuoiQAnTUm8PHZRvtxcOS/gwApU5IulQBm70ONymQsZFscNIV8ljjA8gEJGtJEGtov6NZQMIKFJ4voZtExAqj7T9S0fg0oYutTpix1ltTNQRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736774207; c=relaxed/simple; bh=SF0kbN9Vy6DRrUS9rEO5e15pj8xPRgqZaaqNEWIxuWo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gcJOBcKjudXpgx0gaTDUgp9Kw9AaNilvTk+Y2nSmOfmVT2V5ao/1oiZpTn6mwndp0s15sJ3W1V8QwO/jb4kXpmmsS77eP4XHbnN8/pUv8cWUb7AhHxBh73xyQSIGkCGmzQ0QTIEUYaFYrUc51a4JeyZLxL/SrstAW7miCbqXcTg= 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=UvaNwq7i; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UvaNwq7i" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774204; 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=9usYI5DgNUlDmY6F4Dug4aGXBw+qPPqxLUrXzQ1Tmoo=; b=UvaNwq7io4wZEMHzRZfyDII9XFC2YEypRJ5lLkxbk6VcdUFv5D52D6dzK8eAHpaItxZ15o ReLkXOYziycMIFa1ORwtpxKfRI3PWFVpToGFmS+1YIjyOYlAtlk6Ha93jcFWxcFnxcBgAC cdeTsg1QCT7XK/0DCmDuiZJeBzwIw3w= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-HEjyey1jOYmz1QhQ6-9q5w-1; Mon, 13 Jan 2025 08:16:42 -0500 X-MC-Unique: HEjyey1jOYmz1QhQ6-9q5w-1 X-Mimecast-MFC-AGG-ID: HEjyey1jOYmz1QhQ6-9q5w Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4361fc2b2d6so24482855e9.3 for ; Mon, 13 Jan 2025 05:16:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774202; x=1737379002; 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=9usYI5DgNUlDmY6F4Dug4aGXBw+qPPqxLUrXzQ1Tmoo=; b=IE334Gjk9nLkXEzXAukUnfkZgLjPiC7q5cbkNOrbjbs3ksikUn+ufhUeyQ7LN36/GL KOkK8eaIubnfdumPMBIaW8wO8xcwDjeQ4FOZAe9SN2cgmQNcdm9NL+1uMLy4jAqpvHju GoGszFSt+3ZoVCWfi2OObU1vNpw3hikraS9Ott/4GUbmOeFd5hn+Fge/kb0HfzQH2ycf 3+/OOBBsg13XGb8uXwhDBuit9knCcvSORaBhOsh2EMnGuDDWGeMKtD5s5j1hA8v5jpsv 5GKjLNb6WCX9Rd53/3iIePz5RxRgdz5Qr5sd/zJaygkgY9NKjFqUfSG9bcr99wZa3+Uk CfcQ== X-Gm-Message-State: AOJu0YwJdjIOr4WrD8RzAzYKSYhPAv/Pxu6VV3SS5sTLmq4SN89/q5OT pJjfLX6iyPwcARSjWfBOD5rghx4EaVN6BgtyTe/kGDd/ZzIsRlNza0RyO0xbmtAPbE7muKd8P2g p/0dv1K+a9fsCD0yglohj2e2oIv/wQAixn2IfBh3lf8UjaW5u0Tm8blxn8GrkTehzzMaUHWuLhv BBMK9P0ySkFByx6VaTLneVAOBiF61zDNM+4SNQy54I1lVT X-Gm-Gg: ASbGncsQI3qSwmaDRW+rYd3SH2jRojwvXq/ONsBK6bjqZ+B6JcJ3MHyo3euz87RUEUx mIP8rbws8uqYte65h5k45Y8mLwmJbtMpdwmlyQxSyFgIE44bOnEQbNlLofOo/Kf4fojiObscDee 58HHZWkVdtAALQzwqmUhMw+Cic04lc3n3rxqSg+7ju53XVdDNWN5nzr+GF5mAMm+tUn4q0rVmXJ yxXbPdXi8KDpzVddFb5EMzjXeMy27K8eemokuG480DffD6mXZWD X-Received: by 2002:a05:600c:314b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-436e26ebb6fmr73793275e9.29.1736774201754; Mon, 13 Jan 2025 05:16:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1QjX6fKScjtkrek3bHe4bgrZiW5f8BsOnYBHXEjoxDvqfSM2uADNbnmwxz9BF73D5jNf0aA== X-Received: by 2002:a05:600c:314b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-436e26ebb6fmr73792885e9.29.1736774201284; Mon, 13 Jan 2025 05:16:41 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e9e6263fsm146445655e9.39.2025.01.13.05.16.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:40 -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)" , Baolin Wang Subject: [PATCH v2 2/6] mm/hugetlb: rename isolate_hugetlb() to folio_isolate_hugetlb() Date: Mon, 13 Jan 2025 14:16:07 +0100 Message-ID: <20250113131611.2554758-3-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-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. Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Baolin Wang Signed-off-by: David Hildenbrand --- 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..a93b508bc0e0e 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