From patchwork Fri Apr 12 19:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628294 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 40B05C4345F for ; Fri, 12 Apr 2024 19:51:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8988D6B0095; Fri, 12 Apr 2024 15:51:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84A156B0096; Fri, 12 Apr 2024 15:51:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 711206B0098; Fri, 12 Apr 2024 15:51:50 -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 4BB306B0095 for ; Fri, 12 Apr 2024 15:51:50 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 07296A0FC1 for ; Fri, 12 Apr 2024 19:51:50 +0000 (UTC) X-FDA: 82001925180.28.15E5BE7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 60AC0A0018 for ; Fri, 12 Apr 2024 19:51:48 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=d57JR1KZ; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712951508; 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=LFIGzt+jg2jlYQXhbYFL9JXXNKyVh12kURc8dYVHo3A=; b=2bKAez+ISBPR6/HrvpT2i9eTZygQXndNMgNNaup+4MS4k6MWBx5ImIQxUtyXa7VMS2gAYs zRMOVKM6oYGiR0dehxcX/YNB6IeY7r6WW7UaZhi2irrpuTROS8Q2xnV9hsObkd+Lh5m6RZ eoH69etU5qEcCntC+X6+vK8/csnrzUw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=d57JR1KZ; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712951508; a=rsa-sha256; cv=none; b=70uqlQ2VhDO1Z0fpqEMCpIDphYhqS8F+HUjjIOVjv38iUwyWrvxF5toKl5PgHwSCiK5wSz wCVDRi2tfXL3vjMoI5Ku0SVcV8hnNcPaC+KLnmYY0SkgmcQq296YEwm0Eq9Kji4LHCNnZK xqvF1BYJp+5Y2HRdlemiDQ7mz0fVD0I= 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=LFIGzt+jg2jlYQXhbYFL9JXXNKyVh12kURc8dYVHo3A=; b=d57JR1KZlfrWzKyllgEXk2CIl8 h3/JSdD46rtTWZXEcFnQfwxFoWEr510YxFcFBfWXxRaW2BACp/HSyP6sWnML4KTS2K7P9ipxdblhL nt1275I7IlBoDWKYTQM/04CZJj8G/MegvOUbCr6wnpFxpkqKDCXxTTOBavyjJsLtDvlNqE9xrlbfw cZwIS7ti+MytxW/AHRujHc+CCRUhUX3aYMTVX/zlnsVOiwt5Mxf0tne4KXd7UxGdsICuVTvTV1Mfz Qefb6Ie0iJHlCP8f6p32cg67DYK87Xlnd0CrzyT+xsWLAy6mShzxAeWPw/C8Kkc1lYqFj1x0T/UdW ZAfE3HZA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9e-2OnC; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu , Dan Williams , Oscar Salvador Subject: [PATCH v3 01/11] mm/memory-failure: Remove fsdax_pgoff argument from __add_to_kill Date: Fri, 12 Apr 2024 20:34:58 +0100 Message-ID: <20240412193510.2356957-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: oyrx9ckf33upqn59dubkfh5amyzbk1jq X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 60AC0A0018 X-HE-Tag: 1712951508-934815 X-HE-Meta: U2FsdGVkX1+rnf0gAygDK7vRIPsNoh7/c+/RMZZsooRUaTRSMupJBpnWTo04/xLh3tNWiTPKfi915jT4t0hBo40TVNWgwl4RCcUV28ZiMK9vfvBD7GqWBMPPPElYs6et/sGqFyre+uDFbVHZzc38H31Ts40jI/1ly30oe7tnRMdUhKAJ+ao29uZRV4MpyfROqO1FTv7KROhwJ609Yp+ukDaZDsSYpM0PR+53af5vuYvxQhcFP/TVGllnaRnVqyQIkRhTbSAGlhIkYd/+WQZ44C35EJreHU2oxXgCf9+0Mi8F+egxm6FTB6Vd3reLX4QcQ7Gkx5iZi2kSFjKsVD/MV+VPIJbiu05do6dEeYwU/L+nMUBeN1LFHqVud4WW528/eGqMGlv+SIqRRUyAMdPh52mZXlXbmRXGJ9cf3qfLW96cwF8KD+K5xV1Mw2WQmWfJh6pjkDM4lKdfDw21uxt5MMybqIlYunESAHPMIQEFM9lPLYGe6nhuv1YLWceKhc38WnU99tFoBOSVepBwBLwlhbJkAhyqe2SJx8+/qbqC5QX3NmgzN5VOx+aWtuZFvBrfvaTRB+RF+1MQTMc2Z+Ym9lJcXx0t6dAn5Qc5/ZsYntpJL1diaEUB/klr4En+e+oIIMafbdAULBWETzQgoH9sd1qc8GT25WeJYgImDhNK7LFhCbVfNORdDgHfYLpV+FcwhSu8jgRJ4tJngsxM/2+jCVP6xXfDITgcBGNVRi1MhvE1cBLvPaokG2tg4SCeLizF2+OS7cE2Xd/a70/ZOH3Snr0lKHTJD0aPLB1t2QXRZmk46L6NFwUwhbsBArrp2ULYPzvgqOq9lrgLP0oE2CNnEzagQA0UiZBqF286jVxrH0d1dEmRYNpBVpHSLNKM+VrPFfpQ+tgay+lEe0Ufn+3zvEoeIiaCC8BfIUZkDqPJdzQeRDQk4C1/bETYv1XC1FqhPnBpslfWlGriChuQ2U+ UX06WHWM yFgGY/K43hcyxhE931fbA+a4gmer8xcV4tDhHMsjmf/YHsaBp31WX2E6y2xSNfBkB3HgF9/j0SzmbYZwlCy3ChxC3dKhXbwDU0/+5DTD1K0DnMVkvMmnOrTKdNDjXzYWG3D9pUOD0gXNbCOeurRcEAaY/mDI15hboTH4p6OjAa9p/Zg6oD7d49lY+1qTIC7NFOh49VOCaaZShlR1qK1ZPuFn0jYIenUPdut8CDMBvs7svv5aIA1xbqA1Np5lostW0JP/A3OZrYnfmEkKPKBztgFCQxJW3uWvLyIcW4ciCfy/Ydh8= 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 Reviewed-by: Oscar Salvador Signed-off-by: Matthew Wilcox (Oracle) --- 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 ee2f4b8905ef..8adf233837bf 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -421,21 +421,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; @@ -445,12 +437,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)); /* @@ -480,7 +470,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 @@ -498,10 +488,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 /* @@ -675,7 +665,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 Fri Apr 12 19:34:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628295 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 8CEB6C04FF9 for ; Fri, 12 Apr 2024 19:51:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4534F6B0096; Fri, 12 Apr 2024 15:51:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DCD36B0098; Fri, 12 Apr 2024 15:51:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 255D46B0099; Fri, 12 Apr 2024 15:51:52 -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 07DBA6B0096 for ; Fri, 12 Apr 2024 15:51:52 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C81861407A8 for ; Fri, 12 Apr 2024 19:51:51 +0000 (UTC) X-FDA: 82001925222.13.749E76B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 39E7DA0018 for ; Fri, 12 Apr 2024 19:51:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Xvr+Xqxm; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712951510; 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=Tnq6NiUN07vNOZ2QsHlIu5rppou5nXdPST7AYt/sXEQ=; b=KcYr+xsuhjr9NcOr31FKGk+7hNXQPJTsgbr3tGz/0bNTdasQenUdEB/hgvbAr3krPp8/l+ ZX+jsF1XGPG0b+Vk2sPFgwTNjIZbqWz2qz2gxPnqGJEN17kWoXbYB2dB2GzPkEL9JVjaTI xfJsy3V3JNNQ3xs+kTPAmSMvsuSt4pU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Xvr+Xqxm; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712951510; a=rsa-sha256; cv=none; b=u8L6jWtkQ22lu/6MRaDk1etPw3hp/PB3pYR3l6gMBTpc+qhWtk4UPZ+ZUNRoWw3UbhvzXy r/Dce/kiaNnROvg9cCnQoxWxHOBirS8Zo0Bpt8hljxSWT9kKlz9P8pIQx81xkP8w/by5wf 7PiWUqcXmJ/EFRdSGh0zKRVd9jD2lfk= 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=Tnq6NiUN07vNOZ2QsHlIu5rppou5nXdPST7AYt/sXEQ=; b=Xvr+XqxmjcVkFr0sNpLDvo8/UH 0Z43DaB9CcIRlCdJjgKj8NIX8u5VNdBIyKSxS7x7sIG924A9Km5+eTJL3iZnK3fHGbjo1d6f3QAgd yfg2DbAsMLrSg+m7DTv8gxcyjKRIFt86HrgE/EIyBAFUziMDXwk2CCIm0n2AQf9/d8WiAgKo+tOAs gyr2mEweOVyJRWeDXORhwVdeEMdgyoJncJgSKKBUsGRfWzMXy8F9IFDV/V0wk/TeqJ8//TEy0r8Ph 6D2DUsawylOAp16MgG98JmUt9x6R/n8/ipWEX3USUS7AYxsqWOEkffLdALEXJSsJTqfGyImxRYjMh Vxof/R/w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9g-2m9G; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu , Oscar Salvador Subject: [PATCH v3 02/11] mm/memory-failure: Pass addr to __add_to_kill() Date: Fri, 12 Apr 2024 20:34:59 +0100 Message-ID: <20240412193510.2356957-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 5xpjdfsp1er4cxk9uwaxz4o84zqnjc5e X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 39E7DA0018 X-HE-Tag: 1712951510-706407 X-HE-Meta: U2FsdGVkX1+Rvdb8oIWa4BbBUobChqILPb+81tVFUtC8EmlAhZ+a3zGnjENWBbEQb43d9xRpmmfO4A6vbbzp5D+Vcru/5U2F619MDOD4ks5XIB914PYr05Ak5I6CeViB3oFFkRSkWH6sO8jEcZIq9g3WWrORl+LdygV1LNqhwz8vVyl/VH/QLbXf4vniKSHvHBDYjXsTzWHYRq7XPwgOJucjRpsKwnuVcR9i7vPr5vx4H+qGqoAg7nmc5i/GZbT1/Zr8YUZgaS5bwLk2HX1rMrFSYxWi1gEcI1UsEku27EXp9Kc+OI1TOeskP2xX+PRHbVbuFcf5PqYCe2qdDNGSDs23qvZrmgGwTlCZc0FuqU1n4r55Vu9MLHihin67f6jJhFHYfk3jy1P3MIBFcP9YbtSj9NjcvUG+Y3fZ2JKguceIbKXSPumYs/NHE4IBq7Vn114gnueGO/3hlXfcFV+yW6YkHqkYxsRMAZmijyDZf37diwSI/AWr/i5YCaWaM251zRu2IW3GdZprO4J373ozNvJFMiIkjptgVMlnwo/OLJyBohMndFFD3qm7md73S/MxUkTa6HBl2MrqZb7MVU6FsJbRfki67h8+j49J73jhzXbG0QOEDhVNFOyD5QU4JUNGQW3mpUQ1RRu+fJ2QRLeeJUD5rtpredTXHQLAZuLkFGMwfj9i3WbTKcSXh0kuxcV/h3460y6VpH4Nfu9B6RprF/jaV9x7o2XT9l03rrmYh7n8HDh4Pn0v0MN2hM2WDh3ipDMP46Tc2zY4a7IT8HhY0FWFxvFWcd6P4gdm1cqdTy7JecJDww29ptec4hDJkalfO75EfHpQIlPjLtLtSRTnQiAXrrpOCkiZ1nOsLm1vsZiNEANAbTMSmrQSbuYOg/rQZWux/jtcccRI+ZIhEv1lPmgk8Wvxy3j1UwRvDmLf1aphx0ZZp/sdjLXtTMND+JoPRvqmeh2iBwypAI13G99 XnNiUhcI O5A0uAgadNhiNZif01ghMeZqyUBfMwrnx9GJW0JKEaue2ldDx7/WjH6OUJ4uSRpWYYF0awOGf/TgzwjLXuZu/X5mlQwJVxlAAADwwz2sc4yRCeutYTDj+PAUa9El6u7G1a4OFcY5l4AFv7EJngupOq/buB0AzwzJpt7ZTubN/OTce5rrsR2tKFWrCJzIc0TybZ8OZoXjR8llzUvQoEhbCugQjRxuFaxPOFyXLoOSLobbGXbB6Kr/z0xXkKj1Btj/1bHR4NOR6JuvI+Ms= 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. Acked-by: Miaohe Lin Reviewed-by: Jane Chu Reviewed-by: Oscar Salvador Signed-off-by: Matthew Wilcox (Oracle) --- 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 8adf233837bf..aec407788df1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -437,7 +437,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 @@ -470,7 +470,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 @@ -486,6 +487,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 Fri Apr 12 19:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628287 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 82CC1C00A94 for ; Fri, 12 Apr 2024 19:35:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A57C6B0099; Fri, 12 Apr 2024 15:35:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 007F36B009A; Fri, 12 Apr 2024 15:35:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9A506B009B; Fri, 12 Apr 2024 15:35:28 -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 BB38D6B0099 for ; Fri, 12 Apr 2024 15:35:28 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7838780FF9 for ; Fri, 12 Apr 2024 19:35:28 +0000 (UTC) X-FDA: 82001883936.16.A74ABE3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id BFD81100026 for ; Fri, 12 Apr 2024 19:35:26 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kaneDGkb; spf=none (imf05.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=1712950527; 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=K/R2o/PdWyzoA0RtTM1GHfRpuHZB2/ueGisS2u+9KKs=; b=O3pRWaf+jKpzZzaHWmBM5D2te0bk9WGdgNxtUltOBf8S5AwlR7egOgXoGeEuAG2BjAWlWX o+LjqxBgcBvczD1IX/8uoGFc4ks9AHCMsCZsNSiIiDjOxMPUq5DgPkdOciZE0Gn/S+p3AI S8aLOtjbrDCewDSsnQgIEE5w2mlJKwk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712950527; a=rsa-sha256; cv=none; b=P8nj/sCdjwPg0ws3/6duq5gNJWGw59AaA9pUOxzE5IBsvBWLJ/LMYWumyM/hJ/cfB2A3Z5 eoBME10skAa1YuIBn0Eliuk7Ca5+DoJiUGTevipBWL6dprmECSyBLwlbiTf65ocgGyC1oK 6J2/tm4le2euWT6tX1HvZCPJpGqCbI8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kaneDGkb; spf=none (imf05.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=K/R2o/PdWyzoA0RtTM1GHfRpuHZB2/ueGisS2u+9KKs=; b=kaneDGkbKKrpBXaqt0qM1rZmTr F0Tsbl+v3EmHU6ojlD9nXGSdGFdWDQ38ZgSVtq4X/pxsoZMDbfgkXqR8ifOyNmTFazlSvfc+Spc4i Le9qoaSEpv4JSzQ9P9OnwUGbTaIQY2oBWElaM6CTxhb0nLfOUXE59nHjHvyla4JUhpQf73aUrG0Fy Ld4DOqu1X6LNvOODxziA0b2jatqyRBAC5g81+jSo00SG9q9D8WPP+rCTludKXnnmCM1HPNKA0rjrp tBkkX5P85Cx3BJb/DLOkbnCnzM+TTTMGdsAafmtC+aVRP1UeGtY2ynirlyQgyWDxYIkXU7xt8EgBu LriXXy0Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9i-386h; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 03/11] mm: Return the address from page_mapped_in_vma() Date: Fri, 12 Apr 2024 20:35:00 +0100 Message-ID: <20240412193510.2356957-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BFD81100026 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7g5pgecufyeseozaefwaxcnugehgo877 X-HE-Tag: 1712950526-262765 X-HE-Meta: U2FsdGVkX1+Kw8p9B9lLruzMp70Il3Z+GTiU8BKLBEhldVyz3PMva6Nm8wOzy11rpdSRa33VGfk225fimFFJGZ9ZZPQSKha20/Razh6MyGpSkhLqNDtSZRFROACxPU9HO+uSCUeMWJ4aaDHtIU5BbLECoNyQ1wV+8h42J7flg/ZvaV+czkadYYoAO3Q/cVTn0GNUB8LdpfofnDedX63r9UCcTr+tVFc+POlZPyOFiD/6xrdx41HwmZ3JpRsD1HKuVYnC+4bhNNqsafMXz2qDiZZgGbPyKwZMQGV1tGuuR+MXsi/YRpSHqcm5J90VY1ZW4u6d0JEGCmb6Hcg+Gytrd9zxMUmvzoxq1zg165V0JIpInNoEecy/H9tqqf5N/rP9pY1AURPmCe5C9sEsaqlvP0my3pn2ZverZvBHuKFzytcCGcFu4LwD62KRKwWlsv25Ejfk3LDhLKTj7NKrcVZ8/UZvB5bRI19T0quNW18FblnYNZJYjqdjWdWY8FhLqL5z/4vp32o1W6sqvVnaOoLAoy0dPPzFrixryNqKdrm+F0EE1sp/kz4U5ktOVWizeAsrcp8+KZgknia+pyrsA/D1NYXM728pqnOSDeuqcruVyiphmH6AWUxYiriGfO3uktCLG7ncd7ihirRJsfECyUhMnWBzWj5HXGkkF7MZSh3QzosahQDtG5qFkMVqa8OfGVfjQ8eE9MGfyOoTkU+Q4mQM6r445U3PGoOpT6oPv6UcdWheey1hlhzLjc1ESUAKZdkBIlr5BeVTRbFLQ0PTWkIPXgBZMIosfoDOcaioXDB18n3H6LzEyHLA/yEX8adjiwjnQvdn94xkGTyt5KQrIzjS0M+VpNFmHjiZyFwtUqHTitffUVzJKAp7Bh0nWqE9R21gVltaIFe4IA+dZUFF6oiyCWK5tcOx/nrEpb0J5z//QGg= 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 Reviewed-by: Jane Chu Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/rmap.h | 2 +- mm/memory-failure.c | 22 +++++++++++++--------- mm/page_vma_mapped.c | 16 +++++++++------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 0f906dc6d280..7229b9baf20d 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -730,7 +730,7 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff, void remove_migration_ptes(struct folio *src, struct folio *dst, bool locked); -int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); +unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); /* * rmap_walk_control: To control rmap traversing for specific needs diff --git a/mm/memory-failure.c b/mm/memory-failure.c index aec407788df1..0ad6b8936512 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -467,10 +467,11 @@ static void __add_to_kill(struct task_struct *tsk, struct page *p, } static void add_to_kill_anon_file(struct task_struct *tsk, struct page *p, - struct vm_area_struct *vma, - struct list_head *to_kill) + struct vm_area_struct *vma, struct list_head *to_kill, + unsigned long addr) { - unsigned long addr = page_address_in_vma(p, vma); + if (addr == -EFAULT) + return; __add_to_kill(tsk, p, vma, to_kill, addr); } @@ -595,7 +596,6 @@ struct task_struct *task_early_kill(struct task_struct *tsk, int force_early) static void collect_procs_anon(struct folio *folio, struct page *page, struct list_head *to_kill, int force_early) { - struct vm_area_struct *vma; struct task_struct *tsk; struct anon_vma *av; pgoff_t pgoff; @@ -607,8 +607,10 @@ static void collect_procs_anon(struct folio *folio, struct page *page, pgoff = page_to_pgoff(page); rcu_read_lock(); for_each_process(tsk) { + struct vm_area_struct *vma; struct anon_vma_chain *vmac; struct task_struct *t = task_early_kill(tsk, force_early); + unsigned long addr; if (!t) continue; @@ -617,9 +619,8 @@ static void collect_procs_anon(struct folio *folio, struct page *page, vma = vmac->vma; if (vma->vm_mm != t->mm) continue; - if (!page_mapped_in_vma(page, vma)) - continue; - add_to_kill_anon_file(t, page, vma, to_kill); + addr = page_mapped_in_vma(page, vma); + add_to_kill_anon_file(t, page, vma, to_kill, addr); } } rcu_read_unlock(); @@ -642,6 +643,7 @@ static void collect_procs_file(struct folio *folio, struct page *page, pgoff = page_to_pgoff(page); for_each_process(tsk) { struct task_struct *t = task_early_kill(tsk, force_early); + unsigned long addr; if (!t) continue; @@ -654,8 +656,10 @@ static void collect_procs_file(struct folio *folio, struct page *page, * Assume applications who requested early kill want * to be informed of all such data corruptions. */ - if (vma->vm_mm == t->mm) - add_to_kill_anon_file(t, page, vma, to_kill); + if (vma->vm_mm != t->mm) + continue; + addr = page_address_in_vma(page, vma); + add_to_kill_anon_file(t, page, vma, to_kill, addr); } } rcu_read_unlock(); diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 53b8868ede61..c202eab84936 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -319,11 +319,12 @@ 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) +unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) { struct folio *folio = page_folio(page); pgoff_t pgoff = folio->index + folio_page_idx(folio, page); @@ -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 Fri Apr 12 19:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628282 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 55818C4345F for ; Fri, 12 Apr 2024 19:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC3606B0089; Fri, 12 Apr 2024 15:35:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4C66B0093; Fri, 12 Apr 2024 15:35:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C61E16B0095; Fri, 12 Apr 2024 15:35:21 -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 A91096B0089 for ; Fri, 12 Apr 2024 15:35:21 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3FC66140FB3 for ; Fri, 12 Apr 2024 19:35:21 +0000 (UTC) X-FDA: 82001883642.23.39D0109 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id B478D140006 for ; Fri, 12 Apr 2024 19:35:17 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="fwfK400/"; dmarc=none; spf=none (imf23.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=1712950518; 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=1gUCvVAtEuP4CKYwW2PHVHPr98dBMUXSl8OG3JHsctY=; b=jIeDaGb13oiV2vgrfYYXiSmd/qa7NUx4MlH3jBbSuOqWc/NBORxeblpjYm3kt5y+jItp+8 ikvtHZsUXNLj7A2lT2rWXyvwFsCjX3j/+P+LGI2M1k2et1QPpIld3oPEh7juNJ28bHWgmd lfVxscV1dQt8JifOPv2ajXScxlKlyVQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="fwfK400/"; dmarc=none; spf=none (imf23.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=1712950518; a=rsa-sha256; cv=none; b=cFFDsyZusK7ZR5tr6tTh5AiF5WZ8PYdla8VwzmRDcnyW0BnbB5H6GF2+x9yHc6ABjL4Erd dRMbLsjBfPZKN5iJeMGt0hKeVe/ZdkQj1Fw3Z6UUaH8jNO4sAHzbfD8GxmReuQjQgYEHkN cWZkE+7mqpOkcgpgkrsM83uIZa51QUQ= 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=1gUCvVAtEuP4CKYwW2PHVHPr98dBMUXSl8OG3JHsctY=; b=fwfK400/YPdrGv4E78orJUbi77 tEEwpbjov876H/Z45KVTJ+GWdoM9M7wRf1pRTA3vRRQexrou6wnW4Y25lmj1QowZx4HWFMcknf7Mb sNbMX7fjpXiuHs9mzUw9JiS+05RD/r/ziY5XouEYcPGL02A/aN/aBWmaHCthHyM/9tpDRgrFe9+dy jM1x3J9iXr1ZMo/9wMR4IDzhDw5ga4AbjpD1P+8BlKL3nS0bZC1W3Pv18Sb2waLTnnmRMyECq7Ad6 k+6DgEOGvkTDmA1vKLdFVCTb4aGBbxTK8o+jz5TvJvJBn4WoW17GKHKX/bg2r5EnQYbAaJobeY/Bu pvsBBv2w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9k-3UAW; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu , Oscar Salvador Subject: [PATCH v3 04/11] mm: Make page_mapped_in_vma conditional on CONFIG_MEMORY_FAILURE Date: Fri, 12 Apr 2024 20:35:01 +0100 Message-ID: <20240412193510.2356957-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B478D140006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: s3ngzphko1b186sawrnxbourrq4bee48 X-HE-Tag: 1712950517-114541 X-HE-Meta: U2FsdGVkX19sMsUA3KuPT/tT9PXrZKWwFslaxfL/gyM1ugRPeHBTA0ohbaujo6AR0xd772CkLki0f635P30m3RJwQ46my+VFUuwH4ALNWtY78rhsSzk3OdVWqSKNYLfEJFe9ej0rScKM0rNs8+XSrJdH6DHhH9aIvKbY3AJETXSCNwuQW4No/lUCU6Q30VE6dN69+9dGSwpTZz09+h/5qKT21RBc7uDQWpVKmDaQAQScCyq8FqTjIc9bGfaCfEWDi6KOA954P90o1cAqN+W+ghHp5DMER4YPqoq0pWZY1J3RunUJp/lx23iFGq8qmDbfIQfXCPQeyLBDNUqNZeNczjz7pd7OqgYSWZ5BySaWREpnun40smTdAsd/xxgfsF0yTi3PqOfH6iXKiU2+vz3gh769e90CYYzwQ6kdUI+hmO5AHofZLYnmhRQkT26EI9L2clkids6+nNLCm5B4Oi97xsOXTxmsjddYLNZo7OS2sJxWseDeob98KIDg2tRSNOUgy+ZewCqXAfzfQ0upfmmy8vsyT2taiDrMmZ/8ikPLvVXvBBsj9fzBLxKjoXTeJHb1B/J3niZcHwuJP5NjHZCYc1A9drdiDMyTtNdW33oqyMTkIGUkwS8JGj0EBdsH21VBHWBPP9CNqbm/YInBwMFhbrbgmYRZbmlee6wJa5EfZFHhMx+AB5NvnO94nb5nSUMCEFAOExW0mO8uUmHfilfRsQQj5NA0zdYah2egv+9c7XyhDGc1/wQlpQ0W7EMPFSwYN55XNTJ6oa1h1OYMAeq9iuOKXmXUIaI4TqQVS2K0eBBbLN/9UEnt4TbD2wLt6ZdnH3jypiDPICngk2JFtvfJo6JuyodFUjPcKOFRLBcR/b+MmWc+ppvwuSo5iu+dvc8QdsJ4VZQ/oqOn5n5QsTwKYOOeCUlJKq2s 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 Reviewed-by: Jane Chu Reviewed-by: Oscar Salvador Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Miaohe Lin --- 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 c202eab84936..ae5cc42aa208 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 @@ unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) out: return pvmw.address; } +#endif From patchwork Fri Apr 12 19:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85F2AC04FF9 for ; Fri, 12 Apr 2024 19:51:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 035D66B0093; Fri, 12 Apr 2024 15:51:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F28346B0095; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEF1C6B0096; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C45EA6B0093 for ; Fri, 12 Apr 2024 15:51:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09BEF160FCD for ; Fri, 12 Apr 2024 19:51:48 +0000 (UTC) X-FDA: 82001925096.06.31D6B7B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 75023A0002 for ; Fri, 12 Apr 2024 19:51:46 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="S/miWtBW"; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712951506; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8Ln0/nXireti6Gj7qeC9fC25WVtajNsvaFQsbqX+KPU=; b=etj32qQ2KA8U3fkzzmLBlxJVrpUNwLsdL/N0XXwuLGM2L5NPITfmq1nu+C/96yLGYup3eS 59fIkS39jSjJDR9ZmxqtelgP05x99aTJ0LfyZhuKbG0mj6blLhDuWqZT+6mbvdTCLZ1QIx YWp/sNW9tyE980eGUwoFJafpBrCD+wE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="S/miWtBW"; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712951506; a=rsa-sha256; cv=none; b=CVgB9HR8oRhrm5ZC9QCzU1fibI25pCtBQwH4RYD8WtobloJitGa4oVCa6PD6DjgSBep7Nw lKzxcqZ9bo92emFOBfXptgECZa2K7PjNkNesvq7FQSsa+6f0GRQrpIaEkqisxfm3uvZLmU XgXV+cWI0xVsjgiBY+jxYychdyHugQ4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8Ln0/nXireti6Gj7qeC9fC25WVtajNsvaFQsbqX+KPU=; b=S/miWtBWeWh9FzevUmvg8wVUJw viOKqiV+uq0WzXu++HL8bLQ5Eq+sX35qPxa4ncRm03v28+vj/ABCjL7e1SYN8Q3lbduKRQyD6cGKm 9JesGhr17Hn/ZBwv9Pw8YvzQSD12dR1gOXk3cjVL6dMrJuqOeEugSn/DXvE7lCdxiTO5jI76UNGAb kvc1ygXfLOJIM56oMOZ0wurs7SVBA2pFV6SpYvEbqUm4wHBuVZjecPbw++drYnF9S7/yydMviU6K/ tDaZceK36V+MoJUmnLHMtTYEzcm81CuShS52qrdB6/MT04Iout3w7cQhJV4VQ4H0iU80z1bc5u4iC 7BnQoCkA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9m-3s05; Fri, 12 Apr 2024 19:35:11 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 05/11] mm/memory-failure: Convert shake_page() to shake_folio() Date: Fri, 12 Apr 2024 20:35:02 +0100 Message-ID: <20240412193510.2356957-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: jwfnj4juic7bt36ndbqf3ocwreg3yktu X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 75023A0002 X-HE-Tag: 1712951506-134691 X-HE-Meta: U2FsdGVkX18X1ww0ObS/f5YGtnUxhcW32dM0cEFkMiEgfAJiczQnfqI1u1lUn8C1Fw3NuLZV7aIrWxdpQ/Y8onzYbmxYWnkweiCn4oPGb06GW2WSYgLVuyqI15VXvpD1DDmJFVe2eIUjpTsIrTx+K6m0gzjg1ETZm4eb65p/gx8VqealYRvofCAvFSzt5q0rXW6bxbPpLXumGD6d13EwpCB7jbSFz3Ku4C0vYLLxQhbJIdv9Px+vcXWUw6VaUHryU3LeFjxtuyIb3EGIyxdE2RnUMriyYQ1x+PfWIe2GrvGgwqKc2MciBMAHjCG57tYl5JNRGTFeZrC84M5LlF3sGK4cYbTkx+9xq8a7iCEbiQn+j7lKwbnRflJYfDggHiP/mhd8yakHf3LiLBvah76cJXCGQWl3uen5tjWErLCKa2LUkSvr+RgaumPQW3pgRsVKYKfzoE5/EfOeZ7mEnG7nlrCYM53SofW6BLudHJASthC8Lm6vH9jq7OxXBvXBg1/q8Ocb+Lmab2KiXvFO0OBNzsNZtFi077fPgQbskEu1JpV5M3p+crJbTHUC9XD21FAocwSEmsc0eGhq05evCWwCwFKIcW3+MV50QhyDO6d2pv+Tyb0UY/RYRE7Kw70RxBi7jM1TY9+YR3z8u8vkGsS+Ehfys1gGe1Kp9LrwcE+qNcdO4cQ4s0z94jWCZNU56DzkSXRgPSpiiDZOjWCk9FwpnEpWKxnW5VhRn6IaFa0Rt7dP9c2Ttdxoe9FSvfCKBK4Qt+Kl392rfD3ZWA9Wh4REIbsTDom2vbAOcvjQXqmCn4pjGXa+Ky+0K8TdUfbOyAqPaJ2q2TKVCVKek3o0q7jojh02kwWR4F6sgDFYiUED3d3Ai5/MPn6JR7QEKaYGLWFQiN464lONAMBgwIp2Kj6Ffgazv2K/HQY2qVNDBGQKPFLWnIUMc6A8MVsZMGMAFwHWAq767P+YzKWszHAwZFD alh56R+j 30YEdAD9DclreHoG/FfUwrgmjosWDWqtvnZ8xaZX63JTSo8u4NojvawPU16TWRGabJKdVaJkjGKaJNPXJP9qD8HvVkWYCAk1DHvXaHrto9TqwvXazoo48+QlJUxWp/+I14AZP5ETTw8BPfzwFM+vzAZRvk2/9mou5BOM6yQb/G4eHso/Ce1c01QdAocxQzoEd05asdDBbRJ+OjGoYreg3hJQAnwpzVGaXYezJaClmBrNhDA4NQSFCvSMZXzOcCXMXAsDG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Removes two calls to compound_head(). Move the prototype to internal.h; we definitely don't want code outside mm using it. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu Acked-by: Miaohe Lin --- include/linux/mm.h | 1 - mm/hwpoison-inject.c | 11 ++++++----- mm/internal.h | 1 + mm/memory-failure.c | 15 ++++++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 326a4ce0cff8..b636504c176e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4028,7 +4028,6 @@ int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -extern void shake_page(struct page *p); extern atomic_long_t num_poisoned_pages __read_mostly; extern int soft_offline_page(unsigned long pfn, int flags); #ifdef CONFIG_MEMORY_FAILURE diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index d0548e382b6b..c9d653f51e45 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c @@ -15,7 +15,7 @@ static int hwpoison_inject(void *data, u64 val) { unsigned long pfn = val; struct page *p; - struct page *hpage; + struct folio *folio; int err; if (!capable(CAP_SYS_ADMIN)) @@ -25,16 +25,17 @@ static int hwpoison_inject(void *data, u64 val) return -ENXIO; p = pfn_to_page(pfn); - hpage = compound_head(p); + folio = page_folio(p); if (!hwpoison_filter_enable) goto inject; - shake_page(hpage); + shake_folio(folio); /* * This implies unable to support non-LRU pages except free page. */ - if (!PageLRU(hpage) && !PageHuge(p) && !is_free_buddy_page(p)) + if (!folio_test_lru(folio) && !folio_test_hugetlb(folio) && + !is_free_buddy_page(p)) return 0; /* @@ -42,7 +43,7 @@ static int hwpoison_inject(void *data, u64 val) * the targeted owner (or on a free page). * memory_failure() will redo the check reliably inside page lock. */ - err = hwpoison_filter(hpage); + err = hwpoison_filter(&folio->page); if (err) return 0; diff --git a/mm/internal.h b/mm/internal.h index ab8fcdeaf6eb..b20c736e05f2 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1044,6 +1044,7 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask) /* * mm/memory-failure.c */ +void shake_folio(struct folio *folio); extern int hwpoison_filter(struct page *p); extern u32 hwpoison_filter_dev_major; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0ad6b8936512..bf9da2b46426 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -363,20 +363,25 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags) * Unknown page type encountered. Try to check whether it can turn PageLRU by * lru_add_drain_all. */ -void shake_page(struct page *p) +void shake_folio(struct folio *folio) { - if (PageHuge(p)) + if (folio_test_hugetlb(folio)) return; /* * TODO: Could shrink slab caches here if a lightweight range-based * shrinker will be available. */ - if (PageSlab(p)) + if (folio_test_slab(folio)) return; lru_add_drain_all(); } -EXPORT_SYMBOL_GPL(shake_page); +EXPORT_SYMBOL_GPL(shake_folio); + +static void shake_page(struct page *page) +{ + shake_folio(page_folio(page)); +} static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, unsigned long address) @@ -1633,7 +1638,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * shake_page() again to ensure that it's flushed. */ if (mlocked) - shake_page(hpage); + shake_folio(folio); /* * Now that the dirty bit has been propagated to the From patchwork Fri Apr 12 19:35:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628292 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 5C78EC4345F for ; Fri, 12 Apr 2024 19:51:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65C66B0092; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E15736B0093; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDC686B0095; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B223F6B0092 for ; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 39B3680FF9 for ; Fri, 12 Apr 2024 19:51:46 +0000 (UTC) X-FDA: 82001925012.12.31A9B17 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 8FCA3A0002 for ; Fri, 12 Apr 2024 19:51:44 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PNxAq5Mv; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712951504; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5zr8LOSgGt0Q2WtuiahmLM3vS/KNbcf3FZTCnvUcXd4=; b=gBh6NBKugwWnzLNkT2liujJQQai7bzdxh/Dn/e74W8n/y2t24fa00aHbHhHKWLQnblDkp4 l9StlZsL9+YWF+WU6S8/WS2HNGDboGAb35AVLWVGcLaeZ7+WOyZsQcGTd2jZ8gkZB27uJS v2ivC7uuelpsSpNOjCxMqVRCbM6KB0A= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PNxAq5Mv; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712951504; a=rsa-sha256; cv=none; b=E5iPR5VU/DVT7gMV6RxMfW9QoIk+F0wm4sh5YQh/Yz0d8ndhm+4RXO2GE40vEBxM92sKc4 M+CRtW1hcRaDAFi30YUn79MLwei88pLWDwHh2qoGYQBYa2a01DtozyFuJ2y36A4HhDrdxx Pyek9pTsP3Kyum1p52RX6tOZriY/8eU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=5zr8LOSgGt0Q2WtuiahmLM3vS/KNbcf3FZTCnvUcXd4=; b=PNxAq5Mve0YRpg29kn/T9wTwDO 1pbW1J/Mj+1B1Wj5z8O4Muc5lGHv8d++7YcRafh8umOlo8NdacQ3/5Zb7cOL7GcOVxzYsFS9Appcc g446hiW6iDHfcJxIrH7jK15aElXYpSw+333gV55Vt1MY+cenL89tPf/0ECVi1AG/9FujLjwkehRbK 9YdtS64d9qgnQ86l4ZB4T1wVbCdN6XzY8x1/NfXQ1hlcFgx3qHGH4xcKNY5As2e6D2uhcDrj+AcPc BdPDC05CI3BMy+QB+0i3kPmK/S2kdF2PTv6M3NifbW22o970G6/k+QG9NDTOaHVGC2tOwAVAJAXJ/ vI31Ddbg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9o-4Buz; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, =?utf-8?q?Jane_Chu=C2=A0?= , Oscar Salvador Subject: [PATCH v3 06/11] mm: Convert hugetlb_page_mapping_lock_write to folio Date: Fri, 12 Apr 2024 20:35:03 +0100 Message-ID: <20240412193510.2356957-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 118e1c4ezzguguxte3oii9ddh19gj7or X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8FCA3A0002 X-HE-Tag: 1712951504-700219 X-HE-Meta: U2FsdGVkX19VsAp209wKx5tY+NHxbREg29g8kyuGMyNw/Aiv454Nl/5k/3vLVNBM3SrcQhuVh+QtOB4EMLbrMa13A89cvaJWxm/77w0dwiC3LoZ/5t/5r5PZ4aJ+6VygV9Y8xin5xNCmAylKeQIMbM9ZN/LdLqM5ZtfkH+QV0hSchglnigvuxoNxIM0wMuPzRf4jpev9RGFVXZt/Fj2ftVMMx7im4xmUHN0PXUhv/711Yh4/z0h8PcIDXNv3tGLRVeQkWs1oF2Velcv50XJS27aM4L9u8L52POGPMByiWm3L7ejz6auuIE4b9RMMsLbeuAKJaZtg3uAEqsO7SSgSiXUJQwcuBOysv/1ofDWRWJF5YXZXuh1tvBG7LYTggEQ1vrP3/skrA+ue31zwrXUd9229EUL3qKp4272rORkKQlkPxkX8Z9bKiclQTVpPiF4hA57ZldUrLPwNTRApGjDv07wqSOCuMi27BpIK3ORdne0T1UvAK9R37kkeFHkuHnX2mdi5Y3VQ9wOUNvWC/Czia39aCLIFAjNOYF6M6T9tfCMuIMlF5NWDIkWMVHdySYEte699yhwIUy7rz+RBtrkCKgbAEXO1EyOF52++xSUGIXWZVrBiWBaoHL/M4UHlGXC7owBkM+MhCEzXphchoRDWDDMNt0zKGgr1ytolsYGmKSARPdTKtVOHyV+58tzpGcOVMJZTwGyEr7HVxDyGkN/OxeI6P6AmKTvRym6mlMnI5Y7j8G7N7oxt5CkQdOquCvIh8/uCxao0ObcdsPbjPO8maDPiViQKhpnJfrgcGAq6YXIB9kbjFB8Sm7BG7KPyLLQRT54wFEgRLtw5KbBApg0UictlsL61rWxeHlDMOarhFJj/nEk4l/cDCCI4D8le0+NpUG2lFBtM6F05riodUXfvC4X2DzAUDilMI5oHkmQPJgg9MGCIg6+GDlrO7E1U+soPVUviKZxzrsf7P0i3H05 zNAx5+Pz 7LYFA0P5zg96vCLyxokRJpJOuRZymr8MRVFsIP/HrrKiQi6l4V2uGIceor6R4j/Byj3q9c94s4ujdfozy46E/b106yz/bzNubJ/Qy0xnfSviY3AwKZYQMpqRPNlmXsL3mTovEl5M2D5TcVF0KPcjnd6NvCM/hmWkwtUBjH7pq4ZJv5PVENvvPLWjvwucsU/1q47+Jkw7s22WuVSYny8q2Qc3SFgZ2SA5A2DKJyj0HzTQMgRkaPcqpholq7PLXKwpDdj3zkvMOUGjTJWzLIOktkzdJ6/Z2tXtWThnVqiUN8qtLbDP+R5rjaEzyPg== 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(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu  Reviewed-by: Oscar Salvador Acked-by: Miaohe Lin --- 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 8c97ac48ae6d..aaa11eeb939d 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 a8536349de13..001016993cca 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 bf9da2b46426..52feaa9de9b4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1618,7 +1618,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 d87ce32645d4..fb0c83438fa8 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 Fri Apr 12 19:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628283 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 BD728C04FF9 for ; Fri, 12 Apr 2024 19:35:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C5DC6B0095; Fri, 12 Apr 2024 15:35:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 313B16B0096; Fri, 12 Apr 2024 15:35:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18D066B0098; Fri, 12 Apr 2024 15:35:22 -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 E52996B0095 for ; Fri, 12 Apr 2024 15:35:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B418EA1B80 for ; Fri, 12 Apr 2024 19:35:21 +0000 (UTC) X-FDA: 82001883642.09.F345EF5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 78F7A180018 for ; Fri, 12 Apr 2024 19:35:18 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cow5mePQ; 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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712950518; 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=FFGXNTBBagGzWfpmBcZ/z9lP6hkxmXG0SQeH9eRIjBE=; b=LKqcikznkcbpSz+Ra7HRPYHcH0t6NbQqkQM6QsS9mB2Kx0W/P71a5iD/EER/b/haU3dJvo yl2K7r2XAZWmfBOjQhRH4+0+p/aBg3IHbYJxJRfYBUYLULAgRzqtvO7P5Z9EcM5O4HapHW uaooRrTmm495BREoFN294to9iZvB0i8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712950518; a=rsa-sha256; cv=none; b=Wo4u9w/wle/3rutQ8sjY+IXxyJakDfAcieyWNg6HRC12wNgbqcHdWx97N4OlOuQ1UD9Hcw WBTIPvhuQodFu/Hm+S6YlVIz8pcKFn3UcRrWNx3igB4QrDBnq81aNujIq0Ve+B0x3/vF1R 6y5uZy92+GyIbZ0E87du3IiVf7Rbfao= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cow5mePQ; 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; 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=FFGXNTBBagGzWfpmBcZ/z9lP6hkxmXG0SQeH9eRIjBE=; b=cow5mePQuOdv5dM2sOWOspFXVk LYAKpbnU4BDicGdOSh20irRXwDImImuLgqzVJsZn9h3894oeK9YKZ+4QqM3hLsv3E0mDyOFj4Hf8h S61pfX7VStAExMNIEXCGOv30KE2mVJ7PP0q+bwvuFOR5osPxPmLYMsB7bUt97m2gLP0BAgpDGxGtE rnoKhJLNFtBWZoyegpMA0HRM53HWuY1cFoTbJwaJSWR/K40hK0reaOKxJkCff+zv3DEk5cVAQhkmv sgNpgJRGA7X+Mni4Zd8IWRaeuQakWykWliLpKgOQVdux1FzK+XTWGP55SdyHXtpQr+5tx0rR2IGpf U9EQRZ8w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg4-00000009t9q-0KxR; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v3 07/11] mm/memory-failure: Convert memory_failure() to use a folio Date: Fri, 12 Apr 2024 20:35:04 +0100 Message-ID: <20240412193510.2356957-8-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 78F7A180018 X-Rspam-User: X-Stat-Signature: f41s71637grms76asst1rmmr8cyjkipe X-Rspamd-Server: rspam03 X-HE-Tag: 1712950518-501801 X-HE-Meta: U2FsdGVkX1/TbZVqokmXJQT0KG6gWT3ZFwZzmFfHBzReGKsFmaEna97RkwgAbvoka+ngbVd2xsZLxLNH/iFAARmVW8cbFMWM8oV/j2hOJRLV4X3G0cQ7ReUd0Nb+0hylRB585zCIRfQ17sdF/n3ts4zjcqXfsasdwK2MsSRcNbqP+/NM7MtBwbr9my3FeZnanZwMQwG1GqZvuyA25YiFccZZrpzaiVMhOwrLDaJF9em+lKnTuBhNeOZxs9GelVcimL9i6ep/evPFxS3Sbs2f9yQ8Ctl+DoApTBb5iB+SX1Jz3NwfdPcIyNUul4qGoNSc69Nmr6S/bHp1rR07p/jK0a7D0b7tUebflNiD6F7PUyeL8ZDgPBm6x52lnJcOLMRDcQe0FeDfZ98dsqgYk1gbgERgDPSkuDx/g9BwjQ1hFuRvoR3fyEawqyBDZqGAr2PVwVwGXWFoYmW6C+Z2Vo/Mo4x+PIIryVWXp0nqm00YeS7nxw5zDoefXQ9Z5LBU069QGLr8mdkreJugTolNNulz8FS1jQSyXPm5Sg3aRAeT/1CzTNC/g0JJdYWxQKsdBgzF+EWt+Q4AkpyRVqCT4k3VFYyUOKJFyNoWW+RPKxmg2w+rNtuV7PubewgHGX0ibq4tZufYAp6rFrTwnNxx6JiTvvsslGP9Wr61xQGdReMoEdLWdXEgeSnZdx4pIIcza16l+KvidszSW1QWZQhov7y6cNiqjBPvKVBm9cZtfxvwpa3CK/MLQKTIk7xuAUMPSZRpGTheSanla+P+YkvSUcIcX/O9WaOZGABLc7i34/kGw9p0/PJXQ9gHBfYgaBfYL9CP5UkIRfKlug48t62bpUrFB9mZwJAa31wxbqi7NOXYe8vx+0e7/Ki7yMeIE0uS2fRSaJwIya6+2v3YT6fxllKKQSJ2dUPeVRSMYfPrcOkucfgI6cVvGlSrIi6kjWHJJgyKkTEFGUnjsilHlZ52XX3 TCN2e6eq Yz8myBPweZtOX618juxIy+8sJL6d9UnLVpRgTev0ZyCCY/gpOqMB4Rnlwz4KanqYo+iuMZ0E7VfsHK8Wy+Ilh4VqhEHd0KOKdUtnaf97xNMh/fZhEBNWX3utj0ofTa+MDmbDOGbn61PAjBCYSIT43mt4VDLVng4qL12Jelj/ZCWrGcyoZgOCXlD46ZPQzX2pFQvbzoq7oNrM6beuVcm2ZVJug+LY+d9PYA1H8 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) Acked-by: Miaohe Lin --- 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 52feaa9de9b4..2c12bcc9c550 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2183,7 +2183,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; @@ -2271,8 +2271,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. @@ -2286,12 +2286,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); } /* @@ -2302,9 +2303,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. @@ -2312,11 +2313,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; @@ -2332,29 +2333,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. @@ -2368,7 +2369,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; } @@ -2378,7 +2380,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 Fri Apr 12 19:35:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628286 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 1D884C4345F for ; Fri, 12 Apr 2024 19:35:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6B946B0098; Fri, 12 Apr 2024 15:35:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1AD06B0099; Fri, 12 Apr 2024 15:35:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B9F56B009A; Fri, 12 Apr 2024 15:35:26 -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 65CD86B0098 for ; Fri, 12 Apr 2024 15:35:26 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 364E8C0206 for ; Fri, 12 Apr 2024 19:35:26 +0000 (UTC) X-FDA: 82001883852.17.D3416CE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 82C2C10000A for ; Fri, 12 Apr 2024 19:35:24 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eEyQtPt+; dmarc=none; spf=none (imf14.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=1712950524; 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=DI0hgg7M0ok1w+kh42kKZu57KLd8qYkUQd3yT6L4EaQ=; b=KOrTPSO9wBEq0TiP1VQmkv0rbM5Sr7EISFjfkS1SDH09pQNTwE1MRq7eznvGA1FtDtN8BC U9SFd6O29WJQADGB9Aqxj9pXVKQNwGnxqWY7y6yHZ449Jtmrcblz93JmbZFLYn6p1z/1W4 XkPjJldqQIpQ4cyNSCIeZddfYFXbmg8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eEyQtPt+; dmarc=none; spf=none (imf14.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=1712950524; a=rsa-sha256; cv=none; b=KFA8KzIqEwo7+Zaw4QZmqvZ/nGxwMd736sYiKW09szp9tKCMEyU2qDuKbn8rMqYymypDYt Op+mTJGjAc+/hRmj+YMGAnFzyOi/wIl46K8EBnSQRzaeOf/SXPDRfV9ZQDyVwpuZllCEqI 9JU3y20Dcow7OF54sxk35Z9jUtzJMdU= 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=DI0hgg7M0ok1w+kh42kKZu57KLd8qYkUQd3yT6L4EaQ=; b=eEyQtPt+R5x22q7wRru9TRM7oD now8JHnPu+Ph30VG8k8d+TDwV9YW43OvUOjEfXDCUl99JtQXus0yt7HkwhOsWtYZLE2hAGi4BnXzM UurUWwdGem5JJV47mj5fACdBUlAhpXnwN9XgiSHBiANBaOsFA5e7LBzjv8tZ2wZUPlPzzybabo0KU uz6f0YZduxASr5JQ9BtfNm01L3rrvQtCWylqYg8XL02kTcSSoPvH2NU+jQ6QuLV0iq5fakEpn239U eIV2bTX8hVU+d3HqNEpIHb3+k0HHSIuEzjTF2c2bl0sI/jeiq9WkPcF4L6krmhSCdpsMDGRHd67Ei bUR0SYqQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg4-00000009t9s-0h7i; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 08/11] mm/memory-failure: Convert hwpoison_user_mappings to take a folio Date: Fri, 12 Apr 2024 20:35:05 +0100 Message-ID: <20240412193510.2356957-9-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 82C2C10000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 78jx5qkbxd8fyh7g43sgqagzc9j7cpca X-HE-Tag: 1712950524-685736 X-HE-Meta: U2FsdGVkX1/Lhp2q3vbafyZjLUDAQNybNwUv1g90SEg9q2jdjki7e0kzLZFZo4wlqtnjTm1sFyFJFylEd3DCLZMNJjqA3nz+FWGQVt07qVKi0tIh1vrTmNMJwUSLZaFxM0qV2kZ3jmjxmfh5SbXfjrEv3HcYmGlfKASjYSUrmfeUoJuxZZ5co7vpNxAl7J/oYSLQYuJgzGO20Lp3F3rtQYOTigqHY/nJkej+Mf3YYqLA5AaJDhvsEzA4dYF63dabCejHYsdhE30Mq+zj3TTz74SbgMnVw1EcH1vnx8Focp7spcJvjGfXUCKpaPYtMq2UvPcrMj+umVA3s9P47/DOsT6TDEqfO7MjZ+Lh5sOcQm3i1w3+Kp+gTIeykXbRKRMrH4EXDFA4GTBqXeXC67zagJMYuoXNC0V1/eoI60U6dEdaBDJdg13xB5Pr8TJb+PgnvrumkUHg6T2Pn5fIVSZZ0pQqbugG8eBJVpXQkCbbZeX0bmO2di1q2qGbkicMHA2c995XP2Rmrnzm49iI6XASJH0wQb3Urro60y3poHRpu/tSSYbe0LZuLOMThfcXh8DgXFBxYS1FPw9MlNPnMUZiCThRO7NpJ8DY5/HVQukZ5jFbk4IPKDenpk8AoXhT70bHVVVgtDy2UcntuyLpCPTisn/EngNeSOlM+vWsevfc3VhkWIDDFZORmztEoCm5e8OJx5wIFfBUKstjfqhWIN4TQG5WacwVaiGX4aYyG1icNaTCXISyuifvSSf2Biw8ds4L/OYoJzhQZDKwdfTmGeAOo4E3T6woHXlhrHzyvLJSqpQc4XXp9qAlLB8Quym65M2x+PzWKVoROYuvu9/ibUL/SNVeJR5s5fC7yd80E468PLJ0WV5DtGpNy5d30QQLfl4p0vJL4j+ZTotrnIL863T8SBA1wyJdA+OmZ5U20rb/yEobZUgO+Up9U0nVk5PfD9KmcNQ+UyXQeIhhLjiDJqM sl093k+h FbOSlEjjO403LtT8ntbE5U2/64ko4D0dRSW3SDM8IwjKx+tiFq52BGGNfzSTFQSufnxfP+GHumXtAPKZFjQdrvS40aG2WrCq5NRyJ01KnTvTiMIQsbmoiH8C1cijm0IuGIodOz+7Gb+w6ut3LLISV/ZHzXvY7TJ04OrS0soDHtPFaIqbMF/pk84YGQVrLhlPadAAkbSQ+ZITAa2thhCaR9SY8OokP5GJ63IAjiPgWnrszZOYrDzY9wPmUDOSiJWBIa/xIn2qDNuWI/1uKYbrYfHonnQ== 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 Reviewed-by: Jane Chu Signed-off-by: Matthew Wilcox (Oracle) --- 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 2c12bcc9c550..0fcf749682ab 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1553,24 +1553,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; /* @@ -1580,7 +1580,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; } @@ -1591,11 +1591,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", @@ -1610,7 +1610,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 @@ -1650,7 +1650,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); @@ -2094,7 +2094,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); } @@ -2361,7 +2361,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 Fri Apr 12 19:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628291 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 09E73C4345F for ; Fri, 12 Apr 2024 19:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84A6B6B0089; Fri, 12 Apr 2024 15:51:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FAB86B0092; Fri, 12 Apr 2024 15:51:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E9816B0093; Fri, 12 Apr 2024 15:51:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 53A2C6B0089 for ; Fri, 12 Apr 2024 15:51:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 13641A1C61 for ; Fri, 12 Apr 2024 19:51:43 +0000 (UTC) X-FDA: 82001924886.03.B22E343 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 7498E8000A for ; Fri, 12 Apr 2024 19:51:41 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=e0tewlhF; dmarc=none; spf=none (imf30.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=1712951501; 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=IB2XrvAmdyir6mAiFqIplfWy3iAJvoVZcjxvTKJjc/A=; b=gqM1OSktd8gV9VPZkamPa5N5uq/axhaygkeb0c05J/Y1yM7DBnhnKJXeboNYAYPEyoQZXI As4fz6PtBtkaX37ouLZrGYSLgKQ8ePk/phDBrYRD4J/4Ph+iKOQbXEK9QGmI8IjPe/xH1N tN8dh1aIkLg3grnLKaswmT4NZzLqJdI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=e0tewlhF; dmarc=none; spf=none (imf30.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=1712951501; a=rsa-sha256; cv=none; b=cGYLkjI7XojA2/itsi9IT6Kd46qF4hfQFSddWt0wf5EwErVAwChHq3YgeJW9TG23lOJhs6 jIpJ05NVGN4MhsvpFMN5/9fCAO262i64TrbTUaH1d5NgeJrc5r3u2NLXtHbbhFKBgqs++X uKieF2oYCEOw1X6hX5engNLJCvtT3+Q= 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=IB2XrvAmdyir6mAiFqIplfWy3iAJvoVZcjxvTKJjc/A=; b=e0tewlhFqY5h2IsuvBTV4dmgLr XrNSrza6pexf0xEeJm/qiyWzsg8CQtPrgFl4JBlyyY+I4YQU3u3tVPsvFR0qJVQcHaEG2YOiInP7s 5MvDRpqa4KwQcHFRwnoRezgBn1JL1O/oNNX5JrunrPiiNgZezJnniN/gebqKi/b3zWCkPK6c0eUOF 6rGnZEA7iw1PSqIxCy5jck2ud41TstY2CCq4D2Hj6N3qxOcqTvalglPPpiN3fgHSq3ut9p9RmaJ9u NWwgLU2i9LLZBVrGcQwEYWXoickDqExXHXH1m8IbDbQ4YURsgUbc3LHbl76I6YSrs+kqfbMMz96QD FXRhrESA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg4-00000009t9u-10gO; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 09/11] mm/memory-failure: Add some folio conversions to unpoison_memory Date: Fri, 12 Apr 2024 20:35:06 +0100 Message-ID: <20240412193510.2356957-10-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7498E8000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7kxzdnbtncu7h4fo8bsitnemhhapn518 X-HE-Tag: 1712951501-527763 X-HE-Meta: U2FsdGVkX1+5jIBV2ELX+dL67hJW7ycb2r1cqy17TzMVVnKtcQksWRAJEF3ZUlQcejEXBtPIKInV6ZSl5uHBdrdt7Uqlz4jvgjpOGlV6An/XB18AFdURyoohhgt02sS975YzJQTTnJ4heIFM9Rm6xPG3A3T4a7glkeavR0yitFIoq5ZbX/X8P7rP41x82IfDmzV1qezYOycXSDhr1whubKJ04xoZrUHVfiNsKaMkv51mZqW1y/nsEanWIuEcIvyQpIQ8ix8Idjoef0Td72sDwWySOBqcChJ6SxC8jeyllm5fztQ9YGVSB6MV+bNC+Oqnw/rSjQrRnnCyFq9ocU9iw3jglHeZmOYRyC1zQCFWmPp3310vblePovOkM2m8a1JDNR6c269U3EE55kVjOKQXql6iBhvor8Alh/p5odKmA9m/t6p8PXihYhXfsXeC0CcZl+i9KnVtHd/rQ3+dadKuBHV0B2CssW21qfrt+76VRLQAHIISYJDDhI35Ou7BnkLHkzs3kG3vdDSLec8e7YRDrG6m0GNfj9y2GaMXn5W5bdQOavlmExkW+A/QIjDM6fFx88GjJs8FJ2Zg20qLKo5ItUEzTfdagac+m7Wuspw+T3gcyKhN/VjQ7K6JgC5vhO1uSfXVcKEuNrj+TfWLpoRAGiK9iByhTtdIvwMXcTBllTHWhRPewzw6BzhtswDodOHjWFbeg9qbb2n/6Qd6Di4tU4uFAiVoUHHkKEkzHbQb6Vhfg24a1dG1sW7ceLed5h4ARStX78GHcZ9eDhOet5TWI3Rk1wlJ+OCP0z9Kv0YdHl9vLH8/X2dtBaVI49x6cOfIriez+zEEdRPkb0fVwmGiCHi5aRuS3LoWsMPi9LVmWxrL8wS1ZDp6MpKel6LPsadt30jlkue8hcHlKC5k0mKRPIWLReGPwGK+5klm+cwI4eEP7uJAIJxvOLn3EvjhNhTef8/PQTqVMxLSGM4yo3t udcOL51I Zh1htLhpr0msAtrtydfg61Bml1I9qq5a9z72mU/gRhlplCQEl7qwtK4s2Om26ocnjxoY18it13eu0M6mWJVvHi5ZBZnIF190SqOxP0YOg6tX2Z9aZ/xF3CTn3L7hMv6mRal7aa9Wz28E6qi0HEwZuixi42VQcB/rlyLp4F3CaGrKg0WMYBaMJ+lZn4iqCVmn5WRgcr31moSHl+nybe/PIG51YhDCsMvh5vhMGfchpCt0z2ah9TkU2+LxM7kmEKJCAlftV1gLlSl1Ll5QQ+55gq9mJjQ== 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 Reviewed-by: Jane Chu Signed-off-by: Matthew Wilcox (Oracle) --- 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 0fcf749682ab..e42c5f2179dc 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2550,8 +2550,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; /* @@ -2572,7 +2572,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) @@ -2588,7 +2588,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 Fri Apr 12 19:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628284 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 7E25EC4345F for ; Fri, 12 Apr 2024 19:35:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62FF26B0093; Fri, 12 Apr 2024 15:35:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 425056B0099; Fri, 12 Apr 2024 15:35:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2018C6B0093; Fri, 12 Apr 2024 15:35:22 -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 F02D06B0096 for ; Fri, 12 Apr 2024 15:35:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C0E3DA0E18 for ; Fri, 12 Apr 2024 19:35:21 +0000 (UTC) X-FDA: 82001883642.04.A2531C6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 2C1C32000F for ; Fri, 12 Apr 2024 19:35:19 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YohEe29B; 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=1712950520; 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=wLkitv2Y32RPJ7Mlxb/OaGL8wYq141qqmEY7krwxabM=; b=EiD9jQ3q1P+kxfFltu2T0cmEl/WOi3eQ52JETcFAfxIubPnSu+3llwQtHgKqe1PDvNwG0D kHTlAWVvJr8xTW62Q8LAYWmetLLfJCDD/pBJCNkRG3D6O8P9lTQGev7JIDVpla1JydSnn6 iCtvQZzDjKarF6MkCuCbuh11ksk7Mmk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YohEe29B; 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=1712950520; a=rsa-sha256; cv=none; b=7bvkRF78sjdF31sGo4xORMa4b9kcUb788096nrYv/jVxPhGgPAYya9nVroBcNtc4QhbC0k MrE2BU1YLX+zccL3eGpSTHeuMdW1/eSK4JURKzzlpv3SSsBYTZxCVF1EgqktQatzK4kICf 7PwBsOL9FKbekssk7HZ2i3Or35SyFWE= 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=wLkitv2Y32RPJ7Mlxb/OaGL8wYq141qqmEY7krwxabM=; b=YohEe29Ba2LnuxewC4/LKlOE1k Ixz2EK9RUepKremGUDAYoKzdg4FVheoTkJfxEurEGwO50X9fCrRuYYg8ZhHqwnTKq9ssZcph1mymf +6Y9Aiwx7Gktnh7xxQuIgf7z+V1PgTtHUWk7SIiZhItAS+CC8CLAK6eFLAzn/RjIsExzW2tcYmMgS ABKUDKdat+/5u5aDBXOQod40VbIQf/DEkUxMIKgd6maPyzPG8/X3dTuXMG4m7pJN3y4uA8vMo4/hY UPkK5ypn9SWPob2xx23V52D0kpNzamgWcLMDjjZlCuk/ngYaCx/g7VYvknuR/9etQc/e605HtxT7Y AH+Lqx6g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg4-00000009t9w-1MZp; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 10/11] mm/memory-failure: Use folio functions throughout collect_procs() Date: Fri, 12 Apr 2024 20:35:07 +0100 Message-ID: <20240412193510.2356957-11-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2C1C32000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1ikudadxbwg7cy3t9zkb8r4q4zjhwtdq X-HE-Tag: 1712950519-109873 X-HE-Meta: U2FsdGVkX18OQX/6ta+yMrPc6vjPU+i7sbQhZiKy4b29nCqC6PNZnh7VMVVo/FBjPzZSp8D8IyVrFjvfYLheagNRPrX3c3M+l8SVgMsqM6hH7RaDjxc/y30Wes+CcAOhwz5yzL2K/m+hM1sU3xLvgA6DowdvRuM2z03pSqQ4rSqHwrlDlrhakjZZTFgFYPFDLbYrKI9hyb7AuDZnt+i1/HrZykKsrbDJ2cTrGMwPbdNmMxDDRLkluxEIse+m+SVtP25YJrEMapnLdhuRDWjbSDyAVy5E0jigbecUYZNibwNEAEKrb7UrvxLU01yxXvHaQLqazoU4sISosrFoilb9ty4G19ZRyDmlaCLGUCAgN/4PfaOSCnAv/SHzUJlbsV3ISt9bFGvahrXzZ4NkPhyWVwnagPDBFYnQ24GIdxG828mLXktMiAbqpaI4ZV3ejO6E3FFA3QO0CYO7Ffbs00hcdtuuFmbYz/gZEH9tS4u/cqDZBYt4CpPzPOZCzFx2DUUMsy9GnrVO7WJ0lDSUZdCyff5Jbe67dhxsPdwe/TqBQj3yrTKv7W4xi2yMg9qrYOb8zPgBPj6X6LiYSu8Up3jQSKSdvE3AAUeI0SUioLFzqdT/Y1sHyDkaR3LRr70pKQZaTMiiZ594i5dtiEXM6hFWoWEDmoAsq9JKTlD8PXtoaqPYA4z6Rm86L6tS8BQCKJKnb6lxvs7FOJA+SPK7ZLhroAQwMJvo/GbZrdCTUKy2vzpCNmrSOWdafB2Wkmsrwsc+g4oD8Yj2u9KG2gNkp/AvOxR9nqDSkZAYp3uhqvhcwaFZ7HOrUPYYF/S9XvvkG6DFKaXEn8kSZYq07oEfeETaIlmwSzUFmXq7UOstvs6AdVq+Pga9W5qsv23zPOKT0YKfS6YJ7+DvJNlFQe5OPbBJflDxwB2aaHdsacDppXvop+8FG614Qpv8MlB0NaNN9qf95emWjgJDw1f34vZyG6Z 1TZAfcni gZatnylfzmAa+Wso1HlWKVa7APSpTNQc8GTU6LrIfrkIcG1tWOZTEPvn92yiJ1wCrCXPZT2gQgUgvrBY+YCI1IPR+toOT7Pd3fLYD6fpBNGepRwujMyR9BA/3yT1wOqnHQu86j59tYRsMAtyJ4CYDoF5PLjPvZVnR1JqE804qRFaDpoddjQZb4B4M9ixrDlpZ67nAaFQri7Eq/9AM2wx4lPt9yC1D1wWWJYnZDvoroQ/QKMHYP0Id2JPQgQ== 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 Acked-by: Miaohe Lin --- 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 e42c5f2179dc..a9fa5901b48c 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -722,9 +722,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 Fri Apr 12 19:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628285 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 A443FC00A94 for ; Fri, 12 Apr 2024 19:35:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E62FF6B0096; Fri, 12 Apr 2024 15:35:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9A6F6B0098; Fri, 12 Apr 2024 15:35:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C621F6B0099; Fri, 12 Apr 2024 15:35:23 -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 A90096B0096 for ; Fri, 12 Apr 2024 15:35:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 79F7C140FCC for ; Fri, 12 Apr 2024 19:35:23 +0000 (UTC) X-FDA: 82001883726.26.02E4CFD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id CC2AC20025 for ; Fri, 12 Apr 2024 19:35:21 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fQgNnb6Z; dmarc=none; spf=none (imf03.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=1712950521; 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=SoYNw4cg3/PiZiDGgh3mMR56dd+moi10MIMx5yUsGUw=; b=5O34CFzwqTYF9nRQN01d/HDMeZJnTRbshknsyZWaEjf6BuHMP/NsZuspNSgzLbsHxNy5m2 ve8DILeNLeiKFyN+2N0vAfRnHQsaPHxZO1W9FL5xa845RT/JvxlR6gQ7QRWz8mhkj+NN/d V7YW9KbG5Njs6BgKYJV7lN2YnxqRxqM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fQgNnb6Z; dmarc=none; spf=none (imf03.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=1712950521; a=rsa-sha256; cv=none; b=qm3BJMBokH5xkxR7oKSus1stmLifjh4+/1L7kznixab14g4a7cMyZFsYv6MHTwmb2Ep91T aTWopu9j7Yjh9yVpkeinu9hCqUhGEwMixbfzF7ojw3fEAmRPmFNxrDjXOFqGtDOMS12dXl 5oC/kHnEOuH2PFRbzOXWCN71LYbcw/E= 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=SoYNw4cg3/PiZiDGgh3mMR56dd+moi10MIMx5yUsGUw=; b=fQgNnb6ZHttIXoZrO6YrkNR0XK M/JajGee9j5t6BHsyMOdN8i8tsipozUS3GRTt3co8pdLxwyLItHlVYhvf3v1SYzYU7ODFuI584s3J wRh8vOWorNJcwpGxmSRr+tyafZDtBn8K7ypElUvcg/X/FgtWZJYw8VeM8zIw1H2pfwfmj3hbswiL4 4Ll6/GiQcsiiOzL5Nw2AmXjCE1OPofN2B2rkgVg12vlP8tUmj6qL83DsBScmZRATQVI9ABPIXmgsw xpYF9x773bP8Ki8WEru1gEeS2S99MkMfbB85c7xQviyPM7WlgP4Sk/bkw1jGeh7TmKmJg/UBqNgOj oT7a/AIA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg4-00000009t9y-1ib3; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Jane Chu Subject: [PATCH v3 11/11] mm/memory-failure: Pass the folio to collect_procs_ksm() Date: Fri, 12 Apr 2024 20:35:08 +0100 Message-ID: <20240412193510.2356957-12-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: fuwrnr3zbw1u5ysbd9wezrx7bmeewn4t X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CC2AC20025 X-HE-Tag: 1712950521-559357 X-HE-Meta: U2FsdGVkX1/8R+EQyacvkY/CEeqxwOZnb5DXK7wfdha++LSou47F1AEGZwR89eDYXZac7gAyu2zFy0XvgGpYpN7ePumJl+E4FvY6rto+pcWnjsd3HOzfziwbE1OTwnrL+78OLLJh/Bf/g0mXXML0C8kvC5NaQOM3D9jFTWltiQ1eCg9/cdgICFjz9XuxssoeTa+SXzeAjAryYwWKQppW73MxyuluHPk1x8MFONrdS261s0gITGgFDmHHHHJrRQJ7FQj1ANCk4UXxeg28JojQY0xRgGW03pvBRw7kyzYr+wOUFCbN5wtqe8XfU0OCfFNNF3gpCU3TGzVfxRgiBMgHwZJAHZvAT3KV/gVYOMelOC8FtE4rKXgkb462WlZWMddvbpeBTTUQ5PSU0or6MiKopJLagctZPT8I/5KOu/sYpx5dTBCAXaeXBPdYAXC9+PFXmUk3O8Xt+hZM41WJ9D49m4Y9dS2TSptx+eBTq3JZN9ZO6kuDgWj0hbo9Ubt9zbR1fI7F1jJY3cNI53FyyASNmKtIcygXNIkmheonZIPIc5hUL1HJ7+1UZBHxOMEU1qpF8ILlRcnp8FRWuzNRZnsx2YiV4GGQWoelLYVo5t9hpFAkmFrVDk0ACXPs07rRYDmnK98wgdBAbYu3R/I5/rBB4a1zbffYLQaXQQGr1N+nxjRD9/OCM9kpZ5UeDNeLD6ghkbi4eT6+YKiA4JuJDFAtGnbmB2M8n54xFT6/zQKzKT/NBRSjMUWnV+Q2LvSJvparkGH9LqfRE+3CD/T/2B0UJ+2YGJyUiyQgy/U3dqgxhOicrqoMrF39DysR5RFw4zZyyDQPSyvZqDa0QkHVXP8SdHfFZnAaQUmQ0Kaq6PaM7Jh/XaYm/sP28iKHdBC0VmaTTGKYsWKk1kKkZLbVIgVXeguhNt3BAiHKElxJvyi5pMxmZDGuq2stTqi0lKd3ZXkhjssVQYQfb+ewg6NOje5 aIoQW0dL d107CbsPLsxZn2Aw86/NdYmv3KBkczA8c9HHRg3NVI8aAG28IjpegBZBwjG2zSLeJkioqGTSziGPqT3yH7tK6vb1V6PPGdUAQMBhWowAGQ7q/UiTpjmYY/bVzzd6wMM4Q/6jgNcIudiM81AilT4FUta4EubqXLDDuygfzRGn15Yso3X0xj6MyenALzzPa9BGs7hlIZ8Hq43OGmh/2Saba+tQ0M8qLOrWcg8GelR+0VOreVT9ZCU/HVFIjonNhVJbIfLBM 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 Reviewed-by: Miaohe Lin --- 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 108a4d167824..0bdd4d8b4c17 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 a9fa5901b48c..c7cce73333f6 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -723,7 +723,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