From patchwork Thu Feb 29 21:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13577664 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 71C1FC54798 for ; Thu, 29 Feb 2024 21:21:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 042076B009C; Thu, 29 Feb 2024 16:21:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6EE26B009D; Thu, 29 Feb 2024 16:21:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0EDD6B009E; Thu, 29 Feb 2024 16:21:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C382B6B009C for ; Thu, 29 Feb 2024 16:21:00 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 97A16141285 for ; Thu, 29 Feb 2024 21:21:00 +0000 (UTC) X-FDA: 81846111480.15.6089642 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id E47001A001B for ; Thu, 29 Feb 2024 21:20:58 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uGoFEluU; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709241659; 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=vw3wE6Ne/OUfTw5/V3p5xx1+DBqftImM3ID9MVhOemc=; b=Wd5ZIsQ/1VGa6vcaaQtsmfDjro2S87P91iv7SNVYmWq+ds2M2t6JzllDq+uzh2HmH38gZl LA2GWWfCD8PA/6GUyNDAn2sek9Rl6blaaWyA4I05eiz8ehL1WwAbj/yFGjuRTywgc5uEjQ lpUVfNaxdNjDK6ATxkB9WNliHRlZN70= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709241659; a=rsa-sha256; cv=none; b=lQ/rQfMp82fEPu8F9sdvCg3ujlwRxRpZsM1dWVPcUsujUHsT6s3a7tzjI+77wHQazgJf2z cJ7p8sMEEu/Q6XzETIF+wQKiH6UUxvzwL4TZ6GT/b3WQ6kXzBPf/k6NacPdzcOWiPKFaWF 2sRHaU0NElZB1O5/L/aaZ6JP4Rszk0Q= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uGoFEluU; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=vw3wE6Ne/OUfTw5/V3p5xx1+DBqftImM3ID9MVhOemc=; b=uGoFEluUN9J5VmgILrdjzISqg0 p88xenlnW0ppgVT66V3aUIRcBzy2iHxSI+LwkFP1IN8YFhTAhvmkCTfD0iRjPbhn/KPQRmDJtTi78 4fkuGmU1gtYudh+i66vR5KWpooaSd72VlhcL+1K/HeSGJIWPX3RO5OqCI+g2Fw65ndVVMzBfdFjdR /mA9H6WbW1DF+CC72g9JnwaUN/wMU7D/aBgxKO/uLRvwJP/sQIM5755nI0AJpN6iMnU8thR9fPUfh wCZj285bEoipEcM80uTMl2wRsI53HPkAgy+I5kTpGZsnuhj46H1p3Yswj+edO+8a/6pHqTnQVQtCI NELqTp0Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfnpV-0000000949c-3M0v; Thu, 29 Feb 2024 21:20:37 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Miaohe Lin , Naoya Horiguchi Subject: [PATCH 4/8] mm/memory-failure: Convert shake_page() to shake_folio() Date: Thu, 29 Feb 2024 21:20:30 +0000 Message-ID: <20240229212036.2160900-5-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229212036.2160900-1-willy@infradead.org> References: <20240229212036.2160900-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E47001A001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: wipsshiygyfhnna3qwwipp14yymi183y X-HE-Tag: 1709241658-719332 X-HE-Meta: U2FsdGVkX1+8CB1kjQBIJwaAv4AVHHAm2co9bpgNeei2A35ppk9ISce7FTKCfjcMTbW/n5HuwP75Ng3YC22gglKlqnbhIgOHI4PeMv0CkJPfT+NGZNRaHyexoqvfzuwVLtxJA6SFIWCvbYTXCUFgBKwg7UdesxQMBm/J8gHMvocqpeOWcmZJ5ny9B2d2Bpmuq29pLs9T+I7LCv12Yy+IQsO8uwpCYPxokj0IAZZfWG36nCHCxMN98TQ/2B24fSd271AWZ36r/UflrunQmLjovMdUxvjF9ke1Oo8pKclRaj0dUa3p1wIuwTY0rxr0tAYyXC1Rl6LwMQhXYweuGz4vHuygwhf2Ds20gBTxUrqqEhihJ6H96V2iCgSXN1+iowpAACDmJQuduyBTaBaxLtvssJpgj2uvoVRMShelvQJpRPFYhlPtT4pWFJ/ZOwoBWntognZLURN9JOJuDgZbJNOItxR1e5UGY1YdDc4bWbkvnf3sdrEg29/ZvdFcLCoFaqhPwCIY3q4dB1B7+w/FqkSs/YrYVgcTv5buvEtsHeiHlE9w3A8aVqBRelg0C1MMFSEbS4itS+UFALgZabbi8NQCj7WrIaBi8uY+l00eK+grNNK2QQaYNp5WZ7OunzaVtyVgft0fESi5He6zhQRBMCprA4NYr/zciPzku4z9WurqXUx4bqFZwmhcwgdlkzeHSmcic75jopUdCkfEpb/rd0Hxsmib5tWZxw7XUrzl3AT4f3v6l5+q4F2+9D1/OEAn5qlfVTRi74jvbLC5USINyUy5s/Cl2kdDaAFq3y2FmxeMV2j3VO7fv/+6TwuTR28PiWGjrQzNbeAX+qykDQ4EWtj9VA9Ml8wmaLFKcIYaD7wP97Ue5MJ5tICuaN5J6XCnzDAEI5ujM2TofcdJzgqZ0wK8ETttIaf+1t4YsMXcHFm4X5GR+aoQBRcETXArVSkRojvYFxBJcnHivapVceODIyg D57kKvrl NBLgKAxjZ6tHrG8OWl6m9zj/PzEH7eUArZeE7uQkDX347NGBS83aWxT3fEoZhEcare9cKTJoRyH/lHqOvYDF6iZDLWeYFH0AXvmQR3SMLxY1UG8MDGBs7Lqe1rgBsVNKraTkAsqCsQhRiOjchymPbASJvuWlTuoBs/AldGH4L+d850GzJKDQsleF6U4r4Cwl1qtzS7unh2qL/rBzzNT6KErpL0Osz+v5q98Ii 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) --- 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 03e4841673d7..184f57cdab60 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3962,7 +3962,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 13f4d6ccccdf..b900730f43c0 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -855,6 +855,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 40a8964954e5..27dc21063552 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -358,20 +358,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) @@ -1639,7 +1644,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