From patchwork Fri Mar 1 21:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13579163 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 8CF3BC5475B for ; Fri, 1 Mar 2024 21:47:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7E186B009C; Fri, 1 Mar 2024 16:47:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2C3D6B009D; Fri, 1 Mar 2024 16:47:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 977936B00A0; Fri, 1 Mar 2024 16:47:17 -0500 (EST) 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 629456B009C for ; Fri, 1 Mar 2024 16:47:17 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1BD971404D3 for ; Fri, 1 Mar 2024 21:47:17 +0000 (UTC) X-FDA: 81849806514.05.549039C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 7D35E4001A for ; Fri, 1 Mar 2024 21:47:15 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nGoNpGBE; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709329635; 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=6KeEeju/hMI7K6EYqbMB4GB0Eui15rJAsgnCJmbCFsY=; b=pi2+oirLCkDs7h0ug746L44HBB5hMVJ4R2FA6gdpRciEzbQF6voyyK4e9jM7wsMp9mZLuP GxI9nGxENhNCtXUZb3gQfYUfu8oPF3ccl/I5nsABJfkJTXrNePto2pwm2KfTWK56cKqNkY uhI/Fym6cLlp/NXjMDFnjmYBh/nM4ug= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nGoNpGBE; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709329635; a=rsa-sha256; cv=none; b=roK0qCwTaMjKVAztt2IpM8WrjCaXXgJfEJP4ptkidRNDpdFRjRYcKGpGaHYwwpJOdkRPB1 KCFNo8n6E9PuyOvWvDLA0JBTGWFDru3o76wuknnWOtPwkIZU1zVM3alTHQPuhW18wbq/pG wmiEjZwos2vpAUnCZDs1KxoJ5eLIgqM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=6KeEeju/hMI7K6EYqbMB4GB0Eui15rJAsgnCJmbCFsY=; b=nGoNpGBEvpxTXESstmjqc/TLQ6 6WywmjqMQNZkIZIiEWu+wyGpatscC9dptVrDqrbw7468JlwTiV5cmh9ttWD1aDP4Spam9plYNzncb sMtrrNXSpvNLbP1qPIVGaIKdN0xjmI6H08t6jScG4yWif2Z2FZ8i/d7cXqm1a5prdpnXJaopZBz5H QS9Fa1kf2kdA7B/7RG/of/GtE+SHWlB3DeHox4AMysHbppB9JQNF6Xxa0z5NvaMkwj15EUOqtgEgk ugxf6wNoVAnaTfWHprwsA0CfkE8ZcgdJU27d0cxMBaIT5hnmtwV9GiIp3u7iRYL03q0lno/UHghTw vIU0oYpQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAin-0000000ByEn-3NYS; Fri, 01 Mar 2024 21:47:13 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Oscar Salvador Subject: [PATCH 4/5] memory-failure: Reorganise get_huge_page_for_hwpoison() Date: Fri, 1 Mar 2024 21:47:09 +0000 Message-ID: <20240301214712.2853147-5-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301214712.2853147-1-willy@infradead.org> References: <20240301214712.2853147-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7D35E4001A X-Stat-Signature: n5hrr4uktc8f7g9qr7h1668e99xfiyg9 X-Rspam-User: X-HE-Tag: 1709329635-799284 X-HE-Meta: U2FsdGVkX1/77v7BhjvZkEHjMLaUhh7vsnvSwS+XOFj0uQanHqhmYAGjw8LZJGrkUk2DmkzzlJL4ZWO++aQW4jffyoV/nfPw1Hq7joLMDazvO6WPnJfuRWGxnU6AX985kXddcbZc1D7HohPnuINUg6VDNfCcfU5jr72DDtoCiSbgB5wz+NmW+OH0LHxwLMVQz+NLIze3lL1FXbnXqDYFWKX+K/mZFpRMBd72SlIrCw6vrrXXV+CeamgL7/fkp3hwF4fChdBpk2WQB9WSym6I6VdFjDPO9fvIjWUeO/8lPrdKPBxa1qphiZea1EPzJM1RM8qnRJ9+yWA2GVCwqPkpxJr390wWeRQyII5XoB98euVww6yC4AzpqCc7lxObmpqchx5FHnfqqnW0FCeAl3eVgaH2m7OmXVcG+bhH8mAVOVd9aKrWfq+wcZiEaXGJfB0AEnkfFbksVOUNpgx3W4DADkoH/SjFp3999kchNJoiDE+csSpfXnvvsTcdJuFIoCenRNK0V5gG9K8z9uSRpVYkvS9iBDlm68b+k3z267qySIjpj7oQyWWWnow7UH2OI/PNE5+j0laCkpKxfSOaXKTTqLOGVFOnmrvRgM1ot2T9ZjU2VoZEiX3E+Y7EpbIwgMTviEd0ZdDJ7KN9f7o+8uybhxSv185N1PBzpX3S+OQv86jT8COKlD9RRQ4VArPlm7tQPYvgel4W0uHglgtqD6yU3+7ao9+hFn2mn3h24biu/ktseCVd4wDK2cmuYgcRK2hSjR51Wvh+tffyQ0CUcbLk1knk1YNVXFEanhr/5ASJgiQ2TIAdb5whg+Xlhy2zsUCnvGKvWrxaYSYDyTWFI4oP54yEt2U6679h3cJiVKFYleqoxi/hQAtdOAeWhCHR9PY5hCZH+Bw3b1A8XtU4GSmyGEdbMpjJh90HMfxkdSeJV5p70pl8Aga+FltUy/F11C5Ag7USIx8mP6x7Rmwc+uC jC3rdsxq RBt+50bHMLnDV+ZaY46V8n73/UcK4kD5pNQOMTLcIDlp3s5SukQ/Z/2cgwumsZ17sr7zPvCihk3CvzdwQ4KZGBr7HIn/VNrB+QfTLupg6ZYzlAbUlS8lBFgdmKJacucxDPedSs/VD7/QwB4ryfZt5Rc1V9EdhUnNz9Nl7J0KJVasfjZA8aqnFEEcLy1chJyD579/KbZZ/9bVWp/RLR1nNVyTJ4W7ldBMQHJLt 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: There's no need to split this function across hugetlb.c and memory-failure.c now that hugetlb_lock is visible outside hugetlb.c (since 2012). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/hugetlb.h | 8 -------- include/linux/mm.h | 8 -------- mm/hugetlb.c | 11 ----------- mm/memory-failure.c | 8 ++++++-- 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index c1d23ab53752..89f4b90eec68 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -165,8 +165,6 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end, bool isolate_hugetlb(struct folio *folio, struct list_head *list); struct folio *hugetlb_pfn_folio(unsigned long pfn); 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); void folio_putback_active_hugetlb(struct folio *folio); void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason); void hugetlb_fix_reserve_counts(struct inode *inode); @@ -452,12 +450,6 @@ static inline int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, return 0; } -static inline int get_huge_page_for_hwpoison(unsigned long pfn, int flags, - bool *migratable_cleared) -{ - return 0; -} - static inline void folio_putback_active_hugetlb(struct folio *folio) { } diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7..cfbf2bbc6200 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3978,8 +3978,6 @@ extern int soft_offline_page(unsigned long pfn, int flags); */ extern const struct attribute_group memory_failure_attr_group; extern void memory_failure_queue(unsigned long pfn, int flags); -extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, - bool *migratable_cleared); void num_poisoned_pages_inc(unsigned long pfn); void num_poisoned_pages_sub(unsigned long pfn, long i); struct task_struct *task_early_kill(struct task_struct *tsk, int force_early); @@ -3988,12 +3986,6 @@ static inline void memory_failure_queue(unsigned long pfn, int flags) { } -static inline int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, - bool *migratable_cleared) -{ - return 0; -} - static inline void num_poisoned_pages_inc(unsigned long pfn) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0895debc36f3..2e6ebedb75a8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7674,17 +7674,6 @@ int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison return ret; } -int get_huge_page_for_hwpoison(unsigned long pfn, int flags, - bool *migratable_cleared) -{ - int ret; - - spin_lock_irq(&hugetlb_lock); - ret = __get_huge_page_for_hwpoison(pfn, flags, migratable_cleared); - spin_unlock_irq(&hugetlb_lock); - return ret; -} - void folio_putback_active_hugetlb(struct folio *folio) { spin_lock_irq(&hugetlb_lock); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e42d0cd7888d..fe9d2a0cb962 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1984,13 +1984,15 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio) * -EBUSY - the hugepage is busy (try to retry) * -EHWPOISON - the hugepage is already hwpoisoned */ -int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, +static int get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared) { struct folio *folio; int ret = 2; /* fallback to normal page handling */ bool count_increased = false; + spin_lock_irq(&hugetlb_lock); + folio = hwpoison_pfn_folio(pfn); if (!folio) goto out; @@ -2024,10 +2026,12 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, *migratable_cleared = true; } - return ret; + goto unlock; out: if (count_increased) folio_put(folio); +unlock: + spin_unlock_irq(&hugetlb_lock); return ret; }