From patchwork Thu Feb 29 21:20: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: 13577663 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 691BCC54798 for ; Thu, 29 Feb 2024 21:20:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0E386B009B; Thu, 29 Feb 2024 16:20:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E95176B009C; Thu, 29 Feb 2024 16:20:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D36296B009D; Thu, 29 Feb 2024 16:20:57 -0500 (EST) 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 C470A6B009B for ; Thu, 29 Feb 2024 16:20:57 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99F0D16041E for ; Thu, 29 Feb 2024 21:20:57 +0000 (UTC) X-FDA: 81846111354.02.E52D78B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id EF61820018 for ; Thu, 29 Feb 2024 21:20:55 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="EZ/zKWIO"; 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=1709241656; 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=WIIjR8YSK2/M2cI4aB2urA8EdxfJX9fwxdkntR2rEZU=; b=kSyllKzz0X2YRPscyME2i6w7gfntp7PtE+KaQpjVJEbaLZ0GYImM+Txzzvho+aXECcMFKC FQwjQDNOo2/4OkOwWC8pFO6n4efD0gZbMU0OLlfZgmUwND3VqxSPD1eIdNcK6m0Qcl61pD px8ntjLTnlbIf75OXqMZoqicym9AuCc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="EZ/zKWIO"; 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=1709241656; a=rsa-sha256; cv=none; b=t94YTlrVtIr3NbA32cgQfoE8MesrZEc/GrDwijWrkkjbe+6+dzK8ju7/eApcTH2NO9/xoM k45455egIITRB2aqPScrzKbpceOaVFbB40Oo10emRZzsgCw8fZvC0Vvv7JTLdL9yf+7Xl2 kvR+QwshVpq/uVBdO+32sS7mcYBDGFo= 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=WIIjR8YSK2/M2cI4aB2urA8EdxfJX9fwxdkntR2rEZU=; b=EZ/zKWIOh4/xGYNZlKkjT7JbJO i8OP/jCLyI+yVfmLvomh7ClTpg/DcaeX9ZCReD/BdLjh7HdxChTZzlBc1CxgTzyKZqXEGH+H/EqBZ c7XMLVTSWTQ7CXPetdNfNX40Lv7QykherbVGdpD+GMDKjUa3ICOaeeqjP+qkFIGCdy/zud1b+X61o 81INd7s9BtyIXOWVZhqjtNFdJhBDxOze0J+qvzwv5ihU2rrIS1bNuwro5MEVyapgv9AeMXmKcSib+ 820+qFbXI+v+54U/ylp5MCm7mVULkDfIHgEqHTZzOTe/o8OCwPNxnoTXcmA5eXrRFiPe6hWHhGFNQ +xoSneCw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfnpV-0000000949V-2SPR; Thu, 29 Feb 2024 21:20:37 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Miaohe Lin , Naoya Horiguchi , Dan Williams Subject: [PATCH 1/8] mm/memory-failure: Remove fsdax_pgoff argument from __add_to_kill Date: Thu, 29 Feb 2024 21:20:27 +0000 Message-ID: <20240229212036.2160900-2-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229212036.2160900-1-willy@infradead.org> References: <20240229212036.2160900-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: EF61820018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: nddy9zha5x491qa4kga8ydawe5r4ofbm X-HE-Tag: 1709241655-215281 X-HE-Meta: U2FsdGVkX1+fx1bwMebk9Sc/W2POm+FAAVNinmE97AlEpxi5LkpSJmSvLUOEpU01PDEY0GjqAO4JuK+OJ2SEJuyg2h3b9HGc4Qv9qZNM8NUZ4wMlf3rqqpmt9eFcZXlere8staRoyJ3jIoup5gQWhG8homk1aeZSrqUgo0H4zCG3f5wTfPWfoiqOXepQ7LJ9IB3bQtzWF1io+K5JHy/9DtMK9cyuvJrjjzlFvibTTcVi5WE/B4cu8X9SL7wXp9vRMT2P8jd5OJhQLRFQsB8VCcqQyNJTqtnUTkNBP0VLlgTCU23bKcuCp/hJuD3f7tkJNm0of5bO85IWYUOal/oUajXHqkstVoh2hQpTp10c1cStvlXJTDMHj0bUB3WNGgDRGjkmjgE95CStEHdzBd+pxuf7t85b2ZuLOBQGT0AGZj8x3lXkzHx4NhvALg/a9gAtGFxNUvC0ofSMD5nE0LfUaC/GVgIpCW67sOl4S+5cXzLXJtUZKZQ62u9BULidPjlSPohKuW6ocIZVoUnirjrPCApgohuLAflXK+TZh/31nnITBaiLiEI3xu0R/MDR+NrrNQyhoxgWaVXM9+Xz0m49d91XFfaZ10doNf9bVehNz94TIZJJaRCvQzfN31qBkTzpwfi9lV78Tw1IDSGus54gpaW1hMRYyJwm7eHJ9Tx3EViZ1mp1zN4U4Ju5l3uOHxzBSL+044EaQn99MLoVfchIuVedgWDlvgOZlihDozhB6eE1ol+urdWXCjBDprdan9L+L5UyjmjmReYHzwcE2WJ+d/1FyV3GnLHegTPCyljfSWyQrxnoQAGdbKh078QpFoV67wmUDTFmPJWWxcdOnQn+9CLpvdmvdYBXOWO6arDXxfMIA/soSb5GI/3BjrBig5SliWLyKT56mXCUJY4BMMI0RqIMdzwlJZ0Ha8hyIUm3KIfjZdXGOF+kOAyyfF4kfy0NEPOr7kvs5za/TlNMX4v YI6Fat6Y SQuPayDlDR1ac9QEb7BN0FaQNSwd9C5bATVrd5RJAFa6w+Tw6uSkBOtde/bzEvbG+5HDPQtaVzhue8yTViY4PXZ8loPmHUybHBY7+EZ1zlg5orQnfZqCXIe0Qblpnab/ImQxCNom7dfIT7uPmJ6CUzJYrXgEcyyj6ooAEaA+bZckpNRH86WaUu+zgDxPsRtq6UJW2Gej0GHgre6mntZzReUusKWsMKgKzKA9wiIObykJXni0tO2v8MYaoFQ== 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. Signed-off-by: Matthew Wilcox (Oracle) Cc: Dan Williams Acked-by: Miaohe Lin Reviewed-by: Jane Chu Reviewed-by: Dan Williams --- 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 9349948f1abf..9356227a50bb 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -416,21 +416,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; @@ -440,12 +432,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_pgoff_address(fsdax_pgoff, 1, vma); + 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)); /* @@ -475,7 +465,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 @@ -493,10 +483,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 /* @@ -670,7 +660,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_pgoff_address(pgoff, 1, vma); + __add_to_kill(tsk, p, vma, to_kill, addr); } /*