From patchwork Fri Jan 10 18:21:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13935194 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 06B60E77188 for ; Fri, 10 Jan 2025 18:22:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91C256B0098; Fri, 10 Jan 2025 13:22:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CC6F6B009B; Fri, 10 Jan 2025 13:22:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 746126B00A7; Fri, 10 Jan 2025 13:22:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4FA6C6B0098 for ; Fri, 10 Jan 2025 13:22:04 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C9EA780D4B for ; Fri, 10 Jan 2025 18:22:03 +0000 (UTC) X-FDA: 82992361326.14.3B28080 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 98DD2140013 for ; Fri, 10 Jan 2025 18:22:01 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QKf4rW+c; spf=pass (imf23.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736533321; 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=tRBcf145a4wbVi9jTDlwWferknOn1sr5Qv/yEdUMYsU=; b=6UFCu0tHBNTnIGnMAcpU6lS0Sk2HbaA+R4EW0YSs/UVVyoY5irekoLId8ToMoJ8SAFCjJE AYHlAqsPV13G75ZscKAm3WUAX6T8XAAZOcBPJdSeTcyK/KrzqfQL92jpVLYwarktSw4iUZ 5MmLW8TnZbKD/ZtUxoOYxX3jM/pWPzY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736533321; a=rsa-sha256; cv=none; b=3CUlUvyYfBWYhjHZJfxcO9stKHeW8CxaMZiru4EZZxGArAq0uXZCVJrjUpayhwKdqPLm9x De3rlM9zRTyQihfPIAzElM5xzyDqAaAnxZnjlhMmGfUNizRtsoNEd/B6hIfw6vvpi6Q89d kDmGkzjEZrWbIbVZv4r3c7lusv4dHCs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QKf4rW+c; spf=pass (imf23.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tRBcf145a4wbVi9jTDlwWferknOn1sr5Qv/yEdUMYsU=; b=QKf4rW+cFc2LpEvb0cOgPe/rzjdPcHujpwMGJB8tp+FD9XJv1oha0nYG1u2iHb6o9V4pJZ kP/o/rTmkkAvwOJqfn+bSBc5dgzhomcNXADVQ5Rec+teIB0lq5iavK+1ppcEtnzcSzMuWU E2kcdkvmWFgEqaqhl1MFywMCcRcIkWo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-lsFDSOTRMtGtqJv9TcARDA-1; Fri, 10 Jan 2025 13:21:58 -0500 X-MC-Unique: lsFDSOTRMtGtqJv9TcARDA-1 X-Mimecast-MFC-AGG-ID: lsFDSOTRMtGtqJv9TcARDA Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38a684a0971so1013053f8f.2 for ; Fri, 10 Jan 2025 10:21:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736533317; x=1737138117; 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=ABkiidoQLvz67Cf8RQviaIswJb7Zwy/FlTaLGhzJlkpNCRqDonlUcrDDVrfKsuHHcD suK5oq+kmdjdAQsMoAqsI54nPrYW8+x+E+EUUVhaunLmSEhMgEmuWZ1KBI/Wl2LpL+Dk TYrBoaUD9L8UNp73iKo6BtdpfISUav8hp8BjCvk77vjitQ7xXB8YC63A5sP2g01V9FyI XoDo5ghlZE1AOGu/v7TPufBkKFRCG6ltvpCwOE7iUW/2sBVVwfAjtTykTQp6zXA0/x0n 5uwwduylQjOHRhBfv8eHjjl+8ElD7q7M5pNPQu1A77DdJHBpkln/Gxt8QhoENetaE9MA 1FcQ== X-Gm-Message-State: AOJu0YzZjNeM4usDDGIL9Vn116sqlTRZ2RUZzqVkRnpOnj6E0a/7tJie lFMg8y4TWyBgJWOroHoqtF2OfwN5rAXvj77r78EQHsqhzHEgwfItILlUABpKDdk1al0Gu56lp2j GMjiNKceyIi8Z0c587J4+PgIqXhV9DwLBUBBfOgVjugjiQMLt X-Gm-Gg: ASbGncswN7+nJBDLFj6ztx2C4MIA0bjyGYGi9xxHczDcQW0EPX+z1MBcL54KToY8LTp 98+ftGeFh0amvQAFAA7V6WPOKFbnFvqVfooKyR7tE+TkJmtCVsavzf9hJCdZFoixPS/wE8nwidU P40Zb3YFrL44Rj2PY/xn+fVhrkhcmmuMiWAm6aoMKp39ZVgdcHTABzKTtHr1pyKbrnIbW1kRYDk ZTakjdF/w1+/Z0fD6x5WCCGtRJpEYbpAfg2GrsHzZ8aZVCyjlqiIVrnkC2ws2mSib+LPIGdqb3R 4gdGdfs/jpGlTcjysFlv8Vr8hkaStQJ3yuvmkNhzmw== X-Received: by 2002:a5d:64ce:0:b0:385:f092:e16 with SMTP id ffacd0b85a97d-38a87358eaamr10067250f8f.55.1736533317608; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: v1MjA4yB39K79Wc4XZSAaum--x4tssrMJ2CPTewlEjE_1736533318 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 98DD2140013 X-Stat-Signature: 8564cxqwqwapxcbs6qm5g7x9i3ijiae4 X-Rspam-User: X-HE-Tag: 1736533321-259952 X-HE-Meta: U2FsdGVkX18PpTYiYO6r1MAXo2agUpm238XMxkeVhT5+uKnHvGNVu5rEc9CwIy695/QG/L8ScCmWA2xtRDFPnNaEAz8LYjyB21x5tDQ5AbsWttN7JuAbH68zDDPxU4byAUjprZsCg5/vsxPFIUwjc9E98WgGuff4pMbkVGXLLMHbqkXLj76pWBhG6nOxEnAhgFSqDCUuoRPsjIW2CQj/HnLy+WL8ne2QFt4GxirqAjYQur37h9rKXuJYFIlc2AkTF0oQVbQ7fC6mZC9sEgAVy3UipIYyKZdIoYI5cOgqSLGQLWoTiDOOxE2y9Bstaxt0aWnyMSxfn+7mzD0N99lx9YU3EhbgJIvSAwswIkWsbY7uEM/u9RrNDcUwfb3+ajhg6yx03YM4rfHoCLLdAalmOu2oCzVPn4VaNggXZZ1+CXyaxCifVC6TnznpiUcONP/PwHrU5yd+bLARMbLaV0sO10ocXl64nhCg8/1qtvflc0XDAU2cPrPbuEPbZq0MbmwZB10PPBbK3LG7Zpd9B3fZn0uOE+k/o7JJGhqarK4UCTeVvrqMzjs1Xf+tjPuELM/r8gELqwrTqwo5nKyJpUj+cvh6sdF1tdXSnQe6NOYGlYvhZAKEBJf7eM/aRu182RmbRub/4XLl0w6aC/aptZpn7ZK0HuXjjpqysows8hyt+eeRliG8IoEoU8me//b6AZ+Q/EOzMyEMGlvsDzjM0bTYfZNF7stmWwd0A69g3n1nyLzBv9rGrijRBYePAoAwWbaN6/dFXBqNQ2PxG2HR9gUUUXrNLLGgFU9bRDbg5Bet8IN9lHsJqO7SgNn1iKD+rs56bbluv1zUQrP6GgDM87sh3NzEfe/oaflPcHW34hv+15nZNYBH9m72gT2KM3xyzvv0skaIIyQO/BrmIbjq8BUwKFU27maJSAQfVEVGbZkGNSiQnKZqYPkFqs6fRYrD90t6Am0xkIsZGyqSvk8mW42 ecKU2b4F gL3X+l3HVU3CKWW60tYScditpKCLqojgQLbxRtWW52CF6JRKaweWvECfN6TCgvWqv7ti+Fx5LGt4HOHl+EDgoE0CQ9rsl546EwkZLZkizlrDiX4oxSX92TR9HuG0LguuteYsahj/F5d3Zc7I0fcsDewV+G9J1hyGRrD60ziWLYA9erXtxKMVLxYzXf78zteIzCrHe+GTnxYhWjjaXbsh5VT5KZ3qBU0HQ23GlD8q/8Umy5T074+5jhiX5MjmdgBsyQs3G+v4kgKYczX0H8160QJdxPc0nJmQCdKrRZhxpNVQue/Na6YucUyj4nVt8oh4PWwhu6JXl0dIq7QonhBZzKe0l8qejSd0GyC+dt8WItTLM3eQvXxp98vErYgZURNm8k44wzmcz0LbU6vArwA6EP9wSixWW6CH95yuMrApxhm7IhzTp7Enj6tU5LLltSXgKIYWLyuOj+6hNzqZ0q6gtYMEqYbP/RBX1jClG 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: Let's make the function name match "folio_isolate_lru()", and add some kernel doc. Signed-off-by: David Hildenbrand 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 from, 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 unpoison); 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; } -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_folios( continue; if (folio_test_hugetlb(folio)) { - isolate_hugetlb(folio, movable_folio_list); + folio_isolate_hugetlb(folio, movable_folio_list); continue; } 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 hstate *h, * Fail with -EBUSY if not possible. */ spin_unlock_irq(&hugetlb_lock); - isolated = isolate_hugetlb(old_folio, list); + isolated = folio_isolate_hugetlb(old_folio, list); ret = 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; - if (folio_ref_count(folio) && isolate_hugetlb(folio, list)) + if (folio_ref_count(folio) && folio_isolate_hugetlb(folio, list)) ret = 0; else if (!folio_ref_count(folio)) ret = alloc_and_dissolve_hugetlb_folio(h, folio, list); @@ -7417,7 +7417,24 @@ __weak unsigned long hugetlb_mask_last_page(struct hstate *h) #endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ -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 = true; 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 long 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; if (folio_test_hugetlb(folio)) - return isolate_hugetlb(folio, list); + return folio_isolate_hugetlb(folio, list); lru = !__folio_test_movable(folio); if (lru) @@ -2203,7 +2203,7 @@ static int __add_folio_for_migration(struct folio *folio, int node, return -EACCES; 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);