From patchwork Mon Apr 8 19:42:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621544 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 BA4EFCD1292 for ; Mon, 8 Apr 2024 19:42:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57F676B0087; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52F5E6B0088; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41E486B0089; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) 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 269CD6B0088 for ; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A4DB380139 for ; Mon, 8 Apr 2024 19:42:40 +0000 (UTC) X-FDA: 81987386880.26.05E55AD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 6377E2001A for ; Mon, 8 Apr 2024 19:42:37 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OQ21bnsu; dmarc=none; spf=none (imf13.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=1712605359; a=rsa-sha256; cv=none; b=acRDw5jZElwFtB4LqjjX11TB4H9WNfLV/IjaNVdSmPap3lmpZg35vrVclf+hFgDJ3EveIK VjIvs5UbVgHoAsoc0srRu0wYHnRorvstRNiytaoOx6DBJrzPbXeaWLYuJXde1vPg0gvOwV He11diKDTCEx2xmpfsX71ynQKR4221A= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OQ21bnsu; dmarc=none; spf=none (imf13.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=1712605359; 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=haoysfp0GSvdrFQlRHJYcSBmjTQbWyy8YmB+jXq7oTQ=; b=F4DQF7JLOmeNTMUivrAanSDztSQZMe4tUkHLCL21dUU83ltSu7NzSATaUCVoFUBQ3ZxRkX lJu8WQEG/nTLAxIBl1PjylGb9deP1Gj3kjYLMBxBEKYkG3xur89Pk9kvofM6+eWAxJKTrn DTXotJ5yJpBbgSc1XiIFi9uAL2jmNe0= 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=haoysfp0GSvdrFQlRHJYcSBmjTQbWyy8YmB+jXq7oTQ=; b=OQ21bnsu3Z/b7L+kCvhh2mGroN MILMBNMlU0muHiRb1sctJJiNBHncuZrRVDwnYgUBtDNRkSPOlw9kbKjYNSkHOJ4VXSswgM9SVM1WO K+HEyQfPTp2VGGD7fSwjXsxrDWP2piJBrG8q8HGmF4gtLxKq6WvB3Er1d29gXIfag0mNPa/1JXkV6 aJ95gFFqML3j7KRY2/FqeNTQ0lIO/fqpUHyWcTMMsoh2dK77KCtnUOzfqhsPLTjWwWgN1eBcv/fV4 gsJ7HNl9JB6aR5x1HqxQtv3s+WtjixKJFbaP+FmyF7ZU2kRLEqO61NwS6OfQC5tdQ2C6OdF99YQtz eLXXlIcA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut0-00000000Uq9-36n4; Mon, 08 Apr 2024 19:42:34 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu , Dan Williams Subject: [PATCH v2 01/11] mm/memory-failure: Remove fsdax_pgoff argument from __add_to_kill Date: Mon, 8 Apr 2024 20:42:19 +0100 Message-ID: <20240408194232.118537-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6377E2001A X-Stat-Signature: bojn3ojz8ommdmx6iyfhyejhog6grdix X-HE-Tag: 1712605357-676624 X-HE-Meta: U2FsdGVkX19Tjd293yF58ml2fWK92nNE711UOmOofduFkL4SwNCn6xBCvXTfPQgZ9XSUK6Ba9r2gx7NwpLqjuE1iJnJz5UDHcNeJMqLhZGBh/YHEkCe3oEv0X7RL1jjGoCKPsdjC/SYM6M2z6GXEvyFWG2kZ9fSbUZx6m+vqZ9OV6KCfNg8TSih0m0/63pKRkwMmxGo2RZNIOX7BdhEfcoSrqFsV8gq5vE5jJ9ZdQJ7Hwq05ryE0An1QHnEoqdYn3Z77Knnj2FbnEkaUT9nFewpYBeefH260bQovuB21rBXn3KhBRf8gO/mUQxP64hfLnZkD28CxhSxAVOhV8HtNXa/uwaGfmhr+OgNyoh+/b2EXuHm0miw0prSRGl31H2jSg7THBTC7Xe3L8V308uWEZQwLnE7yV4VPQ8Lozk35CH2C9MRpp1bChH1uRmT/EqPQ4BMt2NSE7XehB6hqBZX2yg/PXkZ9S0SvKL3xATuKIbWpKr5XMuixMh+q3aqNiGg9LJvywO9lJNu0HYD8CYvW54ISQyGC/aDLRgju8PGCOaFqfBLG/2yI4Iha+hQ1JrDGI+w6uP9oCQThKsR2D3SWEKpl+6EzdeBihB8Hh5zqWDwolQhUtZnUS4Ol9gL3kzUlMaOz8oWHX7vgvzdX+6JeLYqjz+pDUBEPVaevaiGp8HhKLSUHIi4Gqwvk5mSH2l9kBguecaKD0NBMmtdp/MSWMevXD1agORlo9rKuBISX7VjcMcCY5ua81lh/gKgduX78u6QJlkadyuUEZ+gWqqYCrZX84c4WgAtePhwcuEnsumnZWgZWdEkDG2irMPIkupMq4DtlqqLTV0UPqlN6AYBgE11QDJZ4edssMV01QQvPwT8ZPAfnws46vDmK5tO49iMOeI6wSlrIkM+dtcMmRFW3ES0vW+1uOPPdSWKzzgrmciqd2zrfe215AzM/hMnqeGzBwdzNLHG73PqLJ/cpy4u vCS6pMU4 teh7t4b2blR+p50NQtV0LnGbuVWK5uJxByXFAymWQ+fPaAxYukB35I5SYhOip/WQ5MJbBSxMwkbeO7QZvGqTxBbJ6W602PWDcgd7T/18cyKSRz2y7TfspTIDG/g89m3HWq+PGCskFYb3E+wjU+JSuqI4CobCSzf8FICHszkrQZ7kBMs2uPC2jd/havPhA857Ck+iqlXNGPd1/fd8GnPZ5NHAIxoawgTI/Z8i9WDCwl8fKuZchqkhC2ZuTtrhpc5gRAEuML5QUhXo/Ed3ZVH55rMMy/6BktAKkbG2OKpy70UnnddI= 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: Unify the KSM and DAX codepaths by calculating the addr in add_to_kill_fsdax() instead of telling __add_to_kill() to calculate it. Acked-by: Miaohe Lin Reviewed-by: Jane Chu Reviewed-by: Dan Williams Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Oscar Salvador --- mm/memory-failure.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index edd6e114462f..34b3c8255c9b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -415,21 +415,13 @@ static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, * not much we can do. We just print a message and ignore otherwise. */ -#define FSDAX_INVALID_PGOFF ULONG_MAX - /* * Schedule a process for later kill. * Uses GFP_ATOMIC allocations to avoid potential recursions in the VM. - * - * Note: @fsdax_pgoff is used only when @p is a fsdax page and a - * filesystem with a memory failure handler has claimed the - * memory_failure event. In all other cases, page->index and - * page->mapping are sufficient for mapping the page back to its - * corresponding user virtual address. */ static void __add_to_kill(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill, - unsigned long ksm_addr, pgoff_t fsdax_pgoff) + unsigned long addr) { struct to_kill *tk; @@ -439,12 +431,10 @@ static void __add_to_kill(struct task_struct *tsk, struct page *p, return; } - tk->addr = ksm_addr ? ksm_addr : page_address_in_vma(p, vma); - if (is_zone_device_page(p)) { - if (fsdax_pgoff != FSDAX_INVALID_PGOFF) - tk->addr = vma_address(vma, fsdax_pgoff, 1); + tk->addr = addr ? addr : page_address_in_vma(p, vma); + if (is_zone_device_page(p)) tk->size_shift = dev_pagemap_mapping_shift(vma, tk->addr); - } else + else tk->size_shift = page_shift(compound_head(p)); /* @@ -474,7 +464,7 @@ static void add_to_kill_anon_file(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill) { - __add_to_kill(tsk, p, vma, to_kill, 0, FSDAX_INVALID_PGOFF); + __add_to_kill(tsk, p, vma, to_kill, 0); } #ifdef CONFIG_KSM @@ -492,10 +482,10 @@ static bool task_in_to_kill_list(struct list_head *to_kill, } void add_to_kill_ksm(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill, - unsigned long ksm_addr) + unsigned long addr) { if (!task_in_to_kill_list(to_kill, tsk)) - __add_to_kill(tsk, p, vma, to_kill, ksm_addr, FSDAX_INVALID_PGOFF); + __add_to_kill(tsk, p, vma, to_kill, addr); } #endif /* @@ -669,7 +659,8 @@ static void add_to_kill_fsdax(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill, pgoff_t pgoff) { - __add_to_kill(tsk, p, vma, to_kill, 0, pgoff); + unsigned long addr = vma_address(vma, pgoff, 1); + __add_to_kill(tsk, p, vma, to_kill, addr); } /* From patchwork Mon Apr 8 19:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621554 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 000DDC67861 for ; Mon, 8 Apr 2024 19:43:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F7966B0099; Mon, 8 Apr 2024 15:43:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 559056B009A; Mon, 8 Apr 2024 15:43:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F91F6B009B; Mon, 8 Apr 2024 15:43:06 -0400 (EDT) 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 241096B0099 for ; Mon, 8 Apr 2024 15:43:06 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AE95BC015F for ; Mon, 8 Apr 2024 19:43:05 +0000 (UTC) X-FDA: 81987387930.06.98982F8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 0466E1C000A for ; Mon, 8 Apr 2024 19:43:03 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=V40hQZPc; dmarc=none; spf=none (imf21.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=1712605384; 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=8E7MsubpwK1pNCAdhISMwGNo4szPO+ok4gT94i6Vc88=; b=s/aNxHC3RJ+EQVP1VXF81SZ4ZbAdOjZ1fWs3AZdv/zgv6ZnP+6kW+EuopBBp2dZ7uFbnTJ w/3JJqPo4npQeV/zfXEK3SrsHwZcmeHpEVDCAhj4pvs7JyqlLYA4ApvuEZuORdBMNeUcHk /dL45Ju+tCuq4SwWAIK614MyAt5YRKg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=V40hQZPc; dmarc=none; spf=none (imf21.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=1712605384; a=rsa-sha256; cv=none; b=G3F4c9sVpnFAopVkWofBU/n3TYN0Wl+yYP2Duv6FUbfT407kjZ12K5u6+PVbKdOBK5FYdd u2jphu3FduvQAHlcWExoQP0EB/lW23ccGdb126vewsMPD7jzFDt9eCUQj7U7xMkHnV1S8m uCFOHrkeADRUVHGs40dCNCSFacnR0r4= 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=8E7MsubpwK1pNCAdhISMwGNo4szPO+ok4gT94i6Vc88=; b=V40hQZPcrc6tgfB3XlUFhKvAZ8 VuYKS1A0PIMO25yNo+E2aXBGQqmBSvmDuwuCt3X0+C/zDCNcBwKmFp46cmtBxRV6cuq4HOyqOhvvk txy4tBqSy1ySbDnR/FcNXSg4/cHVg38LE/okJfeXFxkW6rFaqsakyCzdTNimBTq3eb+YpnebYADO5 AuoL85IaOArQxU3zbhFS9k2DvwnUNu8WlDy7J4wz23efelg5shMkSw2SgZn34hE1LY5wMbVWHmqzI PbProQJU8pWtoeREhb0QV/LMsP4v0sEbFgVhTyZDqJezmAqMf1WvCSt6zIX6LE4XV9seEv0UQWzFL /GT1dmFw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut0-00000000UqB-3Qyu; Mon, 08 Apr 2024 19:42:34 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Longlong Xia Subject: [PATCH v2 02/11] mm/memory-failure: Pass addr to __add_to_kill() Date: Mon, 8 Apr 2024 20:42:20 +0100 Message-ID: <20240408194232.118537-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: dbcu6f9twpro95j65tmqke9c355i7eu3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0466E1C000A X-HE-Tag: 1712605383-272846 X-HE-Meta: U2FsdGVkX1/Iq6piA8SytrvEJ3fpTQezjRTINH89oauXsnNZwpSkNdFIq9GJhXpp0IXT1xFc/nc1HpvEDhrm9Ayel3Ame2llnHIaIEyDjaP5qbobCfwihrZASsBOzSyS/8ee20KGbpoKEhICPls4DrBXnvIGwYTOf38OZXHABI8nmvCwEs5c/DW6jjDi1ejN/QR+j0JHIdJjSlGzUhQoLzkz7yxW/8wWZRkchaDicWyBtOpmp8yLSMoDjvtiBzNspsMtL2xhtDwPKEDBex0ueKvcpZJzZeG0Bb+gLdrkgb4LtDMMKkKPoKTWM3fKprv2R6x1gjmHvvoNSpCJyaHLKUxFrf13NthaQmTMriQcUDDvWt6BN+kjDgIznc8L7cxhIANUP1+BfENgqo9QWPbLuS+Wm+CIb3hTy3o+lUt/+KszChM3tiCL47HRXLq1ZvW9rW6+RTxJV5K6Ss8KzugW+SrDwY7K8x2H+P5vrxc31PJiqbVxDJUEOuBzA3Dp4tpfVKPek6IlhICGnWZ3Rso3coK6Img6ae1C9fWn/L1oDrApRPdou54r/hs5YQwVVMTtBR8W14PdRC5m17clGv0SrzKFSpIt7jYraWQDdrEEOvnwov6661QV9ynb4dLZyTSCxiu1czccdBedhYKFRwnHX4bGPlRzspAV/HBMjRSCpDVaGDdGRBz79jXZlPOuwhsR0F43G+Eq2eMS5w8SdE5z2NjjaIlELuVpacaKeou8LwywTArtKoYtkFPwXWFFVx6aSsXFzDRSwC6d/DzaPbB2lxVvLrS1WLEq8O1vq9MuDEYECRMyQTIbyiCbiMuP1ppAbFwHqgWCNtVPxqvZU9I0kyY0ddN1X+Ek12Nd4gSuidLkEcakUVDdNyUu6wyDLGoCsG5yPNMyfA2n8aKqfQB+ohy9vUGOXwcgVy/GAUF162kUSmMoRWvFTciHsoiLr8VpSZhy3jnlNt1KZkXx1OF 6wMTx+lW cWJXSEU4EQHk8atEFscPr2jsa+U/5bglRxuXraH6+6ab8JMp0GmElKhcv18ERJ5lQcmCbXFqm0chOmbaJu2zlpiP4wClxXWAU1HOhiu97tspqZVSW2togSaybvoVjCL2f3VeIFP3/dfqNiCIVTA7w5dJEU2BcyY19DRvo1eO9NFrwMN7p3SkssxseCivnkxFTEgAHCKCdKqQlQain3cyMCvRk+iD+X0V6jLtHgIwCTDEigDaN/SVcw50JWw== 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: Handle anon/file folios the same way as KSM & DAX folios by passing in the address. Cc: Longlong Xia Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu Reviewed-by: Oscar Salvador --- mm/memory-failure.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 34b3c8255c9b..f94d85075ec1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -431,7 +431,7 @@ static void __add_to_kill(struct task_struct *tsk, struct page *p, return; } - tk->addr = addr ? addr : page_address_in_vma(p, vma); + tk->addr = addr; if (is_zone_device_page(p)) tk->size_shift = dev_pagemap_mapping_shift(vma, tk->addr); else @@ -464,7 +464,8 @@ static void add_to_kill_anon_file(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill) { - __add_to_kill(tsk, p, vma, to_kill, 0); + unsigned long addr = page_address_in_vma(p, vma); + __add_to_kill(tsk, p, vma, to_kill, addr); } #ifdef CONFIG_KSM @@ -480,6 +481,7 @@ static bool task_in_to_kill_list(struct list_head *to_kill, return false; } + void add_to_kill_ksm(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill, unsigned long addr) From patchwork Mon Apr 8 19:42:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621552 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 D75CCC67861 for ; Mon, 8 Apr 2024 19:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2259B6B0096; Mon, 8 Apr 2024 15:43:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D5FE6B0098; Mon, 8 Apr 2024 15:43:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF6046B0099; Mon, 8 Apr 2024 15:42:59 -0400 (EDT) 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 D17006B0096 for ; Mon, 8 Apr 2024 15:42:59 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9E861120166 for ; Mon, 8 Apr 2024 19:42:59 +0000 (UTC) X-FDA: 81987387678.10.BD6D0DB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id F3B7140003 for ; Mon, 8 Apr 2024 19:42:57 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EnWMwjrx; dmarc=none; spf=none (imf07.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=1712605378; a=rsa-sha256; cv=none; b=C276D7HjTNnHOboR12iz3cp9RxymGgpLtXLb8c0DOCIw3BA/GA/vXmxUZj+MFM7ZWgTnoL seEUIXzbALFDfG+oT9NJH2pR/REA5AbdJnGvSBWc3IWIQadAVyvfgwvOYAJKSVziqOANnM QRO4OVGkGTotwPUdd9H2x2gtMBJHirM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EnWMwjrx; dmarc=none; spf=none (imf07.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=1712605378; 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=9xwOmtj5mTjwvmp+KNCpctqJtEXESdvMm2FbLUwq0nA=; b=JGA/Nr9brCe/HlP0Q7+dShrKSZGXRuylkO2IctDJFQbOIRe75Amp9qKFksm3iCcE/kBPAl DQn2hHvjOwmK7rwxBP0nzAkRCVmXK7ZzFENyNc3HF1HFeVHwSRw585vkTixaOEgwm9dr1p rHhhj071RgUsDR02vgS8JzcygqDjk7c= 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=9xwOmtj5mTjwvmp+KNCpctqJtEXESdvMm2FbLUwq0nA=; b=EnWMwjrxPTWEUO9T0K1wzTGkt4 3n+rAKuhsn4l5yMXJYS1rGSahA7rmcBAdnVYZKrdZHcA1tDKnPOvZ/s6LNScQe1wK9f5lv8XwdZye moP/T7e0PdPzyzKPbbSB/8RwOKNnQy54w0OpW1m4nph9wnGh83f2ItQc7ZQZArE7e+JgrJnVIWZRd IoBzDXV0MW2Wu6IVVuQ60yGjuNNE9gU95yqmxoO7UilLOtvRv4X7SpwHgGWhOfOvrvUkCyWYTbwX2 6TDExHv8fKem4fUlHT+zodtwBon7s6+z9v6Ned9S51go3b+3QbpryC07KjiVfmYIC8SJp4taZRh8Q t48+agXQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut0-00000000UqD-3k9I; Mon, 08 Apr 2024 19:42:34 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 03/11] mm: Return the address from page_mapped_in_vma() Date: Mon, 8 Apr 2024 20:42:21 +0100 Message-ID: <20240408194232.118537-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F3B7140003 X-Stat-Signature: 4mp76614fcy9j3kbr94rmfi387boz64y X-HE-Tag: 1712605377-530510 X-HE-Meta: U2FsdGVkX18ETT8Ur1SyzGpW3Kl8UYsBgJhfgknylFaKFPqTITeQZvN8+qnOQ8FdZKvBsE38d96dshF+K4IJ/k9X+hjj1Z6hsT0FfXTfOyHFlve12uD5vlC4/C0qj5jOtTQKlZiVJOXA6fZg2y/joaLzQ0NT4Y+kXMFDG/rR89dw5z58zINJLNEq2oX7HE3jNDaY7D1WyTMu4TA3fnzIq+hVaiq2OSB5IC+CKst2M72/RSwyVWMH1XNL6g0Kx/ArRQIzfgdhrn5xUvAMxtyKKz8G4Kl6Ibr5rtFW422/8pSDuLZxarvY4Bi/I49txE6hS9EAo4/KsqHMfNeh3JWM3LzBx7ebJHZTv15YxbPGVt8P7qgmuuL2Z4kCCzwMRE/MERJIe0vQoTpJxr3wF6uQLrugJsmRciWcdwl9GNSohSIxG/aCcDWZM/2vCKV/u6h+CNe8eTiP6DS3vyJUYAWd//HLw+q+Lvgk0eecRzP3QbZPzcvcoo5fmjecB6N8IFA1o2Fu60LR4uEVmW2ZYTc040hz/oM+ZSfXiTB0sdd1mM1avjCFDpGI9BjPwSubMPWRMMCvt33tnsf2Y4RR5LvdlKzV4yRzYTXwQ+bhUF/WacWltwPqr+3mB34g6/LRaUH6F7dNsk0uUHIytLKuTjtmTPlSkoqaj8wIFPc51sXCmiO/DaziLrdUdzRMfwduTnjObCDc+i8k2ieolnxWsl7ySx7hDWN9O+Zj6aHfORfS0z7+bpxbJfvFv2J54qH1XSJdUBsc02uSXdzu6Sii5DFSMemGPLPfPG+vpsn8sAFyzGlI769huXniLwNvd8I4JF70dgAfTmeALhhLz7mJpOsC7VEsm+eSc1JTBOG85YUGUEcZtY2U65z+7CHtghA0TlURRLZ8SKHj0MIX6w8m3BwOiR26fcVSaaR2kKsB4DlhLxFkyJKC2xSuL4Hh8sHuo5VTusV8HWNr6SVyVFoB6GG P8mLmOhx 30Cq7eza0+mMtIz7bNZYMsPp5bj6+hk7msBIWUheGw0hrrVwb8XDySe2UzEaQY0gWdAqAQ0879NcoyrPCDxaWhvocXWANrbSWN4MX5yV1FjBU4CjfCqyE14Gc18u7hn8AAeOb4fm/F+ObKY5GiWNo9J/ffA7qLqI/vDwSP+i7Y0yHkzllGWlBkSmLNoX7xmuEOqHrstnSsUUkyZNWDjEvCYS4+zQNlE21XuIoHyebniNxoOPW9YULiyvJgQ== 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: The only user of this function calls page_address_in_vma() immediately after page_mapped_in_vma() calculates it and uses it to return true/false. Return the address instead, allowing memory-failure to skip the call to page_address_in_vma(). Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- mm/page_vma_mapped.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 53b8868ede61..48bfc17934cd 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -319,9 +319,10 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) * @page: the page to test * @vma: the VMA to test * - * Returns 1 if the page is mapped into the page tables of the VMA, 0 - * if the page is not mapped into the page tables of this VMA. Only - * valid for normal file or anonymous VMAs. + * Return: The address the page is mapped at if the page is in the range + * covered by the VMA and present in the page table. If the page is + * outside the VMA or not present, returns -EFAULT. + * Only valid for normal file or anonymous VMAs. */ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) { @@ -336,9 +337,10 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) pvmw.address = vma_address(vma, pgoff, 1); if (pvmw.address == -EFAULT) - return 0; + goto out; if (!page_vma_mapped_walk(&pvmw)) - return 0; + return -EFAULT; page_vma_mapped_walk_done(&pvmw); - return 1; +out: + return pvmw.address; } From patchwork Mon Apr 8 19:42:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621549 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 8FF43CD1296 for ; Mon, 8 Apr 2024 19:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E39D6B0092; Mon, 8 Apr 2024 15:42:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 494266B0093; Mon, 8 Apr 2024 15:42:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 334BD6B0095; Mon, 8 Apr 2024 15:42:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0EA156B0092 for ; Mon, 8 Apr 2024 15:42:51 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C204F16015B for ; Mon, 8 Apr 2024 19:42:50 +0000 (UTC) X-FDA: 81987387300.09.0315A51 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 5B52040010 for ; Mon, 8 Apr 2024 19:42:49 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vXZoHYL3; dmarc=none; spf=none (imf17.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=1712605369; 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=r5awW3J/nYbjEFveiyyIQmrVEsasFG1Qhu6fbcLeBPU=; b=0y1JHvKuTO502ICdhcntOsdCblcu6NZxCdyLHPQRH4G+zJ66Y25EWxK+Ikyc/g0IxscjGw uNvjLGmtOg35FbRtFiSLIw0y/DzJIN+wBK0goxy+9W+s60vc380fla6QGJWwHcctt8i/3s 2vtt5Wo25xaJ0PzBMz4BWNi6QLKstfM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vXZoHYL3; dmarc=none; spf=none (imf17.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=1712605369; a=rsa-sha256; cv=none; b=oxwCpHRxZHDSEk/hRRYbrx/zkNVskh3GlD/1HMQTy4M/SvXRjjbEI8uQsPhO7KU+CQmcv3 0DFxxqdccoLg3ER7VcGNNctNsfCOPETESRBXyC5CGUFCRi6hPm5FMg7YU+slD8KJiMKbAM zCiHHcy2SHzneu88mTgFnmQj4zfiM60= 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=r5awW3J/nYbjEFveiyyIQmrVEsasFG1Qhu6fbcLeBPU=; b=vXZoHYL3wEYU5WmFjHMyLNmYN+ yqsWg23pxsx71mtiwK2vXPiF3g8CPdPLq6xn+iq6Rcc0DoeOjjJ+0lpeXe5QjBIjAmNU5V2KO5JOQ 5RnLIB2NrCMVTuO3H2kc9ckpACaVNh7EnuVyi/qS9w0U+BZsV46EmYLBqb64jUBjyDcAWPGFFykWW PF9jG5cTAoUJ5rLVtY4Eh8RUeVtdrsYXvkDqFjwI2CK3qVCwpoVSMmnU6+WGxXaCULrxzNjhcyXgZ Gl/7H2a3WyFQydg5VdY9JqBtz6xDCRSkAKDwwuOLuCAIt/qe7+E9awFegdSIB4WSFlrjF/kPraNrq yFaM4W9Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut0-00000000UqF-44MV; Mon, 08 Apr 2024 19:42:34 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 04/11] mm: Make page_mapped_in_vma conditional on CONFIG_MEMORY_FAILURE Date: Mon, 8 Apr 2024 20:42:22 +0100 Message-ID: <20240408194232.118537-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: whko7rs5wg6m6ajpisgorcs4ehdqb7uz X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5B52040010 X-HE-Tag: 1712605369-55511 X-HE-Meta: U2FsdGVkX1/c1Z05AgSVtJ0isQ1mI/oJXAiWG0bpYNlaBUMwFGwMJ9GXpPeDbiPN3OboJZ64B6iQYHkj8PlwPk2AwP+u5yFT+/9lQmG5K2Y2RCtukU6xQMDdCOyFS3Bs/ocekt8LQGIQB7oY4LlOryyMCvneCs5c+EYm1zhgRKjJYB2KnFkseJd1ZYctvIEVSJCW5Ymefp4gUWTvGTxPV1A+mUx9aYqU/1L/V8OVJaTcfR8mhP351N4kJdzqH6NnAUavgtjfApu4HW4FI1Uwd9Arb1t6SnYTsAH4QcXHybDxaVZj3EbD/jsHjEJRAkNJG+dA4SCi7RV6hfl9LOzQbF37EPXf2zTFpWb0vahzIDriIYu4/9PEdLKxnNCFDePwcOQecfVBX0sAoJYqO/lX0i8TebJyBTkMxxUTDPAnw2Mh/GybHd5jo8AyUf1AS3Z2cGux5rc8in0xtUI1cvEZucXBMEfG18jZi2l3hY63FnVgf9ZY5dvM1VdeyWAez6eNvS33xy91zqjCzmfL1QCWuz9OyZkp26gfcbXVzCOpFoO8e7QzMNwQHOUbz6hXBKNVfI+dJkFcgZ7WTx9prxeaHMxrBhXbFayyUEw9JCTN8FmKXLC4m74YXRGOkRw9zIAdWqwDA6EMH7SH3iO7GTu6f59z5bAUJfQXGhQ7og2v7ueWri2hgRxHqW1mbmv+qjUAjLgeu7wab3rtgcESlSDl6PqIILVDYonKJuKYwnXRbb/mDHjpjHtzTEhHSVO53oTN/ZOWKykGw3gILwUCRQr8xp2IGhzzxHqj9sm0tHMBveEuVX36r7y3xXsCKgGn3Ba7t8XP808oWP5t7XJJzD8GHxdG57hIHYsIvMhyiFmKocGxt/eM/PEakV3OvJCLIHldqWB41xDhM0xUvDF064OWfwbN/Q1Jwa4J 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: This function is only currently used by the memory-failure code, so we can omit it if we're not compiling in the memory-failure code. Suggested-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu Reviewed-by: Oscar Salvador --- mm/page_vma_mapped.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 48bfc17934cd..6e06267fc220 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -314,6 +314,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) return false; } +#ifdef CONFIG_MEMORY_FAILURE /** * page_mapped_in_vma - check whether a page is really mapped in a VMA * @page: the page to test @@ -344,3 +345,4 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) out: return pvmw.address; } +#endif From patchwork Mon Apr 8 19:42:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621548 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 080AACD129A for ; Mon, 8 Apr 2024 19:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C1B26B008C; Mon, 8 Apr 2024 15:42:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 272286B0092; Mon, 8 Apr 2024 15:42:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 113476B0093; Mon, 8 Apr 2024 15:42:48 -0400 (EDT) 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 E5CE36B008C for ; Mon, 8 Apr 2024 15:42:47 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AA6B3A0165 for ; Mon, 8 Apr 2024 19:42:47 +0000 (UTC) X-FDA: 81987387174.15.9981A09 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 1C05A140010 for ; Mon, 8 Apr 2024 19:42:45 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RPl8K5Dj; dmarc=none; spf=none (imf09.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=1712605366; 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=ShShQmCifgcEeWCeVoTkYxbmdXduM14Bv200zxi5ce8=; b=VsGszaIODMAv/duXnpWzbjluFvZAak+XRILegEXPmTshegblmrICUvd4iF6zibWiXG68Zt tkTXuMexQci2W6I6sjFyJk4nNtqCCoMJ/NcplcyJP0729Hd0ZVHCUql3/V6mpAt3qyDvt3 OP5yds2EBOqsYvSeHPtGRbo7+thUW8U= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RPl8K5Dj; dmarc=none; spf=none (imf09.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=1712605366; a=rsa-sha256; cv=none; b=u9603AnaS+F9fagbCprCrY7FmdpY7p/V1z0nK/VwrGjG1dOLE9XNb8TXw+jqBB9X6a+Q5O 3lwNxv2FEK7GKJ27sVECePpAbgc4rxxHGRzAGt5rF8mqs7Ur0PdlMle9+tf2LX3iRntb/s qSFihVTkphq453qVvAfrYTEO+eBcnAo= 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=ShShQmCifgcEeWCeVoTkYxbmdXduM14Bv200zxi5ce8=; b=RPl8K5DjbJ4g7Boc0D7wHNuksT +2Emyp+1H72B5PVgLh+OAwYW5mk5iqOyeZThX4oI7UfOTtV/62iJDA1xguglCd14GZICWHyDu3npK Dirv3kZvvKe4Yh2WTU3nlyOXsCjEs9bGnfERjPEVLFZ7FlSxoNUKp2UooORLBGaYhA2wdP8YjX64G s9z/galI+HtR87ACjjUf35CCNKluHrEiyfaOBxErLdN9u0qxyQvXugdp5TQ1B3IQzFbor/2OoCOQj sjXi/EonctGOC6eL3n3ON0Ypci+dGXwDc5egvJmmpgSa93Vk4h7aPlSsNPVqRzEYY082LjAker6sj LisBD6/Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqH-0Fay; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 05/11] mm/memory-failure: Convert shake_page() to shake_folio() Date: Mon, 8 Apr 2024 20:42:23 +0100 Message-ID: <20240408194232.118537-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1C05A140010 X-Stat-Signature: kzt6fnurhhd8dbhjmiqn977qm81t5mw9 X-HE-Tag: 1712605365-996083 X-HE-Meta: U2FsdGVkX18x/aii5PXjI17S/rH7WvV/B06xe09EEqIKGtXxoLw66C1gjrWvG8RB1tCBrvK/Z8X+DRdvGK+Jp71s0EqFRIjO0G8dSWfY9sj0bBK6W0lsn2Fz6OMvnCEh8+EelL5qcj6NrNIUEg32U40dTduZPDj1pzCSt62tTmVz1dt3vLT69/u1anrvMjc/JLMsM57zUQKXU8D6mxS10w46nu9pXBmJfNbBzw7lMxGW8GsUeN3+XMu8Kd9ezsJ6sxNRAhUSXKQQvE/bprglfW5TK5UdqUy/98z1tDebqZGicSNwtV+CLYuEQ7w5spaNu6aQ3dvNwkxOFaKKUohiTWLhdJ05xwwKLXtdWoP8mtBG5QFlnYZV9NzbrDeOuAmsYqC8RfU98yxi2nViaexs8UyY819oDeWeNC6hGdHeUfNziXK91xnhitsXSveQ4Yi686cXFOB+pUbo+DJrAHYWG3blRwnrYa4m8i6iQm2AFnwzoFPtNBLBaMU1lZQNfiPc7mAn+ezU7eRHvRDblW/evGIULngry8hrSpxhvsdltl9MvCKeDtZM0axZrCYIoPzem+XLNPALltl6VO/gYDSHAGz3gcHCj88GAK/yoP+p2N7dH1wydSxAO4+Nuy5GIjB7vKvyYheCcBpx0jKwAraRHVeqd70FqLLLg85lqlh8WVHe0isvRcnhAj7bXVl7Md4J85xPQAQjH0FQcYSASu2anPMwZPug7mepSpAp9969kBFcEWYRQXgjLdKLQLaI7ocWf5hlt4uLR7+LxHz1GcW69beo3/4GfBSbq0p55GxzXpjISjz1j1yuAWXYMoST+Za19KKn6tpyCzM3m/PqGwD3lvbb6aMgIZ58woFDLKDqkfX31yTbrtZDLfWp+XxdjnSEOP+sPHpOfzV6zP3+3/nsI/sypFoOAls2CUR5gNTvEGKw3Klh5jerT03FjGw2QN7trqm0SMatOYtUMPB9vBU Wfxlv9EH DDJmxQFyPkNVONb1e3g89Bb+B3I38oGiFkUV0r7KdCANQoiFtn+zASB/r7Ezv7sHGMtpddv136nopZ1ZzXYBviypKZ2jYT/F9xsLktag6RqLZO/UFKdWQHLRrtBFNdjbnSCEMOEXm+CkAfc83Xcwz91DDavOiI8LdK+LwP6fYMhJXaXhcrzjTym8zKEAzJ1DGjcoX5Q0zA7je7G4+7uaV20XmvDJoAV3VocsR 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 b9173e230804..19a67f45907b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4011,7 +4011,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 57c1055d5568..14cdc9ccb582 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1010,6 +1010,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 f94d85075ec1..2e64e132bba1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -357,20 +357,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) @@ -1623,7 +1628,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 From patchwork Mon Apr 8 19:42:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621550 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 D1C49C67861 for ; Mon, 8 Apr 2024 19:42:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0293E6B0093; Mon, 8 Apr 2024 15:42:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4436B0095; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD896B0096; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) 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 BFC906B0093 for ; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8B94B12013F for ; Mon, 8 Apr 2024 19:42:53 +0000 (UTC) X-FDA: 81987387426.13.1F21D57 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id EFE4818000E for ; Mon, 8 Apr 2024 19:42:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rZrv3CZ/"; dmarc=none; spf=none (imf16.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=1712605372; 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=g/vGJLoYxlPmulU4S77Y+SHZ4lO6tnjl8V7pbWs+uN4=; b=vs+oQn3N2TqFzbcvj1jCNJ3O35DNLacGlZ7oc3LHGmk6AN4W4b00sOIACVjfs9y8YHcDua MFbto3Mv9kiHZFMGCWY7qb3vDx2YE1aT9m5U7K6vpzFUminhR+BBqFBrdBWaIBfzHRnW4X hWQrkIhMem0pEw9KSxblJPnr2sCpZN0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rZrv3CZ/"; dmarc=none; spf=none (imf16.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=1712605372; a=rsa-sha256; cv=none; b=ZmEEWbNmKQw5vhv3drFhUp8BtviFTdrmPmHXFkRqo8BvNRJ8/2rHNfuu/86p4VJz9FDf2S 2FHbXwFMe+DvH/mpAhF0ToKwod6eCimJN4erXi3XiUikkFOjPP9oYnmTpGctwTxUcnHSvR OMuWvVnHEp147YEmmiDcqx1snUsS9FE= 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=g/vGJLoYxlPmulU4S77Y+SHZ4lO6tnjl8V7pbWs+uN4=; b=rZrv3CZ/2P2oDMKsj6JOzjVr8L +MHrB56ugVAB/OrUv9wMfl4HKNoME79s2P19mFNgMH4xqYtRo1092mN7mxNZld1mqVJWNtliSz+mM eVK6d8VvTaL9+K4zY7a0eHmf3crTEV0IE/ob3MUOawzk/4rWC2ovPiI+2pFgELriFI3c20Sth+HqO D1E1gCBwT0J7sypc7WlMdg5nbSbGkgLD4aWfky90cfzAUDIZyn0/kAgFwfhC/nhec15AAYZ4ZHDMZ jjQUZEfVjK0UGYVd6qQJLfgYKN1+cBzRlGYruEKNuy+P+8VwqobCS/FQIZVEtnJRKkcZCRBUq3F9m kNMgYHuA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqJ-0fWh; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 06/11] mm: Convert hugetlb_page_mapping_lock_write to folio Date: Mon, 8 Apr 2024 20:42:24 +0100 Message-ID: <20240408194232.118537-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EFE4818000E X-Stat-Signature: smbsdwqckt7qkybmkufi3wm68ep1cppi X-HE-Tag: 1712605371-337075 X-HE-Meta: U2FsdGVkX18bN0AOgdNyXJH2zBWCHgVlOTecuy8y9rifHnulTTVgWyKdcnKK+G6gv32FJPe976hMg6HFOY3OHKveZ9ducURzlDtm+zaCWGJmYpUl9BSzmDWnk1CCiWuOHjW+PaQ0tm1uNUjeb1L7uzmuHz/xjpVn/7CGq/ZogrOgI8NtllLfFGvzq5nfbu9wrLsKpusMsTy0BOtyj3eq/SKvw+0ZpFkTC6XvGrE26JE18HtrbCn6ucA8A3qliebtsot04O7FtxfPXy7xa9z2cLn7UuikEshs8ddzrAnH6vF3AM2v1PbvL5oMq6qr1Syo4jyXjQMqd9WWrieFX0AFY/RzlbUMK2oNldF/gjydjwzC9/btmilAABjPeYHtIawD1rM7W1sSQctiY30Zqi+gt2Dm065dESvh5hVpcf/KOlkMoUXp/XMnJVpDK0c4NCdn7xcFXyAyqK/B+OMjcDU77SNkcU8FaxBIwQAdpo0LLpiEKuM574aT413doTD182Cf5Lm7Lp6BhlTBnOnnpY+VwA/xBtAx/MxEoZGvheOuyundtW1x/3Cp++2s/IFKQqQo41OG8LGUT1R2UioedB1SD93amP3H2IVN/UIf80OmLTIVf4nYHWDsQcJUu9jQYteyYwK1XxbOaMO5oB843bSCUBKZW2GH2D2pG2XDJwAhiAUnkyvSumffT3oUxZQDxiemObtH82MIw+gOqivwKv2btt9KyaSxnnpTl6PrjjNk4943IS7+dO3MwnDOQ6CbfHF29JCoECtZqW23iQp7W6BbJJZFmLTEsCvdPwz87D8akHHIDmu3G85JujQbmkHxn2pQdbHvCnf4VUqfvodMIpiqMyNUexvOaH6mFcw6FRNiKoFe5lSLYD2Dkba1EWyXRnfvXX8u6f6DDm83um6C235WocTRdWGfNaIugtYaCA9An2oREYkhL+WGXxrRoT0btOkjnGs+q+LLq6kdgfN0gZd o6kiwibO yQffVgSfyCL/5t48EzT1WEOzebClEPmhMCCnP9HY0miIXDMy+5khLWMGQPBDGMzvafSYVbxUTg6mPXvvfDKGmE0RSpZf39e6W5XPAfRDD2ynpsOtNp9n2//mqJ4fAKDwxIoqURu23e9xbKRw3/UlkrMvDuzisK2BbUtM8rBQ92sET4u9vxs21KoDZ90Q7QCT+kpfRjK9Bp52GlzPH1Q/ryMYdaHsQWcjlU1BXviVpUrzwodw6xxqstE5O/iDvGxDujJfP 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: The page is only used to get the mapping, so the folio will do just as well. Both callers already have a folio available, so this saves a call to compound_head(). Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu  Reviewed-by: Oscar Salvador --- include/linux/hugetlb.h | 6 +++--- mm/hugetlb.c | 6 +++--- mm/memory-failure.c | 2 +- mm/migrate.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 3f3e62880279..bebf4c3a53ef 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -178,7 +178,7 @@ bool hugetlbfs_pagecache_present(struct hstate *h, struct vm_area_struct *vma, unsigned long address); -struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage); +struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio); extern int sysctl_hugetlb_shm_group; extern struct list_head huge_boot_pages[MAX_NUMNODES]; @@ -297,8 +297,8 @@ static inline unsigned long hugetlb_total_pages(void) return 0; } -static inline struct address_space *hugetlb_page_mapping_lock_write( - struct page *hpage) +static inline struct address_space *hugetlb_folio_mapping_lock_write( + struct folio *folio) { return NULL; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 456c81fbf8f5..707c85303e88 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2155,13 +2155,13 @@ static bool prep_compound_gigantic_folio_for_demote(struct folio *folio, /* * Find and lock address space (mapping) in write mode. * - * Upon entry, the page is locked which means that page_mapping() is + * Upon entry, the folio is locked which means that folio_mapping() is * stable. Due to locking order, we can only trylock_write. If we can * not get the lock, simply return NULL to caller. */ -struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage) +struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio) { - struct address_space *mapping = page_mapping(hpage); + struct address_space *mapping = folio_mapping(folio); if (!mapping) return mapping; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 2e64e132bba1..0a45fb7fb055 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1608,7 +1608,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * TTU_RMAP_LOCKED to indicate we have taken the lock * at this higher level. */ - mapping = hugetlb_page_mapping_lock_write(hpage); + mapping = hugetlb_folio_mapping_lock_write(folio); if (mapping) { try_to_unmap(folio, ttu|TTU_RMAP_LOCKED); i_mmap_unlock_write(mapping); diff --git a/mm/migrate.c b/mm/migrate.c index 285072bca29c..f8da9b89e043 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1425,7 +1425,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, * semaphore in write mode here and set TTU_RMAP_LOCKED * to let lower levels know we have taken the lock. */ - mapping = hugetlb_page_mapping_lock_write(&src->page); + mapping = hugetlb_folio_mapping_lock_write(src); if (unlikely(!mapping)) goto unlock_put_anon; From patchwork Mon Apr 8 19:42:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621543 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 B04FDC67861 for ; Mon, 8 Apr 2024 19:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C4966B0083; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 074976B0087; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA54F6B0088; Mon, 8 Apr 2024 15:42:40 -0400 (EDT) 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 CC2116B0083 for ; Mon, 8 Apr 2024 15:42:40 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 91B0AA0183 for ; Mon, 8 Apr 2024 19:42:40 +0000 (UTC) X-FDA: 81987386880.03.4BD82E1 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 7D5C040008 for ; Mon, 8 Apr 2024 19:42:38 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uCLosnWd; 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=1712605359; 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=BrEoYf31c2AVoc+eqLyqp3TFa+yeR2usS7I5e6WvwOY=; b=UwSwJsEPSDfTKHFrUGci5OikxbI0gF4LwQDFZmsen9s1U2OHxOYpeshYI+1b9tCdLMHJ6/ 2M+1dYnvv1x3P2eZcQ8pGMSwRugNn4MWtWw9TVO3ea3BrgCRs1dq2kFu15+TaaPEzkA8Ii QxLMh63fZ9tfMbQW3kGCpTky8DurYhk= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uCLosnWd; 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=1712605359; a=rsa-sha256; cv=none; b=B5LZGXouLEj+4m4hggmOtGDc1w69LcKnBtNWp+UiomD0Rzh9yHtzqxkMwTjzniKsKcM/TR GSJH4kYwG2PpM1DVepNSo1xqPzE1Lnf+KjvP5Jpd9lBonoqq0JwJLYnWpn0W6GAJCdP3h9 ULNhJTBBj9caX09tQ8yQnIhZmt7Mr48= 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=BrEoYf31c2AVoc+eqLyqp3TFa+yeR2usS7I5e6WvwOY=; b=uCLosnWdbtTZCoYg60K7Zsl0h5 6YWieKYa6qfnD4T22QcV9aTAA6yBcWgJ73FUHUlTqewgNXH7IRJJearNUuIWd0adU+UaULUYKTaEl IjT+dbzEdyB6Z3J5k+6J1z4RFQ0BV9FQP+9y+JgVGppqfWY2q/+vR4/RzW2yMpzWZWl21+1e2CzRL 9++Wma3Z6Dh1YC5YHKQ6xxCP0bM3nu6KQtGMWKacNzWzw4i4S27niJHvySI1SIxN00o0Xt4yE+5il RtMW+Gz8V2hhYdZ9GSo88zjVLvaLsQgZlPwUXC3CWFrIvD77zw5g4Xxc8qEFvhRp6kM0lttzIPUaV 05QcoHcg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqL-137T; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 07/11] mm/memory-failure: Convert memory_failure() to use a folio Date: Mon, 8 Apr 2024 20:42:25 +0100 Message-ID: <20240408194232.118537-8-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7D5C040008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: s31w8dey7krjnts4fc9aq8a746dahyng X-HE-Tag: 1712605358-443659 X-HE-Meta: U2FsdGVkX1/ghPO1myx6obG+wi6VMvZ+XrNpznv8o7/WHj+Kbg9ibmwhaWsVeM+TAAbCdZTZSjpGgzefI1V78YLjWQ+dPCYte3Lu9JiZzJSqtOWr07xvJtPhFTD9M5bWEQIzWtaQMU8QMsXPiMJHdQNfwYst3vulFBZ2r44JV53BFDf5PqJ4XmlRt6O7WT4iKvLzc3BxnD298/VPSeGjiBiw4a+KtExgw2ICvpKbSANHGpji97o1IFUZaXyXSWEPwVg4xfLKDp/Dr4SLnSiiznIbLhddR6s9tADu9nZyYrJHxrrtCTEkEZgksayiURvA3PIeDxJdtlwtK7fz5axsXen3DdWsnTLAkOcKocnj2EHTx3lmZvgP3KoUl/cmiOjN78JDfrNwWiuS0yGqyfS3+vgm3fW/Spi1r3+KucxHYtE8I98ERfPzBJw6KzPY/Wv+axsDO6+kb1I062y+9Z0CrqKQoJlcS70tUntmywUVxHZ/FYwyn7lvnETKPEhRawdsT8lVZJE/5JeG3Ot0CdBnE82Y8KnoLS7rOBC1E/qqaR9bi8PFu2GobQZGuyGYod6FXV/jJzLIQH9jRwns644gJ0GRqMXkauYffELCTT07X2plbppJBHWpQztLIOlJWtgx7WXt/AhSGowCJAJhVImilNUeI9lhpGHIdzQVtCmEOGu5VDhYnWUPT8/1AgoZkUxoaBEtZ3gorcg8akLWFKJujiBnKDBuoOlfC23jBAXPGNYEtX5ufoqyCQN2gygoNUQAjV7ZTQFc6Kpznpss1S8eeHrP0yUX78VpiQAsR7gxETdcjdk6AH85IOKxfJ7JjDylNdqivZwGL2+AHYR8LF68OjEDcWdiaBsrJD1dOaiyAoWjv+NFvuaA+vL1gdQ5RZKwlJw5IxsWMB74Tz2w8bF6+BZGXQW+OhdHvvmyDqRc2e5ASFsv8kMFcq7Vv1p74CWdcQ1PD+diwVmtNEViS9M KTKgSHj/ ax8Cr6a5PmsxkAbDmRqvQoHRriCqgYDHx5YfygznamQiYYxF5wy5Xq42Ax2Lcto1bplbIZryHF7xhV8taiiGr9FzE/Q0/TCoDYYSQYsaAa/huS1MV1EjKGMMQ9UBBra57WYlj2D7LWnT58bXwG4JaK81d7Lkc2ZW9diCzDoSFeVO9m5M7XW5P48qVguGKnzHVs0YTC+MNhnn7nnP446FatA7rIPv/fSoushbUule6L/1wsBZd1zoJGdHEc+DP5Yuh8b+EwLM1J4Mvmpx/uJX5VAPiqg== 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: Saves dozens of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0a45fb7fb055..1c7c73776604 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2173,7 +2173,7 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, int memory_failure(unsigned long pfn, int flags) { struct page *p; - struct page *hpage; + struct folio *folio; struct dev_pagemap *pgmap; int res = 0; unsigned long page_flags; @@ -2261,8 +2261,8 @@ int memory_failure(unsigned long pfn, int flags) } } - hpage = compound_head(p); - if (PageTransHuge(hpage)) { + folio = page_folio(p); + if (folio_test_large(folio)) { /* * The flag must be set after the refcount is bumped * otherwise it may race with THP split. @@ -2276,12 +2276,13 @@ int memory_failure(unsigned long pfn, int flags) * or unhandlable page. The refcount is bumped iff the * page is a valid handlable page. */ - SetPageHasHWPoisoned(hpage); + folio_set_has_hwpoisoned(folio); if (try_to_split_thp_page(p) < 0) { res = action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); goto unlock_mutex; } VM_BUG_ON_PAGE(!page_count(p), p); + folio = page_folio(p); } /* @@ -2292,9 +2293,9 @@ int memory_failure(unsigned long pfn, int flags) * The check (unnecessarily) ignores LRU pages being isolated and * walked by the page reclaim code, however that's not a big loss. */ - shake_page(p); + shake_folio(folio); - lock_page(p); + folio_lock(folio); /* * We're only intended to deal with the non-Compound page here. @@ -2302,11 +2303,11 @@ int memory_failure(unsigned long pfn, int flags) * race window. If this happens, we could try again to hopefully * handle the page next round. */ - if (PageCompound(p)) { + if (folio_test_large(folio)) { if (retry) { ClearPageHWPoison(p); - unlock_page(p); - put_page(p); + folio_unlock(folio); + folio_put(folio); flags &= ~MF_COUNT_INCREASED; retry = false; goto try_again; @@ -2322,29 +2323,29 @@ int memory_failure(unsigned long pfn, int flags) * folio_remove_rmap_*() in try_to_unmap_one(). So to determine page * status correctly, we save a copy of the page flags at this time. */ - page_flags = p->flags; + page_flags = folio->flags; if (hwpoison_filter(p)) { ClearPageHWPoison(p); - unlock_page(p); - put_page(p); + folio_unlock(folio); + folio_put(folio); res = -EOPNOTSUPP; goto unlock_mutex; } /* - * __munlock_folio() may clear a writeback page's LRU flag without - * page_lock. We need wait writeback completion for this page or it - * may trigger vfs BUG while evict inode. + * __munlock_folio() may clear a writeback folio's LRU flag without + * the folio lock. We need to wait for writeback completion for this + * folio or it may trigger a vfs BUG while evicting inode. */ - if (!PageLRU(p) && !PageWriteback(p)) + if (!folio_test_lru(folio) && !folio_test_writeback(folio)) goto identify_page_state; /* * It's very difficult to mess with pages currently under IO * and in many cases impossible, so we just avoid it here. */ - wait_on_page_writeback(p); + folio_wait_writeback(folio); /* * Now take care of user space mappings. @@ -2358,7 +2359,8 @@ int memory_failure(unsigned long pfn, int flags) /* * Torn down by someone else? */ - if (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) { + if (folio_test_lru(folio) && !folio_test_swapcache(folio) && + folio->mapping == NULL) { res = action_result(pfn, MF_MSG_TRUNCATED_LRU, MF_IGNORED); goto unlock_page; } @@ -2368,7 +2370,7 @@ int memory_failure(unsigned long pfn, int flags) mutex_unlock(&mf_mutex); return res; unlock_page: - unlock_page(p); + folio_unlock(folio); unlock_mutex: mutex_unlock(&mf_mutex); return res; From patchwork Mon Apr 8 19:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621551 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 6E3A4CD1292 for ; Mon, 8 Apr 2024 19:42:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BDF16B0095; Mon, 8 Apr 2024 15:42:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46EAE6B0096; Mon, 8 Apr 2024 15:42:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2727A6B0098; Mon, 8 Apr 2024 15:42:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 07B046B0095 for ; Mon, 8 Apr 2024 15:42:57 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9912880152 for ; Mon, 8 Apr 2024 19:42:56 +0000 (UTC) X-FDA: 81987387552.06.602438D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id F1509A0013 for ; Mon, 8 Apr 2024 19:42:54 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RpL1PRDc; dmarc=none; spf=none (imf15.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=1712605375; 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=B4hnryhcXkSp4iS7rv9BaRyeZuX8K6Kk9RX8X9f3irE=; b=7sNeY4fPWR7Z0+D5j9Qk1b4Y4IKerreD77b8ONvBQnnssRW40VP+n9MGPhWrfPr8Vcu3M5 +gZUSB8CpSYtdqMK3782FbIrdOwh/7yb9uwXCPqSm+N7oxRCpxqWVD/AdDRbqJWSqE0LdR ev11DnQmFsyz8Vnls5wIFgpzRJwrwf0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RpL1PRDc; dmarc=none; spf=none (imf15.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=1712605375; a=rsa-sha256; cv=none; b=quYqDTD9PIV15GEWWbnKUKTFC30/t4+1MGu9yoztRel0WHEIuNSDNO0fy7lSL0XuRHVYkn O0V8vTjIDQj0wwaW2ogf/EG0vpU3q6eGelCWze6zxhXwRH5XxbNyoCstlcQuKke6IHhLLN fEc4W/3w+xp81nK43Eninh0nl/XCaZI= 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=B4hnryhcXkSp4iS7rv9BaRyeZuX8K6Kk9RX8X9f3irE=; b=RpL1PRDcZ6XUEPlUVVVuIQY5H8 9Qg27XzCwO6OzAwddPhO8cq4Riu77Wt3isZ+zuAJ0ee8/Z/03NgHyOCMrczBc9uw7wTmSprW+mhV0 NdSfJ1DxqvSX2j38cJ/dm0htn1OFP/j3wtrZLfgtDeOmW4WHAcCqU4yskoifKm4AZrhNmCkotnZ5C ZpusMVCYS5vG3anXQMPk/40QDidEUzEjEyrShs/h7HB4lksXOSvF9y7/Xhkmrf//5KsIx7sS+gA9V XZseW/hfk9r7hG4ldIS1PR++X5E4T7KSmQFoSp9sRUUiXB35TbAlZcNRDGkGGklGOJz4oU8c2ObTs zQwuFD1w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqN-1PSx; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 08/11] mm/memory-failure: Convert hwpoison_user_mappings to take a folio Date: Mon, 8 Apr 2024 20:42:26 +0100 Message-ID: <20240408194232.118537-9-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 1nmhamyi6q1oza8qeewe9szp86s4jr73 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F1509A0013 X-HE-Tag: 1712605374-190031 X-HE-Meta: U2FsdGVkX1+UUJ8rf5IxWqPF/1QZDrhRdoqiBJYtAmX9mrZJeOetDMpqQzkzNDWwgfu0hhIRvw21LPhUVHBQbv8lTEntOVKHLeMULt9cku/6xLG8mq3aZSBGj+FN+1l4GU6Bhgq9YLVaJJ6nO5KgKMedZZJvJT4lXDew32Q4K+aa6c8FVn6JJZhJXk5UTLuXqObu+22f5F+DnA07MzxQK1sTwISEVUzB1J75q4JPkZvfuIw/LGJD4KhoqaPma/bjjuWcEahOpwNuYbxszZb33Fly8TOT1SJCuIkdbNuGfCll1mxH14vZGbKd2J6FQnYkJNUb+Waq+U2ouLrw9tEEbu70S7mUjjGaBHQwIHRXNkDAbXh+/Qkd0bX0pRJMG7PvMjs1n7Zf+EZBuCy30WVBlSOfvCPcsHtFzgblTzHFD7ckO5HN81QsPBRZc33A4dDw+w5Cs6mIZHpLIxxtPKBXoIxuUIkrTg9L/7yTle5K57sOdrnKkmPTwCm/cpj9QY8/Ig1ukf3RhHSIVO2hqaZCT8EXGKJznrOJrW7/Q5kEZMXMQfunAD6XcVAwzpvqKjP4oHiDPyUzWCPuVG6yZ0GcSWQexdlkLh2sOEM8XAWBxb028R/eH2M94Pzme4MHPUGvYnWXNHK6Vt6dT4H+TOSEf7lf/GRTzmBsXyx6tuMvTSIVJd+mLTLyCWkNrp23aBitxGF8r2G0u69cFDPirSb7IT4UPajKLat8YY9ppESNbzK0y2jj3WWCW9oWE72hvO5h9LZdBxF1jyxqL+azJzcXnRgEYFZpW1RA3RdfECJi6hEsjTYr1V/0AozkYfATmmuXG40UsgUF2WPJQHP2n49CJDwMfGAqY29G1zT+M7OMHR1F9/t1KsGiTtjHdEK3QHc/UZLzJvONpb5ZfGICkYWI5QGaO4bsl2kAfF5zg6MUjO5GNE51P0PMVIQS6bG2kIX57bBlrj9z5SLlf/VGbSy A0t8zRv9 ngu8nUJdaJNUz3JRnSn0lSFYgQqWTBKMQoWurBlZ9PF+GewPL8snxGHk28TWBLcju06/aWcmRjPrlc1xmGLiNKAJlY1ipHbKB8das6C+4KvPK5p/uaX9TzAwhxsu6iD/hNBd+k9uRuuGlQ9r5rGYAFxdFmAnGvjgKJWIMIaUImZGeMstBcLFvnKN86BBu6Gxn418JKNAxg9UAUoSINFi0Zf45nFjfo2hUWn5aCNSt+rLW2asWnqRwbKuxKQ== 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: Pass the folio from the callers, and use it throughout instead of hpage. Saves dozens of calls to compound_head(). Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- mm/memory-failure.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1c7c73776604..fae0b42f0aaf 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1543,24 +1543,24 @@ static int get_hwpoison_page(struct page *p, unsigned long flags) * Do all that is necessary to remove user space mappings. Unmap * the pages and send SIGBUS to the processes if the data was dirty. */ -static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, - int flags, struct page *hpage) +static bool hwpoison_user_mappings(struct folio *folio, struct page *p, + unsigned long pfn, int flags) { - struct folio *folio = page_folio(hpage); enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_SYNC | TTU_HWPOISON; struct address_space *mapping; LIST_HEAD(tokill); bool unmap_success; int forcekill; - bool mlocked = PageMlocked(hpage); + bool mlocked = folio_test_mlocked(folio); /* * Here we are interested only in user-mapped pages, so skip any * other types of pages. */ - if (PageReserved(p) || PageSlab(p) || PageTable(p) || PageOffline(p)) + if (folio_test_reserved(folio) || folio_test_slab(folio) || + folio_test_pgtable(folio) || folio_test_offline(folio)) return true; - if (!(PageLRU(hpage) || PageHuge(p))) + if (!(folio_test_lru(folio) || folio_test_hugetlb(folio))) return true; /* @@ -1570,7 +1570,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, if (!page_mapped(p)) return true; - if (PageSwapCache(p)) { + if (folio_test_swapcache(folio)) { pr_err("%#lx: keeping poisoned page in swap cache\n", pfn); ttu &= ~TTU_HWPOISON; } @@ -1581,11 +1581,11 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * XXX: the dirty test could be racy: set_page_dirty() may not always * be called inside page lock (it's recommended but not enforced). */ - mapping = page_mapping(hpage); - if (!(flags & MF_MUST_KILL) && !PageDirty(hpage) && mapping && + mapping = folio_mapping(folio); + if (!(flags & MF_MUST_KILL) && !folio_test_dirty(folio) && mapping && mapping_can_writeback(mapping)) { - if (page_mkclean(hpage)) { - SetPageDirty(hpage); + if (folio_mkclean(folio)) { + folio_set_dirty(folio); } else { ttu &= ~TTU_HWPOISON; pr_info("%#lx: corrupted page was clean: dropped without side effects\n", @@ -1600,7 +1600,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, */ collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); - if (PageHuge(hpage) && !PageAnon(hpage)) { + if (folio_test_hugetlb(folio) && !folio_test_anon(folio)) { /* * For hugetlb pages in shared mappings, try_to_unmap * could potentially call huge_pmd_unshare. Because of @@ -1640,7 +1640,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * use a more force-full uncatchable kill to prevent * any accesses to the poisoned memory. */ - forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL) || + forcekill = folio_test_dirty(folio) || (flags & MF_MUST_KILL) || !unmap_success; kill_procs(&tokill, forcekill, !unmap_success, pfn, flags); @@ -2084,7 +2084,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb page_flags = folio->flags; - if (!hwpoison_user_mappings(p, pfn, flags, &folio->page)) { + if (!hwpoison_user_mappings(folio, p, pfn, flags)) { folio_unlock(folio); return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); } @@ -2351,7 +2351,7 @@ int memory_failure(unsigned long pfn, int flags) * Now take care of user space mappings. * Abort on fail: __filemap_remove_folio() assumes unmapped page. */ - if (!hwpoison_user_mappings(p, pfn, flags, p)) { + if (!hwpoison_user_mappings(folio, p, pfn, flags)) { res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); goto unlock_page; } From patchwork Mon Apr 8 19:42:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621545 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 9C27ACD1296 for ; Mon, 8 Apr 2024 19:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D7046B0088; Mon, 8 Apr 2024 15:42:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 187646B0089; Mon, 8 Apr 2024 15:42:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 027286B008A; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DBA066B0088 for ; Mon, 8 Apr 2024 15:42:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9216816015B for ; Mon, 8 Apr 2024 19:42:41 +0000 (UTC) X-FDA: 81987386922.29.62C6815 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id F292740007 for ; Mon, 8 Apr 2024 19:42:39 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SpAARLpc; spf=none (imf11.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712605360; a=rsa-sha256; cv=none; b=eBzc2Y+TrRvcHEqUJaLJi2jMp6pPZSlYXSpjTH4UcRZ5ZCrBu40ZRZuVGsb4A+Y+AdCszy ybA/S5pOOoxUMUhQbx+jgHrnX+DJGWfoUFet8Civ82mNvJuK+YTW45WjWiO9CAaXX7z98M wW81GTAAwEoWrcGAnv9kgywTUDCOK4E= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SpAARLpc; spf=none (imf11.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=1712605360; 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=soTpfP0xkNpciy3Ek6DOYl0uO4o6L2fyg9jDZSMeenM=; b=Kt6GTWT9j0ShQWQGdBeaZd+IAvrj0alt8DBFDXw4EuiIy28p5pEVchs/L8ooHW8ybVZY+S wVvCC1Xsis7tTIMq3LS/YKIvbxDzj0ZkSoOq7OdKaAFBtAaBiN0088NtjI+O4r6JyFW5JX 4MYaveUh5/BrCHPqFr3IiQuf2d5/7C8= 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=soTpfP0xkNpciy3Ek6DOYl0uO4o6L2fyg9jDZSMeenM=; b=SpAARLpc/f08d8/D+xVo8vDLt/ tvxVrtQRDXkBaQ1yhlnODi+G+xiVj08BVa/hCabrAf9Ho2AQh30XGPXmxJqqK1EV9vRlc+NunMb74 VVl5XMI1sGMWp8CsOcx2KbPCXkd+ktGxd3Q64ZZQxVvN9WhliN5YmUDj7Ejc3ROgHQcrO8Wttw4JN mIt48rIdyRKxQSnslXjJIfvs+2lq6Ee0EPRdtcF65PqH1Gw1gpXcWNTogKYtYvpdCx2gu+E81zOP6 82ChieCnx9n/Qe8ggXdHgkZD8QBRDzYqhRUt4Xdc7Qp/2sU4oKGUxISY8ooUUMcHBSM08p5FBr7zH nC79S8yg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqP-1ivd; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 09/11] mm/memory-failure: Add some folio conversions to unpoison_memory Date: Mon, 8 Apr 2024 20:42:27 +0100 Message-ID: <20240408194232.118537-10-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F292740007 X-Stat-Signature: 55szng94a855ramk5xxdjp7xg8ayj919 X-Rspam-User: X-HE-Tag: 1712605359-171805 X-HE-Meta: U2FsdGVkX19KLnOr6IFae7eJrk869tOk2ZQrXpLV8EdYyKOuH3sHt5jZtZy+n+AJqrS+Hf7OY31VNG1VOqXESvhs94Lukqe7TNgk9ZZ1MMMvJmKue+cWWa2sNIkZVCUMrSG69muVMrDvX4h1pnC1sO6m4WfkSxnOyCwxJ+473xTvQWWuUKjeQipjsydBYqLPtgCfcytr3n02IvXECzL1vqOdaLyWyEBQQSuMj3Sj6ensc6j0lQ+CEsRVvnFivkBkJXDkGRotZiVFb3EpHDKJztyDfUCAoLz4adJ0TW9uNkevdq56oI+57Jez4ZhGt8h0F7zajMq7OZtHLgRJ58r2k4Dz8BF/vs3GWvWt41rhjmErpoPJColrGM2XASgn8Ox1d9rHbLqfMxVgpSvFT8ZSUQNJ7ki6prFLxN0ZygVtNL/mJnMKKDUtEpsKHzyu937kOE93A+K967dbiM5Bl+KFlB9827nDzIa8+jpph6Rezdwk8TdgZlFdAJJKpiV3fDVCgx51mYJDuSDr5sRqZjXlXavx6tWGncTgoyH8HquYpyc46+8hxLjQ+h+6DRfrWEveGoCm07hHUomQaDS5yPkHwQmT3MuWZD7F673Gy8gdayOnNeunv+I583WgXNbxNf7HpjuNvDpZ7dy+3LI7kcnOqoHBmJyIjXB7o2XG4qqpuT1JdOUFT01e7seVlKGx1sk3Bl+RO9qVgwdQn3KPFUdTqFYdT59UgG4Q2j9EDVqZKwhPO0/P1XZMmyQqE8mA+iq5sdTwN15uvzGWiG/2hWdR25NVpwhiLLic7iqfc0dxht9B3Bh8qSBA/IzppLjHp5nf/qjAoLbbeBmxSC9hBjhsCo+qkh28qTd8hJNxtBQ4uHUHyw7/eEube+SySK1ygApwFhiFc3m7V8tHXPiF3P41kr9kO5GF/mzA4JKlHUqSqBWk5HX39QkiLmmaNL44UhbrRisEhiuhi9wU/O0iUnC ItVTvvnB Lr+bNqly2MQTbKbmDvbKntCI71dC6BcZ5/TvhWS3ntmCaa3G93Zr245F5ugb/II+WETrUCGJkNYLdYfpJInwDNuNoGFZfa1rHchewVC5sgcF4ObJXEZZFXZnWGyKZ5xX5/novy0fAnRdaZG0nzMw8ry3LbfqOOBUwl+POg8KGzfAUnTl32Bagz7EKGv59bVZrQmpGXfGPbeztXQx2/mHfP+eGJ1yBIivMg+pRHPjGkl/4Y79gnt91jQHZ4A== 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: Some of these folio APIs didn't exist when the unpoison_memory() conversion was done originally. Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- mm/memory-failure.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index fae0b42f0aaf..7caec2fc3327 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2540,8 +2540,8 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (folio_test_slab(folio) || PageTable(&folio->page) || - folio_test_reserved(folio) || PageOffline(&folio->page)) + if (folio_test_slab(folio) || folio_test_pgtable(folio) || + folio_test_reserved(folio) || folio_test_offline(folio)) goto unlock_mutex; /* @@ -2562,7 +2562,7 @@ int unpoison_memory(unsigned long pfn) ghp = get_hwpoison_page(p, MF_UNPOISON); if (!ghp) { - if (PageHuge(p)) { + if (folio_test_hugetlb(folio)) { huge = true; count = folio_free_raw_hwp(folio, false); if (count == 0) @@ -2578,7 +2578,7 @@ int unpoison_memory(unsigned long pfn) pfn, &unpoison_rs); } } else { - if (PageHuge(p)) { + if (folio_test_hugetlb(folio)) { huge = true; count = folio_free_raw_hwp(folio, false); if (count == 0) { From patchwork Mon Apr 8 19:42:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621553 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 93B48CD1296 for ; Mon, 8 Apr 2024 19:43:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24BF36B0098; Mon, 8 Apr 2024 15:43:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FCF76B0099; Mon, 8 Apr 2024 15:43:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 029AC6B009A; Mon, 8 Apr 2024 15:43:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CF9D16B0098 for ; Mon, 8 Apr 2024 15:43:03 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B1C33160167 for ; Mon, 8 Apr 2024 19:43:02 +0000 (UTC) X-FDA: 81987387804.23.3BECF1D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 1BE4E14000F for ; Mon, 8 Apr 2024 19:43:00 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OQHXQ+mN; dmarc=none; spf=none (imf26.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=1712605381; 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=IOEzr5jyHmx6zA4lRzG4aI0kxVWdg++eH+7vTi2OhhE=; b=5hbqk2sxvjyUuBgs6smiPaz2fg5XoxYOOXIQsv4VyPHqlAcrH2I6Zl6dMs/SbBbNB5EoPh a6E5ZCJVZzxbsJI8fMDqg6dR4FiqSsCLQ28jH+akKhZWf5G6hBoafPauwV9fywIbQv02Ys Nn74m10vTpqXfpc1K2CRWPUK9NLY1+8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OQHXQ+mN; dmarc=none; spf=none (imf26.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=1712605381; a=rsa-sha256; cv=none; b=ejvCP4K2vwjZ69uRd9ZYTTiYdBZaZ2idT401jAbeJy5s5nnw7JQ4QVL+4pLvPmKORqL2OK wwSfFb5HbPVe1aix5KPBuOvz+CYjgPx6u+mlXUjSxBXTt8JsU8IYS0f5UxIoPkEveoZr1a lJLuUlB1OjzlOawJfYVBI07+yX2pJ/0= 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=IOEzr5jyHmx6zA4lRzG4aI0kxVWdg++eH+7vTi2OhhE=; b=OQHXQ+mNM4i+uj0nzcAfWtGEU1 +vUj5CWphF9dmjUsN2qhw/BN51mX7D8TaQEpZfT/5watWAvjyfK1yKwpPYn/1lWai9wgsc+PoOV3i VF4uHlcLrmIafTNTUcevXfZUUQ6GZUVQP08Nm5TSVcjoH+2+XJXY02yKSW0S6bEXOMGQaYXZY3qEb r3EQMMjfEmubzC1CY7HUprxpS+Yi6AaNHCOotvHCVFiKwnQNCNoOP7Jmp3LwD5QcGht6i+EbBNgVZ Ah4w84mvTngRruL1+LKWDKvgbTesPujvybNB8FuTj7gkEZm9USmuUwZf4tA+Qr0V2RmgR1RmZZIwQ nyaQ1Tkw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqR-216H; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 10/11] mm/memory-failure: Use folio functions throughout collect_procs() Date: Mon, 8 Apr 2024 20:42:28 +0100 Message-ID: <20240408194232.118537-11-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1BE4E14000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 473menh6mxwssoxw16m8ygnq9b8n96rc X-HE-Tag: 1712605380-113443 X-HE-Meta: U2FsdGVkX1/4fgoalB/aewiodXWklKcF0W9wvjfymiuokTyOAAg7o5K7Zf6brJEKQkDNudQf8t5YWcEVA1fqkpOlJlARCPFU0z9q9ooIQpAKodYRASOn3p4xGl8xU32tBzvd66n0Ux+ak3tR9SW5P/ra0DXeMLeCqK5JHY8EUzgHEvomNSO7d1U5Z0TzHJLYM3MSEfNxkBYWAxbkRrlqlovRmBQbJN7lw/4NWCTt9QZ/9Ejopfb5eOHgkdWGkFaxigrIGLvw4CGW7aLl/9hbz9s9Oo+J5h98whZn54uHCdVol/W8F3jL0tm+Wg5fOWyj4eif/YEi2Mio1Vk3qbewBbo1NIfwkf3fOju5VU2uIZkNyG58JnOvhJsj96lQPv6gkngJsfGCe71rY7uJdvTFKmmTKkhp2kenU/0TxmBu+0U/Mb/7tNYBBOQkyQYQhR9MwmM6mUxAATfq3+890Twuz43lfepwbB7Be8KbyjzuA64GKeg5kn+2QW3A6jDWAZdm9lLkN57g/Ifi9wxt482JdX5ZyK8XgoH+0yH1g4b50BpV9WvlRL6QPDZz5QEkRiyHKBnsqYKe5KXVWq/Vg2K9CWrI9UMpfGpV4cfjiLR/ARzSNJ503lafArI3VFzpAmf2EFzZ67co/eAMfeJV9D+rIQ1P7TZfZVrQ2AynA2B0MAtY1xrZM2e7CFRyYihkjAQB/q8D2uQjIVRYJ+LVqEHjCLBGVzjCpSfeMHNK2vrAbnf7HPq1BIzddwqkO1l4QbuWmPgKnFXOCzo1O9ddLG1KKbVhvRA1szb2UQwkHvITDFKVahTP7OfwPSnzGg3+izUiM8eVZDNufNdL07PVp+kEI469iAO3+avggZaG+hMjFUxHDUKK6iSMjoWrj+JPRa88lRG9kqXZVMpf0/iEbGNDMgw1c2TMy2UWMqMccBCO1WqhgFJwh+f3DqGzRNOoRTG87aCp+E14pdix/+OqadR DRHjN7JG ChYmFxX9y/bcjYFZKJjLVwtaxiNSExCB6aoYEtJKxkJEtpGGJE3O2niHzZcAC+JrZfxUfcqxA+ZS2+zfE+ctEjz7qaGIO3EOT8Z9s1Sc4Jq4PBUnMH6dU5O75i1b1DMUHyPPwYhmSHn8EmuC3FuqNaCxPPziGGaGLtdluPqrJgYRro/i/bmUdGx4kzmokl80jUMGg4kJjTSYDRM3VyK0OfIRItZGxwLlQfAZL 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: Saves a couple of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7caec2fc3327..1c3cf1fe4964 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -712,9 +712,9 @@ static void collect_procs(struct folio *folio, struct page *page, { if (!folio->mapping) return; - if (unlikely(PageKsm(page))) + if (unlikely(folio_test_ksm(folio))) collect_procs_ksm(page, tokill, force_early); - else if (PageAnon(page)) + else if (folio_test_anon(folio)) collect_procs_anon(folio, page, tokill, force_early); else collect_procs_file(folio, page, tokill, force_early); From patchwork Mon Apr 8 19:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621546 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 F3792CD1292 for ; Mon, 8 Apr 2024 19:42:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 422916B0089; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D1886B008A; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AE726B008C; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) 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 EF9E06B0089 for ; Mon, 8 Apr 2024 15:42:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B30AD160167 for ; Mon, 8 Apr 2024 19:42:43 +0000 (UTC) X-FDA: 81987387006.21.D7F98A7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 28C36160014 for ; Mon, 8 Apr 2024 19:42:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=izrbCC2d; dmarc=none; spf=none (imf08.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=1712605362; 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=dlGaAuj8W6+fTT3yAvD1acTea9O34uBo7ScibxUX1SA=; b=7mFoFGSKaNxA2Lkgyrv09MV3fnR9Qxz06YMBiQkBt0Shlbbywz4k8ikl0P69tvnpv8lqOZ lX1guJNU4Wa2vwX/D+Rd1vFnwtoDpKfMXiCJLxMFEcQUKDy6jb82mQqtupw0xTdaruCvVr q7DbN021n6W3ppXBLcpxeoOH6KzoRcg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=izrbCC2d; dmarc=none; spf=none (imf08.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=1712605362; a=rsa-sha256; cv=none; b=geanU70ImAn9piVJK3uIfZRmKMdwOlbibiyYVucDJ8qBtby4VI36uutsA2FSvLnR2JgZhv WXoqIQ65zqtTN0J/xJVJ8fcx6UiIewRV5JyXCCxIIxxT7xaFuQhSdRGg5HI2gZ/s7j0O79 tgiY+j+8QE5u0pkkoE4xaisF9RQliCo= 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=dlGaAuj8W6+fTT3yAvD1acTea9O34uBo7ScibxUX1SA=; b=izrbCC2d+ZrDT9766uHaoSgks2 DyoQWurwpcPgY6Nocj8pSobJtDkVUpP5xbrox93bMm4PsD/aclyGsKsQO2/j5IAi/0Z1D6jgO83AB T8qxHegSqoe/q/bLogjvojVhUuiwpB89GskEUwthwfZ7VzjXdhqIEDqsyFpQjU5mGLcAbT+GcNQU8 zoh7G1RhHC4dSi34WNOZT/q96UvUx04Dfa2JZ8IvL4WehtMq1nbqftRXU//98xMxIm5O6aF742cGA lCw47OakWv4COOQEcQdTnxGVUBLXV8i2QNIBLUFqDJjBgj9VyEaoKJA2WusPE/jXoiXvYbE5oRx2H xDUJRCBA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqT-2KIC; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 11/11] mm/memory-failure: Pass the folio to collect_procs_ksm() Date: Mon, 8 Apr 2024 20:42:29 +0100 Message-ID: <20240408194232.118537-12-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 28C36160014 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bhynunbct4krwxzszmp93c374mij8a1r X-HE-Tag: 1712605361-110111 X-HE-Meta: U2FsdGVkX19QvyxTUfO7VSVoAQOvj3UbcEKOyJqPfTuVd1lIcW//k3Fh2AeZI47pUWLlSM1j9TkWyLzRAR0ZiSf+0Th8ZkI2xHE4ed7889+sa8ipoL+pCYuUpiVEpJbnJgH6P/6u3Vg0iBRpoG03vrhh1s/0Nx6QSYYSMQY+nHR+NsbHmU74Z3wMV+vZ1Pn1fhODx7OypuIxHojL09YfEDNNJGit7wgJLjWJbkIY1H1aU0aje8ymbKXtnAp8yTFS5BlyUKHx7afLxkLf3yPm5xPcsM15pb1QSnhTg2DJjxQMKKXz9QEYDP0qDZXi/LVAtgxc/0JDLTw262cWDgTuCv3s/D4DWE7EUP4cP05e0LZheife7OHigLORlseAQO9DgMg9czZUTAwhPQD75NziS7vREVI1XI45EV6y9pk+2SRcyiqu2nse9EDBIKNLPvdRYw5HIfCRajxVndrjR7P0uOfB3dBYQftpNPZxT37+dpV0wf5G2kyrCVkovD36sfgXL2fNB1AMYwtA1cjJpe0xDmBPguoXzwk9HUQz/9Zl1foYzGM28/Kpv3kL1Mo2PrN/bvONw1Y0bINMejio6heZBEfUIq5OHkLAL4SrN6bXqyNKArFcBP3kS5xo8LeC9UM8Oevn3NblaboeJjdj1VgC9ex+emlYelnTN1XUv8VUzQ/M2xz2lzVULyBhsMmqo6YPlGUHvbe52/Ks6AFEmsCBFxQdasL+/ghwt2EEErhJqdfsyODTrHEtc+tCvF7+0MCWJpHtjuTD5INcq4hrNVDhFT+L4u8hNf2SlrDJiVD6YJ8NoTSfBZ4qL1lP9Dau3hs6+7blCybqgWmrYlqQGSAc8PYE4lwhIMuSBgaQIBwNgyQxDxACIP5dMymOSS7cswU1TcW/3deWzkKB/Hg2rG8GgrEZxMPYJi+AMUeJ82J/YlyT8frmfFsgEkF7/QymHbkyKVwKRYZKHgcBRbqLFlJ g0r4moje eHXwVWdY6BfAo0MExXlZYDz4jnfW1PZPJ3InDaWg78bjsmqX+ZLFYE3clm7fcWhplgXUKVMuwmlTO6c0sPxG8Snw2/li1KxYi+BIUwP46CyO04hwP+LoOLskALSPDzhBziUvZ8Shj93l2EJI+qr14HC7flBroTXw0hifIAz4JjqffXjGZFtx6ccKm2EAs9AdtgKNU4ec2Nt3yo94VhHa29mapRbPxxULsmB7M 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: We've already calculated it, so pass it in instead of recalculating it in collect_procs_ksm(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- include/linux/ksm.h | 14 +++----------- mm/ksm.c | 5 ++--- mm/memory-failure.c | 2 +- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index 358803cfd4d5..52c63a9c5a9c 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -81,15 +81,9 @@ struct folio *ksm_might_need_to_copy(struct folio *folio, void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc); void folio_migrate_ksm(struct folio *newfolio, struct folio *folio); - -#ifdef CONFIG_MEMORY_FAILURE -void collect_procs_ksm(struct page *page, struct list_head *to_kill, - int force_early); -#endif - -#ifdef CONFIG_PROC_FS +void collect_procs_ksm(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early); long ksm_process_profit(struct mm_struct *); -#endif /* CONFIG_PROC_FS */ #else /* !CONFIG_KSM */ @@ -120,12 +114,10 @@ static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte) { } -#ifdef CONFIG_MEMORY_FAILURE -static inline void collect_procs_ksm(struct page *page, +static inline void collect_procs_ksm(struct folio *folio, struct page *page, struct list_head *to_kill, int force_early) { } -#endif #ifdef CONFIG_MMU static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start, diff --git a/mm/ksm.c b/mm/ksm.c index 8c001819cf10..7d032b52002f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -3172,12 +3172,11 @@ void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc) /* * Collect processes when the error hit an ksm page. */ -void collect_procs_ksm(struct page *page, struct list_head *to_kill, - int force_early) +void collect_procs_ksm(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early) { struct ksm_stable_node *stable_node; struct ksm_rmap_item *rmap_item; - struct folio *folio = page_folio(page); struct vm_area_struct *vma; struct task_struct *tsk; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1c3cf1fe4964..0630e34b583b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -713,7 +713,7 @@ static void collect_procs(struct folio *folio, struct page *page, if (!folio->mapping) return; if (unlikely(folio_test_ksm(folio))) - collect_procs_ksm(page, tokill, force_early); + collect_procs_ksm(folio, page, tokill, force_early); else if (folio_test_anon(folio)) collect_procs_anon(folio, page, tokill, force_early); else