From patchwork Fri Apr 12 19:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628293 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 85F2AC04FF9 for ; Fri, 12 Apr 2024 19:51:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 035D66B0093; Fri, 12 Apr 2024 15:51:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F28346B0095; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEF1C6B0096; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C45EA6B0093 for ; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09BEF160FCD for ; Fri, 12 Apr 2024 19:51:48 +0000 (UTC) X-FDA: 82001925096.06.31D6B7B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 75023A0002 for ; Fri, 12 Apr 2024 19:51:46 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="S/miWtBW"; dmarc=none; spf=none (imf25.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=1712951506; 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=8Ln0/nXireti6Gj7qeC9fC25WVtajNsvaFQsbqX+KPU=; b=etj32qQ2KA8U3fkzzmLBlxJVrpUNwLsdL/N0XXwuLGM2L5NPITfmq1nu+C/96yLGYup3eS 59fIkS39jSjJDR9ZmxqtelgP05x99aTJ0LfyZhuKbG0mj6blLhDuWqZT+6mbvdTCLZ1QIx YWp/sNW9tyE980eGUwoFJafpBrCD+wE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="S/miWtBW"; dmarc=none; spf=none (imf25.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=1712951506; a=rsa-sha256; cv=none; b=CVgB9HR8oRhrm5ZC9QCzU1fibI25pCtBQwH4RYD8WtobloJitGa4oVCa6PD6DjgSBep7Nw lKzxcqZ9bo92emFOBfXptgECZa2K7PjNkNesvq7FQSsa+6f0GRQrpIaEkqisxfm3uvZLmU XgXV+cWI0xVsjgiBY+jxYychdyHugQ4= 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=8Ln0/nXireti6Gj7qeC9fC25WVtajNsvaFQsbqX+KPU=; b=S/miWtBWeWh9FzevUmvg8wVUJw viOKqiV+uq0WzXu++HL8bLQ5Eq+sX35qPxa4ncRm03v28+vj/ABCjL7e1SYN8Q3lbduKRQyD6cGKm 9JesGhr17Hn/ZBwv9Pw8YvzQSD12dR1gOXk3cjVL6dMrJuqOeEugSn/DXvE7lCdxiTO5jI76UNGAb kvc1ygXfLOJIM56oMOZ0wurs7SVBA2pFV6SpYvEbqUm4wHBuVZjecPbw++drYnF9S7/yydMviU6K/ tDaZceK36V+MoJUmnLHMtTYEzcm81CuShS52qrdB6/MT04Iout3w7cQhJV4VQ4H0iU80z1bc5u4iC 7BnQoCkA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9m-3s05; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 05/11] mm/memory-failure: Convert shake_page() to shake_folio() Date: Fri, 12 Apr 2024 20:35:02 +0100 Message-ID: <20240412193510.2356957-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: jwfnj4juic7bt36ndbqf3ocwreg3yktu X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 75023A0002 X-HE-Tag: 1712951506-134691 X-HE-Meta: U2FsdGVkX18X1ww0ObS/f5YGtnUxhcW32dM0cEFkMiEgfAJiczQnfqI1u1lUn8C1Fw3NuLZV7aIrWxdpQ/Y8onzYbmxYWnkweiCn4oPGb06GW2WSYgLVuyqI15VXvpD1DDmJFVe2eIUjpTsIrTx+K6m0gzjg1ETZm4eb65p/gx8VqealYRvofCAvFSzt5q0rXW6bxbPpLXumGD6d13EwpCB7jbSFz3Ku4C0vYLLxQhbJIdv9Px+vcXWUw6VaUHryU3LeFjxtuyIb3EGIyxdE2RnUMriyYQ1x+PfWIe2GrvGgwqKc2MciBMAHjCG57tYl5JNRGTFeZrC84M5LlF3sGK4cYbTkx+9xq8a7iCEbiQn+j7lKwbnRflJYfDggHiP/mhd8yakHf3LiLBvah76cJXCGQWl3uen5tjWErLCKa2LUkSvr+RgaumPQW3pgRsVKYKfzoE5/EfOeZ7mEnG7nlrCYM53SofW6BLudHJASthC8Lm6vH9jq7OxXBvXBg1/q8Ocb+Lmab2KiXvFO0OBNzsNZtFi077fPgQbskEu1JpV5M3p+crJbTHUC9XD21FAocwSEmsc0eGhq05evCWwCwFKIcW3+MV50QhyDO6d2pv+Tyb0UY/RYRE7Kw70RxBi7jM1TY9+YR3z8u8vkGsS+Ehfys1gGe1Kp9LrwcE+qNcdO4cQ4s0z94jWCZNU56DzkSXRgPSpiiDZOjWCk9FwpnEpWKxnW5VhRn6IaFa0Rt7dP9c2Ttdxoe9FSvfCKBK4Qt+Kl392rfD3ZWA9Wh4REIbsTDom2vbAOcvjQXqmCn4pjGXa+Ky+0K8TdUfbOyAqPaJ2q2TKVCVKek3o0q7jojh02kwWR4F6sgDFYiUED3d3Ai5/MPn6JR7QEKaYGLWFQiN464lONAMBgwIp2Kj6Ffgazv2K/HQY2qVNDBGQKPFLWnIUMc6A8MVsZMGMAFwHWAq767P+YzKWszHAwZFD alh56R+j 30YEdAD9DclreHoG/FfUwrgmjosWDWqtvnZ8xaZX63JTSo8u4NojvawPU16TWRGabJKdVaJkjGKaJNPXJP9qD8HvVkWYCAk1DHvXaHrto9TqwvXazoo48+QlJUxWp/+I14AZP5ETTw8BPfzwFM+vzAZRvk2/9mou5BOM6yQb/G4eHso/Ce1c01QdAocxQzoEd05asdDBbRJ+OjGoYreg3hJQAnwpzVGaXYezJaClmBrNhDA4NQSFCvSMZXzOcCXMXAsDG 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: Removes two calls to compound_head(). Move the prototype to internal.h; we definitely don't want code outside mm using it. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu Acked-by: Miaohe Lin --- include/linux/mm.h | 1 - mm/hwpoison-inject.c | 11 ++++++----- mm/internal.h | 1 + mm/memory-failure.c | 15 ++++++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 326a4ce0cff8..b636504c176e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4028,7 +4028,6 @@ int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -extern void shake_page(struct page *p); extern atomic_long_t num_poisoned_pages __read_mostly; extern int soft_offline_page(unsigned long pfn, int flags); #ifdef CONFIG_MEMORY_FAILURE diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index d0548e382b6b..c9d653f51e45 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c @@ -15,7 +15,7 @@ static int hwpoison_inject(void *data, u64 val) { unsigned long pfn = val; struct page *p; - struct page *hpage; + struct folio *folio; int err; if (!capable(CAP_SYS_ADMIN)) @@ -25,16 +25,17 @@ static int hwpoison_inject(void *data, u64 val) return -ENXIO; p = pfn_to_page(pfn); - hpage = compound_head(p); + folio = page_folio(p); if (!hwpoison_filter_enable) goto inject; - shake_page(hpage); + shake_folio(folio); /* * This implies unable to support non-LRU pages except free page. */ - if (!PageLRU(hpage) && !PageHuge(p) && !is_free_buddy_page(p)) + if (!folio_test_lru(folio) && !folio_test_hugetlb(folio) && + !is_free_buddy_page(p)) return 0; /* @@ -42,7 +43,7 @@ static int hwpoison_inject(void *data, u64 val) * the targeted owner (or on a free page). * memory_failure() will redo the check reliably inside page lock. */ - err = hwpoison_filter(hpage); + err = hwpoison_filter(&folio->page); if (err) return 0; diff --git a/mm/internal.h b/mm/internal.h index ab8fcdeaf6eb..b20c736e05f2 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1044,6 +1044,7 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask) /* * mm/memory-failure.c */ +void shake_folio(struct folio *folio); extern int hwpoison_filter(struct page *p); extern u32 hwpoison_filter_dev_major; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0ad6b8936512..bf9da2b46426 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -363,20 +363,25 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags) * Unknown page type encountered. Try to check whether it can turn PageLRU by * lru_add_drain_all. */ -void shake_page(struct page *p) +void shake_folio(struct folio *folio) { - if (PageHuge(p)) + if (folio_test_hugetlb(folio)) return; /* * TODO: Could shrink slab caches here if a lightweight range-based * shrinker will be available. */ - if (PageSlab(p)) + if (folio_test_slab(folio)) return; lru_add_drain_all(); } -EXPORT_SYMBOL_GPL(shake_page); +EXPORT_SYMBOL_GPL(shake_folio); + +static void shake_page(struct page *page) +{ + shake_folio(page_folio(page)); +} static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, unsigned long address) @@ -1633,7 +1638,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * shake_page() again to ensure that it's flushed. */ if (mlocked) - shake_page(hpage); + shake_folio(folio); /* * Now that the dirty bit has been propagated to the