From patchwork Wed Nov 23 19:54:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054176 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 684D8C3A59F for ; Wed, 23 Nov 2022 19:54:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E97C86B0074; Wed, 23 Nov 2022 14:54:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD2EB6B0075; Wed, 23 Nov 2022 14:54:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5FA86B0078; Wed, 23 Nov 2022 14:54:30 -0500 (EST) 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 A71D86B0074 for ; Wed, 23 Nov 2022 14:54:30 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6636DC0534 for ; Wed, 23 Nov 2022 19:54:30 +0000 (UTC) X-FDA: 80165759100.26.CA39436 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id D340C1C000A for ; Wed, 23 Nov 2022 19:54:29 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANJdvjT024628; Wed, 23 Nov 2022 19:54:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=xm2gMD3T23PmdDrhDiJoTHFKsv2XmtVcmY0IcP7Q4Qc=; b=V5hCnPkCGDGo/racu7sqejLUjrlv/dJfkfZvIbv2rz3tw7nW6oYSe2gi7cbAPXrkUSYW QRMbKSge7nRCvn+xgsQwYUTgogoBogqGeittvtdGubMWwnCduxX+/zHdJg+dZdeVI7l7 fN3gQ/AtEqJ4S30zY69XOofDrzJN4vAxkmzTOMmP52kZRXna4mfpwUZaRvoHaRNDGT/Z e4n5LhR3Vqa/3J2ZYkvwFJt5fVBj0oNrCO6Vd8e0i2PJA0IHnldFo8LeEPxka519nUux TFIZTgrB7HkArRhQfep4HPGRi6iJJys6PezpBVwJgmKEXj3z934BLfbldTg7J2cBvt16 hg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m1svgg136-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:17 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJESJk009343; Wed, 23 Nov 2022 19:54:13 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnke3bqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTcATirmCZ34/ltlIvhHPhABseorj9xXkQFxk25Vcsme7XiMXNaITs8NsAmTnCwF3gNnFWgSxKdQAK+NCXqxwE35F/D7G8noHzcgesYO1TI5yv28oJhJPDuPlWLicui70Uob72fUPO+eEm0VYg2MSCQdBQb0ZVQyQNa1bPdUZt3+eJOaIsDOy4FAB/n6YVTdFWQA38WRjEYfN9NBtXMBjkPm/iA9Axfekxe3JYfjAX16VzdIO1+j5sHaT/6TK1+ySaEbWHT5fsbxMaL71qAT0poA4IYDPcrziH+t4y8BrwFat3Am4dJ0p7yYWyZUo6LoX/fZ8UBXbVOMhtr+4gdILQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xm2gMD3T23PmdDrhDiJoTHFKsv2XmtVcmY0IcP7Q4Qc=; b=Gme5pSyW3NNkTxFSgoEA0rKUCetjlD6BeH88cAkJZaCOTM0Ze4QDoj2xDSdsrxF/3bPnkq8NkHgxdEg2K8Xc1iCSWdqSQgK24fAs3ie8xFwy1c33KTxdu9mGtILQAutDcJ6LWTDkL5Nzk+9blAoFbgcRnV+5cPPpto8dJiH7kIkbm7dGGuNnYDvPMrHcsCrQOFUrAl4gFIaU49FYle1K1Srsy+YPrVTc7IrPbP4BP8CgS+7KrrwOCWtjZlLspp0gd0JqZLmZqx9JuTVud+6melIn9vlKUMK6J+h/OWTayQ0vZo2JW7heewhKDB+8JRNNI1KGy92CPmISDfkbW8FEKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xm2gMD3T23PmdDrhDiJoTHFKsv2XmtVcmY0IcP7Q4Qc=; b=JM0l9Vd23CLpHWOm9KP6rVZDqj5qjAcPVdwibhRImZeAFKgwF1EJDpPBHuVTK1zKpx4N06/MnlV6AB6CrEz8Sqy1xe6D00LXO6yyYtBfuYFV4XY+lYtQ0/U2Xr0JVETIOQNHyHKZJeeaCg0nTH6NB0fUZM0JTbJNxWYq/Tu50ag= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by SJ0PR10MB5671.namprd10.prod.outlook.com (2603:10b6:a03:3ee::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 19:54:11 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:11 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 1/6] mm: hwpoison: remove the unnecessary THP check Date: Wed, 23 Nov 2022 11:54:03 -0800 Message-Id: <20221123195408.135161-2-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR04CA0200.namprd04.prod.outlook.com (2603:10b6:303:86::25) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|SJ0PR10MB5671:EE_ X-MS-Office365-Filtering-Correlation-Id: 31760501-9d15-4cff-3b07-08dacd8c7db7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HXp+OGv/zdBSxvFBBancl+zA3MHe+MxTd1eRnpYd3xnALVTNx+PEzhZYwFEPX/xvkqr8xYSW6KRnWIoNaonIUG8wo+YuBPt+xoVodnv81k11gV7s0YSrIg1dFifDdiAWuDEhlwtYL7dfs0u8ZyIYv66x791FNl4e3MWUG5pWNdPW+em6kKyJ+816v0A5upZFUJdRVrB+z/Xe1DA81AWozA7cXFA+DIyqUO4xjhn/ARabDdW6EBiJjUo3Xsa/+R8FjFPC6Hzx9HOHBNQ22QmVn1RYw8BpSucO6rGpS/IMbOuNLERfUbs6P3fkoSvc944uxPsSK6WUisDZwSJNTwIDi+gVctStPeBPt70qDN+ssOiG4wBS8pS51kpU0zOW/Eb8rIOhjE+umTWbsJ8zMNpetED4SE8WiwgqhPTALb+IJqxbdL1qf63sShT2gt2TDHZ0JYokUk04720z0GFJDkHOaoqU85Xg6ijwEHPmXU5bLqERAiwenc2qNN910j2rHioytM0QDx7XTdJjjoJC9YPvQFyynz6cTeHX8Wd65BCxLmwFgWkFi2WB9fhqrHx3lXqEIFeoeIcEvGS3G6SXpF2sz8LLUMuSroFbwhoOlXtnES3j2vPeWser3kfF0dOsZB+n/06L4ZEl+GOZGXkVxqUrUFVsX5h1hZT1MplsEEU6L/o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(136003)(346002)(376002)(39860400002)(366004)(451199015)(86362001)(36756003)(66899015)(6666004)(6506007)(44832011)(966005)(478600001)(6486002)(8936002)(5660300002)(6512007)(26005)(83380400001)(2616005)(2906002)(38100700002)(1076003)(186003)(54906003)(66556008)(66476007)(4326008)(41300700001)(66946007)(316002)(8676002);DIR:OUT;SFP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2EqrzLkwTA1wzLUFV9xil5fc+M35kxgFVoJV6dTPb5pJCfstH1VpTgf/ro1AFXOeJNWQ+qOaSVAXer4fuxoyHJA4fbAw2ns2ogXF8irQfOZeARbVPNW6MdEDS51/I5GxJL6mDegJhPUG6slE7IYPOaBM1qznU8Ygoi23ZR6hmE7X7Khm0xCKQUGEKf2F2YUV7urDoB4Vd82NmfW+biy25e/O96QtmkvJhIVH5ZRAIzbgobI6sggu6dn4ietZW+jQhHH5nhs0NOqAOJzOqTC0969gChreySS0J7cu6LZb4GsiPAWK6TUFNjutINQgH33YwS5bbIdru6qVAaosNfu1902WRWnkMNhGzYRXswUEjkDx8IRJYXl2asvLqxC1LZbwgYyCyFYImivSoGuys+zAT+ZkzewHDfP6d0NALSZaJSEK6BgLtdTz3l6PsB4C7h+WQiuQhD926mM88QHc2KdixZVetTuKru+Yy1mQvs3xkcq7Kd0zIQ1vPQ8vEpqc9BnGe46iJVyiz1amVhyXIg9+D5OSRIFWFT0FVXz8R4mPsWrhuJAoKv3Cqr8vnqAeRVNhPDD88sp6lPm6tThKmlNMmWu4rMqTHVtAk+hpRhmeXxGBCFsfm6dBnEEhDe6kPzPBYZmIt5OKsQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31760501-9d15-4cff-3b07-08dacd8c7db7 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:11.6809 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OK9Poo/nMxNMpsTb5VjFTtFL4d1kUyKvET+MnbElT3p9vZOX+QZty/87dH/6uh9ol6YtZd9S8QQ8Upsq+nH17w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5671 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: 16-2cSbv-Pc-ZfGHpBc_v8lKDWh_xREv X-Proofpoint-ORIG-GUID: 16-2cSbv-Pc-ZfGHpBc_v8lKDWh_xREv ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233270; a=rsa-sha256; cv=pass; b=JRLzcLTHwvsGLXDd/C3LQBM+6cbvS+ccwlHPkDynQA4rZpz4SKA3KvqYsILRnsgp1ExAgl HcgNcN2oVWf7tYJhCERkVyTdROkMrT9KXX/OoIke/Pj4B/jRrx5GtdG1kR7ZN7uHQoRf2U 8oUafFYFkatfn3IDctq7Ms7w7xTMwFM= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=V5hCnPkC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JM0l9Vd2; spf=pass (imf20.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233270; 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=xm2gMD3T23PmdDrhDiJoTHFKsv2XmtVcmY0IcP7Q4Qc=; b=T1155IaUa032gIA6hA8RBlgl5Jj65U/UOnVA+3sKrKUcioLasqVoOT+t7dNCSY9imLX7CN V5HGzK2JNWz5QzoUCJZQeA4E5PIc7lWDStzWRxW3avHiY8HaB0Hfize61TSM6YhB+tqvwi Z6ugenHY03BUExFAjJpeBZ2oZDPHi3Y= X-Rspam-User: X-Stat-Signature: 1spafphcmj9b55q1x3wndkk1oa5qsswg X-Rspamd-Queue-Id: D340C1C000A Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=V5hCnPkC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JM0l9Vd2; spf=pass (imf20.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspamd-Server: rspam07 X-HE-Tag: 1669233269-561354 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: From: Yang Shi commit c7cb42e94473aafe553c0f2a3d8ca904599399ed upstream When handling THP hwpoison checked if the THP is in allocation or free stage since hwpoison may mistreat it as hugetlb page. After commit 415c64c1453a ("mm/memory-failure: split thp earlier in memory error handling") the problem has been fixed, so this check is no longer needed. Remove it. The side effect of the removal is hwpoison may report unsplit THP instead of unknown error for shmem THP. It seems not like a big deal. The following patch "mm: filemap: check if THP has hwpoisoned subpage for PMD page fault" depends on this, which fixes shmem THP with hwpoisoned subpage(s) are mapped PMD wrongly. So this patch needs to be backported to -stable as well. Link: https://lkml.kernel.org/r/20211020210755.23964-2-shy828301@gmail.com Signed-off-by: Yang Shi Suggested-by: Naoya Horiguchi Acked-by: Naoya Horiguchi Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Oscar Salvador Cc: Peter Xu Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mike Kravetz --- mm/memory-failure.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index aef267c6a724..ae8b60e5f939 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -956,20 +956,6 @@ static int get_hwpoison_page(struct page *page) { struct page *head = compound_head(page); - if (!PageHuge(head) && PageTransHuge(head)) { - /* - * Non anonymous thp exists only in allocation/free time. We - * can't handle such a case correctly, so let's give it up. - * This should be better than triggering BUG_ON when kernel - * tries to touch the "partially handled" page. - */ - if (!PageAnon(head)) { - pr_err("Memory failure: %#lx: non anonymous thp\n", - page_to_pfn(page)); - return 0; - } - } - if (get_page_unless_zero(head)) { if (head == compound_head(page)) return 1; From patchwork Wed Nov 23 19:54:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054179 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 1551AC3A59F for ; Wed, 23 Nov 2022 19:54:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12DDF8E0002; Wed, 23 Nov 2022 14:54:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B4298E0001; Wed, 23 Nov 2022 14:54:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7938E0002; Wed, 23 Nov 2022 14:54:31 -0500 (EST) 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 C84E98E0001 for ; Wed, 23 Nov 2022 14:54:31 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9D996A0EA9 for ; Wed, 23 Nov 2022 19:54:31 +0000 (UTC) X-FDA: 80165759142.12.0081B93 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf01.hostedemail.com (Postfix) with ESMTP id C577F40010 for ; Wed, 23 Nov 2022 19:54:26 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANJiX3m009796; Wed, 23 Nov 2022 19:54:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=8ItNy649FN2cS/hBlkmzbF78ZBWdLK5y/XeURfLXDKY=; b=jUQhfJWQ+yFypKOa+eXlDi17bpm7UDaLM+4c7QNcKAN6b5y+DeZjV+s7bDybJ5eNafgx fDfv3yO3CHtz8fzp7973wTkxNAbou0kL5EZjnlv0i3Lg2o3LlrqyJUgJmnQjoCbswG4x 7k7g1Z0b10Vr1aIOItW2ChfgyKLipN+BsahzzTu5pvr14M4SZ4T7SVmQDukPSsVjF1ZW KypUq+lwOaTIsorqVKQE/0Pgyoq1/jM+o09DmjARTce11AMO6L8xMM9YNMby2Z6RpjCt tBceHbpJXhvp0m48CjzfwUNkMD3EZhWYeD0Px5ShHxWbUVxtkuQHqqiPt6C+8bcn2kjR RQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m169535wq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:17 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJKOFf009739; Wed, 23 Nov 2022 19:54:16 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnk7gws6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjvIt40pSfnE23WraRfnx76YLSOZiTbyw8s14eN19g2jzU3qhylOB9fBPk4rAlgxEDhRW1cC1jO4YUjwTYMoF51gUs8fp9YYlGRQXpwRpJDX6khVcQ4KCQrrhlyniYmCXx6nYUDGXFgCgYnDRQ84Gl41+lmmFReXxYFsCcqd8EcrNy6SqPOZVGlMLJ9Mns/bPU/CiJvsHYkzkv4w2DYZwb+a/jfeWxxbfea8fAh4JtMJZfJMHlA7xwYSTNf+ImIxKI+Qnz9l8hNgDOD/UC7dy6z9lFyJs5hqULAQIZE5RHFyYDFpH44k8coGw5YrJR90Az6BOipyKc/6ArD3RKH2Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8ItNy649FN2cS/hBlkmzbF78ZBWdLK5y/XeURfLXDKY=; b=C5rL6mSRWwIr3a4yBxxLZp+2ZNTmRsuSDKsEOA4e5OvNjo8FOEHLzOj9n84NAe6X6jlzhLUHQAIjxfRDcE5t151KULPxI4Yb4WIA1BUEfIeD3wI2CuEtrOMgjLjUhPxJ5m3gijsyrKACiAw59/X59Whqw6nUlfRl4WPKb2oZV5oQ0HDy2aJ0YVwOsqS4lPs61AhSUoHRgGyMZTW1WAanQL4/SCIp3j+kcsQrzcKt2fHVE7sFuZ8RBKfAq6GlyQXWyBmRLb8JOyiRCmdB3UxNKQdS16R2ZHWaC8Jii9nY9X3kAhu8rwkv5ktVPORHE3077W9m+I/tOCH39OnmpheTzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ItNy649FN2cS/hBlkmzbF78ZBWdLK5y/XeURfLXDKY=; b=fpIJb0uKhf6t6SSD5mmE6zAQ3oeh2h+vMLsvUhk9rrvtQOMJ0EqykyQg5MGmdGNrMJ8V2WFKX5WgBhCHFdFsKFTpuh76R3UM1kdh/6htFu8H1Ir5Hkn5zfq8R5hyosqTtWSmJkVwNRPxt/Th888g+bYcDcpjiO2TZobgqsMu2VM= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB6300.namprd10.prod.outlook.com (2603:10b6:303:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 19:54:13 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:13 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 2/6] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault Date: Wed, 23 Nov 2022 11:54:04 -0800 Message-Id: <20221123195408.135161-3-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR04CA0192.namprd04.prod.outlook.com (2603:10b6:303:86::17) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB6300:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e301b64-4302-41eb-7cf7-08dacd8c7eb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tBI4JtbNiNYlFenuFd+dGNhsGd8JuOOO624ezUCtQOnAw8IiZu2bgl62Xf6PKmBdkuSyM8vPDyxah7iTTK3733JCXAz8a4fZkMOHFXVs58hotHT83/+N4S4IwGy1CO9O0ufbvTFU6KfX7kTPBD35t/ARbIUzgBj+i+rWbyaUKgbcPz+519zVJLpkfjZ7UAmEDxdUTtuHTSP+HRkaKLs7S6TqHoBJG8+CHKbw39t61agld3JyRYOMCg/0PZU/jZJ9y23EtvbYYccLRw2D670ZDq+SkWkUbdq3ks5LFePNwYEAmfTxqZsa59wRiBMPm7AYzB6RjgGLYW5OCF9aK+BzNKmBkqAhiWujHa5xdz7Y1RQOugv+ybSLiasosIQKP1jrdEEkNYQQ3KNJOfOnRLBj6GdeSlh5gQAbNQOpZw0K3KEoSyS0kErp6VmMaSTc8cIDqAbqm6WSAXyvaxr2lpRA9gE0Bvi1ynleljycvu17zxbrs/BzMWqlUR3V1QAtJ6u/lWXUT9X0DPxwxWG7aZmmNPC6AiAUU3vB2eLwxow+afb25Gp/igMfwkMpmrg/VqoBEMwfZRYUpNH9Skubuyy2x4G8nFoezRgxyJzQ2k/N76nwTpG7cL1ydLDpQssRbCxmdCfl7yUepdiPXSAOItxHtevLb41+wvruoDPai4FPOF4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199015)(36756003)(316002)(54906003)(6506007)(186003)(1076003)(83380400001)(2616005)(966005)(6666004)(6486002)(26005)(478600001)(6512007)(41300700001)(44832011)(8936002)(5660300002)(86362001)(38100700002)(2906002)(4326008)(66476007)(66946007)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vcsFRKEqROvBI/FGrI3TwlTPw0FievWuSDbtzJBiskXZI0A3MBd8N56qkzrn72SCZc1oEIVpll/4QwT1s3DDD1AjlV20cLNr7+JW5WjuSVRXQ9242a9GTcJw0i+ABACH4sjt71eLCNqKJvuUZt1YbmnJj0vr+9sgafUlSP8zFH2Jnvh5PQ9XElSTzIf+kh0aDnpGf+OCxVqWqO+uyWus6kEbxYn5BmBt5R4DKd6htzFayVXwh5euN2txs8IMJ+pLIVoHqYglLC4yihDko6PGooeQN6TH9ZBtjIQLSdT/fWvU2tXJNp2eeElqnp/xB11y+Fc4rW9pUPkTlxAEPKS5N8UdalfeRECxN/asfDlUV42ig81MjePIfxfMtRfMS313vDFmb50weRV0+AJovTSpVuTynCofojZY/xAloT5qxt4naiTNBbyLnVxN16cHYG/yhHAfLCAIadoUnOL++r2MsCC7bJ5k44TpNMasQe9jZlNOS5+gEXPMgBcZx2Dm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OziNP2U/xKMV+iX5iLFKKupYfdyu5XA5X6XlD9H7iei3h23iZLQmG+WbqNLLZ+3sd+1xp0ZnMwMhSYdckWtn9uzsdliw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e301b64-4302-41eb-7cf7-08dacd8c7eb6 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:13.2288 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dn1H1ZY2Xs9qaoY8PIH+BjrsHXOC1ICv18DqtfvvDeVvdPySlFrs7yDnooKHnmUaA4xsN9kQDZ0t+Vqubd8mvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6300 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: D_C3uVakfdRBOsPs5x5heFCBojso_s8G X-Proofpoint-ORIG-GUID: D_C3uVakfdRBOsPs5x5heFCBojso_s8G ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233267; a=rsa-sha256; cv=pass; b=Wt2XPtNOz2jU/sGOO1CMLg6YyqERMPm5JtIdS8nnL6108mcJko8SKJgSSxErql8Pqw0HfV 74q2jIZk0g2nYgT0lZ8RCNDoaKxQ6py+DB4K7rPEcpETDvoN+VU5Hrt8CgA7qgvaNdbdrY JKHCydcP6r42T1KH1BzBkZEWELy+GQ0= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=jUQhfJWQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fpIJb0uK; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf01.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233267; 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=8ItNy649FN2cS/hBlkmzbF78ZBWdLK5y/XeURfLXDKY=; b=Us4dV1kIfCMPDEKR6OavYzRIeXgh/rLhMVvA9DZBLfObo/rscEerdH+eSOqchL+t9iizT7 yKJLulH5UhgI+nAK9SkD8Mkq+icKLG7kGBC4yAGQkr+WmLkMal1ndi8YLqxj+nInaluIxZ czaN7EU4vziHMrw1RnEtKzt4B8YPyXQ= X-Stat-Signature: r1gwzoepqsgp6sc37sstretcmca9h1qn X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C577F40010 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=jUQhfJWQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fpIJb0uK; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf01.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com X-Rspam-User: X-HE-Tag: 1669233266-597626 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: From: Yang Shi commit eac96c3efdb593df1a57bb5b95dbe037bfa9a522 upstream When handling shmem page fault the THP with corrupted subpage could be PMD mapped if certain conditions are satisfied. But kernel is supposed to send SIGBUS when trying to map hwpoisoned page. There are two paths which may do PMD map: fault around and regular fault. Before commit f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") the thing was even worse in fault around path. The THP could be PMD mapped as long as the VMA fits regardless what subpage is accessed and corrupted. After this commit as long as head page is not corrupted the THP could be PMD mapped. In the regular fault path the THP could be PMD mapped as long as the corrupted page is not accessed and the VMA fits. This loophole could be fixed by iterating every subpage to check if any of them is hwpoisoned or not, but it is somewhat costly in page fault path. So introduce a new page flag called HasHWPoisoned on the first tail page. It indicates the THP has hwpoisoned subpage(s). It is set if any subpage of THP is found hwpoisoned by memory failure and after the refcount is bumped successfully, then cleared when the THP is freed or split. The soft offline path doesn't need this since soft offline handler just marks a subpage hwpoisoned when the subpage is migrated successfully. But shmem THP didn't get split then migrated at all. Link: https://lkml.kernel.org/r/20211020210755.23964-3-shy828301@gmail.com Fixes: 800d8c63b2e9 ("shmem: add huge pages support") Signed-off-by: Yang Shi Reviewed-by: Naoya Horiguchi Suggested-by: Kirill A. Shutemov Cc: Hugh Dickins Cc: Matthew Wilcox Cc: Oscar Salvador Cc: Peter Xu Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mike Kravetz --- include/linux/page-flags.h | 23 +++++++++++++++++++++++ mm/huge_memory.c | 2 ++ mm/memory-failure.c | 14 ++++++++++++++ mm/memory.c | 9 +++++++++ mm/page_alloc.c | 4 +++- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4f6ba9379112..3f431736cfc0 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -169,6 +169,15 @@ enum pageflags { /* Compound pages. Stored in first tail page's flags */ PG_double_map = PG_workingset, +#ifdef CONFIG_MEMORY_FAILURE + /* + * Compound pages. Stored in first tail page's flags. + * Indicates that at least one subpage is hwpoisoned in the + * THP. + */ + PG_has_hwpoisoned = PG_mappedtodisk, +#endif + /* non-lru isolated movable page */ PG_isolated = PG_reclaim, @@ -588,6 +597,20 @@ static inline void ClearPageCompound(struct page *page) } #endif +#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE) +/* + * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the + * compound page. + * + * This flag is set by hwpoison handler. Cleared by THP split or free page. + */ +PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND) + TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND) +#else +PAGEFLAG_FALSE(HasHWPoisoned) + TESTSCFLAG_FALSE(HasHWPoisoned) +#endif + #define PG_head_mask ((1UL << PG_head)) #ifdef CONFIG_HUGETLB_PAGE diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cb7b0aead709..cda0ea6c8623 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2464,6 +2464,8 @@ static void __split_huge_page(struct page *page, struct list_head *list, xa_lock(&swap_cache->i_pages); } + ClearPageHasHWPoisoned(head); + for (i = nr - 1; i >= 1; i--) { __split_huge_page_tail(head, i, lruvec, list); /* Some pages can be beyond i_size: drop them from page cache */ diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ae8b60e5f939..b6ab841d1db7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1367,6 +1367,20 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { + /* + * The flag must be set after the refcount is bumped + * otherwise it may race with THP split. + * And the flag can't be set in get_hwpoison_page() since + * it is called by soft offline too and it is just called + * for !MF_COUNT_INCREASE. So here seems to be the best + * place. + * + * Don't need care about the above error handling paths for + * get_hwpoison_page() since they handle either free page + * or unhandlable page. The refcount is bumped iff the + * page is a valid handlable page. + */ + SetPageHasHWPoisoned(hpage); if (try_to_split_thp_page(p, "Memory Failure") < 0) { action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); return -EBUSY; diff --git a/mm/memory.c b/mm/memory.c index cbc0a163d705..1e9f96caabbe 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3814,6 +3814,15 @@ static vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (compound_order(page) != HPAGE_PMD_ORDER) return ret; + /* + * Just backoff if any subpage of a THP is corrupted otherwise + * the corrupted page may mapped by PMD silently to escape the + * check. This kind of THP just can be PTE mapped. Access to + * the corrupted subpage should trigger SIGBUS as expected. + */ + if (unlikely(PageHasHWPoisoned(page))) + return ret; + /* * Archs like ppc64 need additonal space to store information * related to pte entry. Use the preallocated table for that. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a56f2b9df5a0..8eb745920cac 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1232,8 +1232,10 @@ static __always_inline bool free_pages_prepare(struct page *page, VM_BUG_ON_PAGE(compound && compound_order(page) != order, page); - if (compound) + if (compound) { ClearPageDoubleMap(page); + ClearPageHasHWPoisoned(page); + } for (i = 1; i < (1 << order); i++) { if (compound) bad += free_tail_pages_check(page, page + i); From patchwork Wed Nov 23 19:54:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054181 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 478B2C433FE for ; Wed, 23 Nov 2022 19:54:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAB1D6B0071; Wed, 23 Nov 2022 14:54:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5AB96B0078; Wed, 23 Nov 2022 14:54:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B87056B007B; Wed, 23 Nov 2022 14:54:40 -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 A65FA6B0071 for ; Wed, 23 Nov 2022 14:54:40 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 648B380E19 for ; Wed, 23 Nov 2022 19:54:40 +0000 (UTC) X-FDA: 80165759520.03.0AAFEC8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf01.hostedemail.com (Postfix) with ESMTP id A437A4000D for ; Wed, 23 Nov 2022 19:54:36 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANJeVhV025076; Wed, 23 Nov 2022 19:54:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=sflJeV2wVdwMlYQjHBj0SDRMKKm7Vvcf9pXWfqqZHi4=; b=rV1TdDtLwPoLWookHAIwy8QkJXbr1pCHtM1UT1LVK1QLyHrcSnhATpj3VF1QOcgH97h9 aINT72XgiKlSC5xNlShJXs76+odgDqYOQ+X84yUVESniaUzYVVRAIhDmTCpzH2XrCHIN Yl6RkhMBl7V2sZUI/kR+X+8KLGhmCU5mhAe4tLjoinS1xJRqldgoHA3AvAuHmiBXiw49 KQYto2QAhxz1ECN383sGA1ExB+QQKTSEiFz2Xc6iX1Oe7lDDk3Obj5pXxsrzrGlynfYu rTXbg/+rALOWVHkC++1jDQ+JhMz669JlJGOARYCsIdclnPHopfVvmv+8k0pvovw2RXN0 2g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m1svgg13h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:27 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJMRHa034540; Wed, 23 Nov 2022 19:54:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnkd3rvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xj/xgNxNscs4NRolLxqbVHApxXANwHgo6Dkufej+54lt25sqwQWDUaBPjGdwIW7DQbGh0bQROEGSyT558J/DIeZwrX4J20IBOmVL2c7sOZ7wbXKZjs1nDHMibz6nekdcoX6bknhWJZrQ6Sb4oD3h2UhG+b0/heym9BmEKRc0mx9z2taAeEYG9GVkP4G9gZT4TmLfJLnOnP3dMbN+h7J50SMQ7HYJCpZI7hJrFk5ZGzyT3e47q9CkalgGZLVxQGOLpgbGeEsKbEvBSZdWxqnOg71TlA67TjCWyY1boZ6bTyGHn93x7hIrcS88hENJiIKCXz09NlXK4xlU6rG85X3nyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sflJeV2wVdwMlYQjHBj0SDRMKKm7Vvcf9pXWfqqZHi4=; b=icaG9zjkBtGpXgzav4Wz/7AfhK3YZFhpCvLp4v+UbdccfkzkFMBomfmxcVTd0hyUvp29hsaDpCXzCBR8Ylq35Gs/4yoq1wOpPLbbMicP9b7LvDTWgn71He8tx57IrY2xnZBXdLkkRIGiR4VcMkJLy+0wj0ZHxT1FS46bEMrY31mXcfnv0M7rRwyMMK6ylvprDkUONltOaNOJoIQ0OUfSaCmbZd1DgGu9juKm+28TpMxbboE461L0kVceHZ2HIeVKmjh4jbkocO7JPDocNii/G6B7iI9g9WXPHD9WrW3bBGNt1Q4m5E+I27Aua9ySOnsHP67kKcCdW/U8UUeeODHFAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sflJeV2wVdwMlYQjHBj0SDRMKKm7Vvcf9pXWfqqZHi4=; b=luv8GtXgNxHkJoOSSUiIKnUTxfcvyQ65JHCVjn0k9Tyw9E+5yXEjrZrPc8OG/we1HJxZRq+aMAHw4xrvkxFwS8bC1cekw7p+FXcBIIFq5BRt7dLb3lqg3jNTttxFkg5dVblHkGCyO+w1hrXspkggy0rATrgA21eq8ka3JnoqXPA= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by CO1PR10MB4753.namprd10.prod.outlook.com (2603:10b6:303:6f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Wed, 23 Nov 2022 19:54:14 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:14 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 3/6] mm: hwpoison: refactor refcount check handling Date: Wed, 23 Nov 2022 11:54:05 -0800 Message-Id: <20221123195408.135161-4-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR04CA0200.namprd04.prod.outlook.com (2603:10b6:303:86::25) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|CO1PR10MB4753:EE_ X-MS-Office365-Filtering-Correlation-Id: 65b87bff-6824-4564-22c5-08dacd8c7f70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dLGvijTuox9Laxcu5WLjolJkHACsaD1IPu6ZPYXC7RqBrGxoCk3Mg0ySuCnfW+l/Y7bMa8BYTr9ixkBjKjUwm0lQu2lOlrr2j935899yKqlin1KP4Q/v2iB1W3sDLR9DrUEJv3iyc1Ij40EhcXX5b1qxueZnFMkZ6gwCJLTYPfVuHeBrDRj2rbmC9aDqqosZZy1ZEt7sBvbb4KcNazSO0aJwQ2Why8PmX9li6qvY76hiZ4YckAB3t6DgIJV0IsH8yoCVyBjvGYhAzb9jbG8ObaQbZedimJBJkLbCJ3r0zz6aaN4xVcIyEeM0yJigtbZAEZI7eqoqcVSsByVR4mvalp3+swGPcsWtTwO3xqcVuo70FvAYXxcGHfV+iU2oytxXsEHzeCm/AfCjvvqtwJqiERcYMNC3NVH6/E17vKjr6SwBQVgB6mPzZ+BE1cg0JOCaq61v6IrvCGpvRwcDCtqujcFULbmAwS60DToujBGeuoqWfjsilLHaCFBuL4Xs+HL55ZzarXWZBoxhBpwjiDEAMrB27rP5JmAhXuqXybc2bbxYygBYxQiV/uXIZVWYxWUQ+YxKmzAeTFklxtURhDKnb9V+Gsk1dC7OZLPRyxcJIDwm017aEI30Z5V8pYrFNp89bJMUo6OZC1gv3BxsXUAiEvBqJyiDLpe+lSPqAbgk844= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(396003)(136003)(376002)(346002)(366004)(451199015)(44832011)(5660300002)(66946007)(66476007)(6512007)(36756003)(8676002)(66556008)(26005)(186003)(54906003)(1076003)(2616005)(316002)(6506007)(41300700001)(8936002)(38100700002)(4326008)(83380400001)(2906002)(86362001)(6486002)(966005)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6h6+q42av9DUrLqa5OBrvjrLtKbHacik7y6eP7HwUVZtzkTgfaZyNOZxwqy1Va66aQHReO4Z0469c9+lRgFyMKXfIquSVdrGB4oNQX6X620Ll0cXv/sexe9w775z/6x+/sxD8LynkxYXmpQRncbplpFs7z7CZVtVpkTrm7Ta6TOiifa8Xpo5smXsRHE2Q7eZJLxwjL6Z3uUhl/iJjbUm+eUyukGn4GlCnWgO63A2dImqyOYZlQ3g0tIzHQzKloDpo1z6SQu415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Bu0CEhJBtA2l14Fz7djVw7Pg/sRSo5c7VPEvlLBoJm6uhcdqpKNZG97ItHwL/KT8OCRHTITpaYI4pA+ivMMxTgkaS6AdnmKb794dzgT2eumx5QYAlsydRaNdxvZOB4oZExMAGwVYbu4RKSGIwja6y5nQYVGb9ORjxtpXvoKfB2K30QMaqkq0dx6547vaVCljzn8ZxY6VCCdgk5J7FSQuEFESIiCUXCb294S3eN/n3UxUOrUsgmxwF4EXLn5bNiSnIxn7tCQuG1QCePeLPRmbQ4DvxSrAPOhD/imdTAphcEP5q3n9wnom1aDKuMco0WzayeQVf3sdPk7sPA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65b87bff-6824-4564-22c5-08dacd8c7f70 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:14.5860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TdpQQRrUD3fnN886AAj2I2oyIfIyy8V9N9SnXIlSz3oQvbkRYhBv17ORKHHJjirdDY/W0QA0Ngj4ueMJiRZe9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4753 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: k_b8goxUQzNKjstAFDGcU8qvB_ESdO5j X-Proofpoint-ORIG-GUID: k_b8goxUQzNKjstAFDGcU8qvB_ESdO5j ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233276; a=rsa-sha256; cv=pass; b=iAHORklV1P2x5zRYGu/ClGsEyFlrLevLjdzn/QOeh1xoL8ItlGhwAkn0YtqN21I3v23Me7 8sdEPvBe1lJOb4VAYG3rkWLhbvj8mCrBQ4x/1ctUooypLemf2i83uYidxKOPmLW+mxDoWX iMaS1I9TJ7D9VuT4zyYA/jsVW1ZWq/M= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=rV1TdDtL; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=luv8GtXg; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf01.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233276; 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=sflJeV2wVdwMlYQjHBj0SDRMKKm7Vvcf9pXWfqqZHi4=; b=hHP+vHnUgmQVTo7kb/Z/8bcfxBWyp03Ces8reGYsFsVN4dNtQeFuC1DfSSOtmLX8o9zZiM jqZ7WwwtttuWLHrUaPVBtFgCGmzGrHXZlC6K4myBFLm2ANZRV0XceNGs1RdJEmIaaDMGxW 5b6P61n2lV5QyOxApeg9buHXpkILUpY= Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=rV1TdDtL; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=luv8GtXg; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf01.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com X-Stat-Signature: 3p94gosacquo116u4qcdca15tnoxreah X-Rspamd-Queue-Id: A437A4000D X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1669233276-97433 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: From: Yang Shi commit dd0f230a0a80ff396c7ce587f16429f2a8131344 upstream. Memory failure will report failure if the page still has extra pinned refcount other than from hwpoison after the handler is done. Actually the check is not necessary for all handlers, so move the check into specific handlers. This would make the following keeping shmem page in page cache patch easier. There may be expected extra pin for some cases, for example, when the page is dirty and in swapcache. Link: https://lkml.kernel.org/r/20211020210755.23964-5-shy828301@gmail.com Signed-off-by: Yang Shi Signed-off-by: Naoya Horiguchi Suggested-by: Naoya Horiguchi Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Oscar Salvador Cc: Peter Xu Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mike Kravetz --- mm/memory-failure.c | 107 +++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 35 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b6ab841d1db7..0f77ec1985dc 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -650,12 +650,42 @@ static int truncate_error_page(struct page *p, unsigned long pfn, return ret; } +struct page_state { + unsigned long mask; + unsigned long res; + enum mf_action_page_type type; + int (*action)(struct page_state *ps, struct page *p); +}; + +/* + * Return true if page is still referenced by others, otherwise return + * false. + * + * The extra_pins is true when one extra refcount is expected. + */ +static bool has_extra_refcount(struct page_state *ps, struct page *p, + bool extra_pins) +{ + int count = page_count(p) - 1; + + if (extra_pins) + count -= 1; + + if (count > 0) { + pr_err("%#lx: %s still referenced by %d users\n", + page_to_pfn(p), action_page_types[ps->type], count); + return true; + } + + return false; +} + /* * Error hit kernel page. * Do nothing, try to be lucky and not touch this instead. For a few cases we * could be more sophisticated. */ -static int me_kernel(struct page *p, unsigned long pfn) +static int me_kernel(struct page_state *ps, struct page *p) { return MF_IGNORED; } @@ -663,18 +693,19 @@ static int me_kernel(struct page *p, unsigned long pfn) /* * Page in unknown state. Do nothing. */ -static int me_unknown(struct page *p, unsigned long pfn) +static int me_unknown(struct page_state *ps, struct page *p) { - pr_err("Memory failure: %#lx: Unknown page state\n", pfn); + pr_err("Memory failure: %#lx: Unknown page state\n", page_to_pfn(p)); return MF_FAILED; } /* * Clean (or cleaned) page cache page. */ -static int me_pagecache_clean(struct page *p, unsigned long pfn) +static int me_pagecache_clean(struct page_state *ps, struct page *p) { struct address_space *mapping; + int ret; delete_from_lru_cache(p); @@ -705,7 +736,12 @@ static int me_pagecache_clean(struct page *p, unsigned long pfn) * * Open: to take i_mutex or not for this? Right now we don't. */ - return truncate_error_page(p, pfn, mapping); + ret = truncate_error_page(p, page_to_pfn(p), mapping); + + if (has_extra_refcount(ps, p, false)) + ret = MF_FAILED; + + return ret; } /* @@ -713,7 +749,7 @@ static int me_pagecache_clean(struct page *p, unsigned long pfn) * Issues: when the error hit a hole page the error is not properly * propagated. */ -static int me_pagecache_dirty(struct page *p, unsigned long pfn) +static int me_pagecache_dirty(struct page_state *ps, struct page *p) { struct address_space *mapping = page_mapping(p); @@ -757,7 +793,7 @@ static int me_pagecache_dirty(struct page *p, unsigned long pfn) mapping_set_error(mapping, -EIO); } - return me_pagecache_clean(p, pfn); + return me_pagecache_clean(ps, p); } /* @@ -779,26 +815,38 @@ static int me_pagecache_dirty(struct page *p, unsigned long pfn) * Clean swap cache pages can be directly isolated. A later page fault will * bring in the known good data from disk. */ -static int me_swapcache_dirty(struct page *p, unsigned long pfn) +static int me_swapcache_dirty(struct page_state *ps, struct page *p) { + bool extra_pins = false; + int ret; + ClearPageDirty(p); /* Trigger EIO in shmem: */ ClearPageUptodate(p); - if (!delete_from_lru_cache(p)) - return MF_DELAYED; - else - return MF_FAILED; + ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED; + + if (ret == MF_DELAYED) + extra_pins = true; + + if (has_extra_refcount(ps, p, extra_pins)) + ret = MF_FAILED; + + return ret; } -static int me_swapcache_clean(struct page *p, unsigned long pfn) +static int me_swapcache_clean(struct page_state *ps, struct page *p) { + int ret; + delete_from_swap_cache(p); - if (!delete_from_lru_cache(p)) - return MF_RECOVERED; - else - return MF_FAILED; + ret = delete_from_lru_cache(p) ? MF_FAILED : MF_RECOVERED; + + if (has_extra_refcount(ps, p, false)) + ret = MF_FAILED; + + return ret; } /* @@ -807,7 +855,7 @@ static int me_swapcache_clean(struct page *p, unsigned long pfn) * - Error on hugepage is contained in hugepage unit (not in raw page unit.) * To narrow down kill region to one page, we need to break up pmd. */ -static int me_huge_page(struct page *p, unsigned long pfn) +static int me_huge_page(struct page_state *ps, struct page *p) { int res = 0; struct page *hpage = compound_head(p); @@ -818,7 +866,7 @@ static int me_huge_page(struct page *p, unsigned long pfn) mapping = page_mapping(hpage); if (mapping) { - res = truncate_error_page(hpage, pfn, mapping); + res = truncate_error_page(hpage, page_to_pfn(p), mapping); } else { unlock_page(hpage); /* @@ -833,6 +881,9 @@ static int me_huge_page(struct page *p, unsigned long pfn) lock_page(hpage); } + if (has_extra_refcount(ps, p, false)) + res = MF_FAILED; + return res; } @@ -858,12 +909,7 @@ static int me_huge_page(struct page *p, unsigned long pfn) #define slab (1UL << PG_slab) #define reserved (1UL << PG_reserved) -static struct page_state { - unsigned long mask; - unsigned long res; - enum mf_action_page_type type; - int (*action)(struct page *p, unsigned long pfn); -} error_states[] = { +static struct page_state error_states[] = { { reserved, reserved, MF_MSG_KERNEL, me_kernel }, /* * free pages are specially detected outside this table: @@ -923,18 +969,9 @@ static int page_action(struct page_state *ps, struct page *p, unsigned long pfn) { int result; - int count; - result = ps->action(p, pfn); + result = ps->action(ps, p); - count = page_count(p) - 1; - if (ps->action == me_swapcache_dirty && result == MF_DELAYED) - count--; - if (count > 0) { - pr_err("Memory failure: %#lx: %s still referenced by %d users\n", - pfn, action_page_types[ps->type], count); - result = MF_FAILED; - } action_result(pfn, ps->type, result); /* Could do more checks here if page looks ok */ From patchwork Wed Nov 23 19:54:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054177 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 77437C433FE for ; Wed, 23 Nov 2022 19:54:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E95906B0072; Wed, 23 Nov 2022 14:54:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E45416B0074; Wed, 23 Nov 2022 14:54:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C71D66B0075; Wed, 23 Nov 2022 14:54:29 -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 B92226B0072 for ; Wed, 23 Nov 2022 14:54:29 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 91B2C40A4A for ; Wed, 23 Nov 2022 19:54:29 +0000 (UTC) X-FDA: 80165759058.03.4CADDDC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 1A311140009 for ; Wed, 23 Nov 2022 19:54:28 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANIhhLs015621; Wed, 23 Nov 2022 19:54:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=pVtfB2cwHEzBeKcBPzU1VOg9DZild1IftBR2Y8xWutM=; b=rgtDgwlqJuiDeGiVfhmg7su3lXY8n2xrS+LKC9yRpzje2F9cJ5wubM1tMfOlVlyHP7YB bkUoZfFPSus6NW8d66tIMuYdljZaMrr7D2zguAagl/aPRvtGqtReR3745jrQUm1CEXJT poHc1YdLqA0q/nk/qXoCwfiE5K38KC+PYFePkkpv294ZgA0cMNEUoNZkLjw+mH3JoYZM 0qOzgwHnjvoPvugfeCwSZYTPmR6JeBOvMfr7cem1uCBn18aweYMJeqOkkTro+S2RjxPF hBk8eFOzi3TSXvlpZyHTmse6yug1oy/kWLRnOxnjle35puXg+H1nfLLVQpbMtj2U7sih Ag== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m169535x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:19 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJQ8kM015585; Wed, 23 Nov 2022 19:54:18 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnk78qdt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRCsBhP6cdTyCe/AJoLdut9B1cGhb4F4KsjRP2yZ3xy3WnHD/H3jTPHIFO6wViEE3eZYP3pyTRiH3uLYzjW+gyotnlUSLBNyvAqncOW3oxmbvG1GvdEfIaBKIh5h8RiwWWRgFmwziiugJAntAeouMet3r6yNhWglMSVdxdOoKRc1arh0DtuqoT1Uf07CsQs1AgFGvxN9JvNJVOD2n6hozwUaUtK8xEorDjx/+0hwnsYdLfPunAeZk09m9QaGSI6ESrBJ0w3f36KHIw5fSOwRKnCc1rbsBUTIr9R9zLCvZYo/ZQWmCJNk+u24WWh5i/LmzEHW9e3KWF+wDRlGtqpkCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pVtfB2cwHEzBeKcBPzU1VOg9DZild1IftBR2Y8xWutM=; b=gCm69XHItvVivqzzphyK0a3KJhmS55cikuqzus/qRTBJ8JBoS7g7X0hPOE+wQWKg2DWjdsJoexu3sUzzL1WKyfk/6QOZ8mXyaUtaCG4ZvN2IG+oMf+c3DC+p+DwbVnppsS7hWsU4O7irhfkgjvxSZoOxNp4Q4o5V3Rew/8jbTw80k24XXptvjT8PM+yM5Qg10dhDVO76/Yj8bq+8TEdKEXi2tGNSX1xaSFnHkQolXu6nBxFgTJHKszcKXss4SDnqWwdDQIsbrqEJ3gBqCnVVCu5Wtjj1+sQMXJOQDkOzF88kVMTXPvn+q2w0h2EoJrrJrurUazIIp9v/YMc7ECKUEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pVtfB2cwHEzBeKcBPzU1VOg9DZild1IftBR2Y8xWutM=; b=LKsKEXYOthItOdtW1x7FwtmfKNRwzo4iYfK9xuN//8Nam8K6d1TUmxb5krILur3n5vD0fojD+4s84hvsJ6HmjKiVk10vQitB4w3k/kqeYnogaSpIZHO428b9MMNw59LeR98ILs1Rz/VNhxdRsOQZtYRXIyYHaSAhOAgtN9Sdabc= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB6300.namprd10.prod.outlook.com (2603:10b6:303:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 19:54:16 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:16 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 4/6] mm: hwpoison: handle non-anonymous THP correctly Date: Wed, 23 Nov 2022 11:54:06 -0800 Message-Id: <20221123195408.135161-5-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR04CA0055.namprd04.prod.outlook.com (2603:10b6:303:6a::30) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB6300:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bd5e6bd-b500-4a23-0bc1-08dacd8c8068 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8lesDBPSAFtYwHlFCoV9GNk19GlPEGct7ZJ2gv8D7qOv7sRgHltgWDDppX4IXD56k0Zw2SSsUe6Jb9S6XKhVHT/jniWG4Y9LCw7g4H4pVWpnvvA5koVAkQXoXi93phB4ElHG64p1r5i2O2G5qcfIhLRQJkXglAAZq/iHZ6OKYXQZeutNKci7gCeL5zSu7Fxc3ZO/Th/p0dFA8h4NewG65/oTkrgBvAh04yaVi1s12z8vpVY9eOiZgkZQiDwQB3zMDWeFfD4qf7H02yAU7W0HxpVbyz/WenxY31K66/eER983WApmvcWuFo1BqKyvc/9NBaStS7meSnGK+3dAovHFHC5uTly3LVdFyR2bbpjHglM0S/Z35L/gGijVQKviDuzF1HNq7jKv6qwqLG4iqBDbK+a3Pw2ne6/ExsCAEJZNwDf61mfOxOXCpW5NWVhrO0O6WLVwfsXZy0jLMOsoz18iiF8iBYPbYevXHqSvXMlcKG2Jclso/kooVT0/ypijbPTxp2T3DyWd4rYG54ByKDo/1xZXusi3GvukUuDg/Djm2pHwZJBEIN7qev732OX9mOZ1sKlLepLZixIciem+DDpw1zZOFEJnRwqL4jyzTOlcrH2+ZGsYscXAMlmIcHd8YOAyt2Qbgzw8kP3kveTAT5FVNrA+QZzRMM6cauePi5lgxYs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199015)(36756003)(316002)(54906003)(6506007)(186003)(1076003)(83380400001)(2616005)(966005)(6666004)(6486002)(26005)(478600001)(6512007)(41300700001)(44832011)(8936002)(5660300002)(86362001)(38100700002)(2906002)(4326008)(66476007)(66946007)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DpWtcAia0oK4Jb3csNMRdWnbCqR4GN8eHXwwA0QL04TBAeF6pl5nGMcqL6Kld6T5oOzD7+aRX9g4+qE7XbmUa6xhGJ6UZKgKLtv1kbk1zCsH8zUFkITA66gA4ZbAZrzR16V0/KxjtBiiC9Y47fqA3ja8n1vmF9+4+macQ3bxYLgbIu4+xB226h9DQq5IG1vzL/OSUNBIAWznOcZsXWurro6lYhgjIQObjvu296ezHiZyFM7SbvME+GxBY2/jtnPK9tPWIxTjLOB5qzX4U03bVz6Wkoxv5JGqITNClv4tffJLLQat4jJk/71VlQuYPyThM6jzzsWSMS20T7LpUCc844PRR/nZ4m5dNrY5l6UjDJV9Rjqt30SaLQqJWOQtZ8b3yiN3/g8HJ55CVtonFLw/g0NsGOvIbgI1nJI5kNVIYWG4hHJRgqJLWjqpWfes/YEi4UpePon7Rs+at8FHwWXe9FDVU5xdIDM7DNRkbewaINzKkM3ARLkUpDcykDWloO3WRyrpZbVzNqj1PGYk/nF8c3175Mq0iyXj+QoRfeDk6R6bgZwEks69NoaZusLldbnh0E0rDKLu7cTpEkcAQM2E9XHLCcpaJUON7Az2g3HBxZR8vno9Uys0kXHcGGAAf3hUfT+RU52FK9M6EKOyqc4Y6BfYCVvAu+6L3/GjV0OmuJAyDyfkEFFsuPqAe2YgKqYvugLw7f6maodKomh1+30UKR+CyNr37e+NuApWLg2FBsSg4eft6Be6vC648DVjQQ0y0MaZPsps3wm93436jIPHTRPsyLyygd+Pg2Tf79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Ds3xxXyN0ix7fjb7VgnKaoJzwNrxDdJHm8tAqiIKcuEy9ZYot+JbbiYCo5Uh0AHfZcumrNy0qPrJroGfdWgn6LiaDTDxzTr90ruKWLxhnvxGuJlRMHVA0DADLx/IbKinCcLMQsgk9O1L2zywSHiZAzMzP0ubzk5jOQAgKYBhyblFWzQvV6YHkjPaBAlVqjEdilTrHslQlsxpjk82qxKv67H7ECh/l9oNRhQ0zxukhO3dj7shYUHR8fGZlY07GasvpuZym3RN3QrK7u+TZIuDMp1oBhQvLwPefoJbizjbmrNN1Qt/pmNNukkJyYgoTu3P99+dEsxCOTPv2ORUJp2i7+sszj2/2iH0HewQAhurBmkwO1nm7UkyZcYgvCYxznqhW/HL3+vUjX0jOJQCwxorHQidSFqfs910NEh10AjazmT+T7ETEsIUmrRbFCMm4fpq4DCbeNuwPXbV9qxEdKFq0diZnnQo2vO1wxOa5niGZ4OvB1k65PMfkw6zhloddqdUfput6pvSEtxCMLbH0cKWPj9O52AD2C2at6wIFhFTR3sRQ2eFf5J4a2Ax4494fFkQxootxpBCsGSx4B9gFjbCSsh+p3z7K3uWlj4U963KaFbAJHLM1gVa5quQ3p3yLo9SAYjMgcakRd8TlUGV+bNJTozecXXdiyxEuwZj9FZnJh+AICCoYoT8j7VtV6L7YI6BjY0xc46ukGU/XwlUlwhWKIHTx/1f+QIxC0+6MPwRgs84KRY3I6qjTy1IIbbdbvAOOr4xNzp9CTFPurH00py4p//txKl2aeUNJbtKQpT9THs5kP4nmPYuVb1oy5fADtbmA2QJooLqg04SWTOtfNYBWBm4RcYpw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bd5e6bd-b500-4a23-0bc1-08dacd8c8068 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:16.1182 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0vkKjEqWIVO/fwdbt3RReK5BpNpjQmMIdr72FtT+dY7JidxWQ0d3bvqQLhoDEbe5jT32otC2vA30BNbx8Zg57g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6300 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: yOzyaioO4GvBuckF64dTkjCHXxmYYQIK X-Proofpoint-ORIG-GUID: yOzyaioO4GvBuckF64dTkjCHXxmYYQIK ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233269; a=rsa-sha256; cv=pass; b=ebZs2TC9rmvcO43AT0MWdp10b2h474XnadEkGkWPg1fCzZ9Zj2M9EBMIHMlaRewWl66E1z wXzye6z3Xm6AlWb2FOsvilMRD4Fq4vRE7zMcavWwXC1ZYl+AFiL99uZAtAxpBztGooZY2I HXV+7ckIte9xw1g+XmG6qTaRaQi1yts= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=rgtDgwlq; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LKsKEXYO; spf=pass (imf23.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233269; 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=pVtfB2cwHEzBeKcBPzU1VOg9DZild1IftBR2Y8xWutM=; b=Pgsp3R6cxo3ixz2LSAgzPScITOZ6wNHDyDeSM9PX2aFNZjHMuf8kgi811dxja5uHNfubHh uRx6FcPa7HTd6fjpK4UKJxjXhoyPIf0wmPP4QefRywiitlbr7F2a61H9FmVoi8iSQE98yJ NyNMl+lH/oZRbZ4QhqrQE4mO1q/Zoic= X-Stat-Signature: yssu77tbz8mi1ww3etnz6a4pk7hii5rb X-Rspamd-Queue-Id: 1A311140009 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=rgtDgwlq; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LKsKEXYO; spf=pass (imf23.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspamd-Server: rspam02 X-HE-Tag: 1669233268-862942 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: From: Yang Shi commit 4966455d9100236fd6dd72b0cd00818435fdb25d upstream. Currently hwpoison doesn't handle non-anonymous THP, but since v4.8 THP support for tmpfs and read-only file cache has been added. They could be offlined by split THP, just like anonymous THP. Link: https://lkml.kernel.org/r/20211020210755.23964-7-shy828301@gmail.com Signed-off-by: Yang Shi Acked-by: Naoya Horiguchi Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Oscar Salvador Cc: Peter Xu Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/memory-failure.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0f77ec1985dc..1d37de089008 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1154,14 +1154,11 @@ static int identify_page_state(unsigned long pfn, struct page *p, static int try_to_split_thp_page(struct page *page, const char *msg) { lock_page(page); - if (!PageAnon(page) || unlikely(split_huge_page(page))) { + if (unlikely(split_huge_page(page))) { unsigned long pfn = page_to_pfn(page); unlock_page(page); - if (!PageAnon(page)) - pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); - else - pr_info("%s: %#lx: thp split failed\n", msg, pfn); + pr_info("%s: %#lx: thp split failed\n", msg, pfn); put_page(page); return -EBUSY; } From patchwork Wed Nov 23 19:54:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054178 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 BD8B7C4332F for ; Wed, 23 Nov 2022 19:54:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67F286B0075; Wed, 23 Nov 2022 14:54:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6317A8E0001; Wed, 23 Nov 2022 14:54:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A4496B007B; Wed, 23 Nov 2022 14:54:31 -0500 (EST) 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 285546B0075 for ; Wed, 23 Nov 2022 14:54:31 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E1F94AB911 for ; Wed, 23 Nov 2022 19:54:30 +0000 (UTC) X-FDA: 80165759100.26.59DCECD Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 4D749120015 for ; Wed, 23 Nov 2022 19:54:30 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANIwxiI006018; Wed, 23 Nov 2022 19:54:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=wAYQ4kHlIXiOKqHFbvdAoEbuKL1oIyz6KTJZkriajj8=; b=dLbWs2mE9XaHP9J5V38ThnB3ZYx6IT4M343g9yUyHetqwE9SfdN2rzWZ83m55ZImNUhA 23G2qXx4HgznMpV5N1nOIRfGlW8NyB3YRxEObYZDrayDeHjRFNly8US02OcqGgmp0kQz 8n8rbGBToLjPa2pzRxb6I8hC3kaYxa+dK1TqLA/iBiC1i8jZlzujamYxvw3KpWaFcD1Z j3C/kMHXUUJWwyo5sMESbZi7KpyQLCVR3XKr8szUIqo+1L7Vs1HHw+BUfAfKEt6jmQQR BIItyyHWZkwulT/N068mB2PomxyXm+JxnoQmkyme4uhxhC4qCsr5A4KLQ7WhgVpssqRG qw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m169535x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:20 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJJ3gb009704; Wed, 23 Nov 2022 19:54:19 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnk7gwu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qx5vWECvpPXiTN8NUFkdMUocmJcwyW/qwbo0dBuH61ylR6PR8/1oMsO2XQt+cxoTe14XEHOZ6Wy5wTM59PadFzx0Xb6vZzEUAnYECGhs3b5GXIkYdGPEfJtvfnfjrkfwp9JIF8GoOXAEJIK5eZT6j/03sRPnRVyUJZrwrRQ5l69dhq+wGjSCNXVBHG0Esw0xOsaag1yeV0oyTiYkg/dko9TXj6uZLHl+/UyhTHkj5B+ftvo3z2CuXK2mexicQuhw1lV5WcWHsHyQb/5ADcjRQA5xlNbx+u8L825853WS1cmKrCaTbqe/ebW6LLZKXQCWKdx1zds2F5vPNxkO9tN5rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wAYQ4kHlIXiOKqHFbvdAoEbuKL1oIyz6KTJZkriajj8=; b=Nyn7e5h/felysYm4aV2mpsFGw7mVHCJa7OuHJQfyn+bgehwXAzu33HX48//RsUnuMaDLC0ad1kknD9NvZHpwvkSCoqVWSMq/zSkruWb4YSEZqhGfwZotOhrnGc5CqVc8TzrjG1nvQaFMGSxvxKz0qAlXVEX5qFQXkXa54CRZhJPBEV6n3QUalNM8IYtI6dHl2+7eum3oBQ/wLXNMmljK+AncSafvZYYnJWFL6GRZhI1vcq4CdWQWQ3IFPc+nRc9+yQuBv9q9qDhN5ZspXi5g0SRqk1+ucTwvQiZKwWjpA3M3+IeDc/Zl2LENd9SVfK7ABR8FokkAeT1Y4DRw8PUsgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wAYQ4kHlIXiOKqHFbvdAoEbuKL1oIyz6KTJZkriajj8=; b=AwDfuvQfViPRMXx77xa4qRFeFFYJOWZEqkW/DBoVdh6VsSS1oV+VE3fzfuLP+OBZGnKvIPJXb4dXSk/BJltHJ6SghBAGCm2EUn3PW/JVYriQ8+nbBzm9pzhlg4qQ9cVNvFrKRLOTTnK3Dccq0rFzda37u2lpIbPf1VfTyiDGLCM= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB6300.namprd10.prod.outlook.com (2603:10b6:303:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 19:54:17 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:17 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 5/6] mm: shmem: don't truncate page if memory failure happens Date: Wed, 23 Nov 2022 11:54:07 -0800 Message-Id: <20221123195408.135161-6-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR04CA0250.namprd04.prod.outlook.com (2603:10b6:303:88::15) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB6300:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c6e0f68-266a-4d9d-9cb3-08dacd8c8156 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 52bPhwbaJ164Ivr0ctEkR4GRxidtQIzRibO/3XqarT3h8rAq90ndcOaAJdi+764XdhbxpNwOQopIlNZGOuT2vx3PxJ4kbJ4Ezvg/DOcwO33YIGjiYxdk+vglgjqF/cTp4WKeGDK1P4WhXXIqJemquyX6ijjg4H7oMRReGr5//i4FVArVGrjASlkk8nQ3IUrOS4y6RqUqSOjYyifXWN0vQ6Wd5FgSqkUnyG6ca5Gssee6iChjpjvCWHpAJ5zwmFhmywSaqf99bWl09S9WT+RrZD99uw9Hr6qoj8pHsmbf/FxwY3ks2az5F03UpEaNHilj5vzMfA7wknVrwSTdBuwaQB3ORPgHlfU3RIAfCdVhPd+HaDqxiFKMyTImWgi33MYxmt8ivTf8v/IpFaBQekqMYY3qE8del6gpXY6d8Fv8Yt1yZKd3mwitdE0BmEXt7cct1O2ymv3nnuilMwNR+kuMCsmNWvCcaHXd4NQMZB6ZSbWMAl+1rYk1+TdnThXJUzdyBhL9LMXpOCpXL5PM+Q5EANGqcRbidUNoT1wga3lmDIdv8s+PwjU5LdzWLNYAV1SP05eatC2d1lto4PmG5T7GWbiLi7TMtMt0N8mzNq9LfqAmXAODOX37lRklU7bZapodHUb63S4K/n/xh4hk4ep7eRiZzPwCKlLezZsgcgfJcmocxWLw/rNfSQ23qz/w2FH9w8eP69kamT/9wEEWz2fZNw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199015)(36756003)(316002)(54906003)(6506007)(186003)(1076003)(83380400001)(2616005)(966005)(6666004)(6486002)(26005)(478600001)(6512007)(41300700001)(44832011)(8936002)(5660300002)(86362001)(38100700002)(2906002)(4326008)(66476007)(66946007)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N+n9AFpabryHXRahR92WoeEPwcBZAVlsgR7ID5K7mxoG4S07eZEdq04PV56pq5dMfqUPerRk8ULEaLGKWAUf8uHyMglPAkV2QdaF9sGDolVaW2qI0dP+s1ZBcnG/hKAkuOy4u7gqZbCyBtW9UKvf6H/o5O0PZSO+hF2y3BnBjvNt9jL5LsPtZf81DezPKw8goL5Ok7R0WL8eKEgzvAUa1O2o2Yjwgcb2jHWZFEtn70cGNDWnOufd+rVy1VjDPcl+0T2Ui66MO/K31jsRUTCtec4E0qyMDO1drq9l+rTcWBU0CZSnd38JU4nJAKQjOZ+cG8mAGysfjrJOi9hvT4CGHAL4eXgN2PQytZY1EZAyAHjGyChB00vHoj9NnYJKdVW41Y4Jl0Vzo7e0SqF2cYjezmNUI3OHO/iuT/hlcH7DrHAeqEZuwAAyFaxpK1K0YwjYQccbJQekWiDHxO9hko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UUI/jplQfW29EfzO0Pf7EE5c9LdbwU8d/ARnMqL+9kM7iq3ihXEAvODmxkI5oFw5490o2Bk89k29sGB06EbwutHYdIVYuuFz14ObatVjzGIgc7AUPOQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6e0f68-266a-4d9d-9cb3-08dacd8c8156 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:17.6962 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XmNN2CTC1h+bJNQBNp5A0WAFljI7LMw3g1hTVa8U2IBdtuNwHrajemEOhDFXSz/JXF1eufSFXepbpw0uuQqQGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6300 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: y5DIevq3OccUe0nk_iK2G2U1wj8_N1G3 X-Proofpoint-ORIG-GUID: y5DIevq3OccUe0nk_iK2G2U1wj8_N1G3 ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=dLbWs2mE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AwDfuvQf; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf29.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233270; a=rsa-sha256; cv=pass; b=Dl9/7phCqNmo8tzEQ+NQ1Mswc5Y1ftpnIZLgSiUPGotMgu2W4mPxa1A025QWP6JADCHSOo IbZREo7IH2pOT0hdW4CjS+2IbQD8wPUz3yr2f35tXL8uAZku2V29cmhrqlhHGmAyikQ3N2 tja6WL2h852Ce0OKkOeaeL/fEtQGYsM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233270; 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=wAYQ4kHlIXiOKqHFbvdAoEbuKL1oIyz6KTJZkriajj8=; b=TYnjswP6u5z/OfM58bBKuEafA9klQdIVWtLAcVeElNY61xxF1RrY+vwbQi7teCwLVIoqTK 6R1kJGctTVFIUqmueS+sBhKmRp9xGeW86EZDwLw2SvBFngP0VGjcFVwFJ3/g3Pwms2sVl5 n3Am8McFdijI1Fd9fdSnI1cmnuvzW2I= X-Rspamd-Queue-Id: 4D749120015 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=dLbWs2mE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AwDfuvQf; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf29.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-Rspamd-Server: rspam06 X-Stat-Signature: yd3x5xrbjzzdep3bnzjnw9b1eemhzza9 X-HE-Tag: 1669233270-852612 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: From: Yang Shi commit a7605426666196c5a460dd3de6f8dac1d3c21f00 upstream. The current behavior of memory failure is to truncate the page cache regardless of dirty or clean. If the page is dirty the later access will get the obsolete data from disk without any notification to the users. This may cause silent data loss. It is even worse for shmem since shmem is in-memory filesystem, truncating page cache means discarding data blocks. The later read would return all zero. The right approach is to keep the corrupted page in page cache, any later access would return error for syscalls or SIGBUS for page fault, until the file is truncated, hole punched or removed. The regular storage backed filesystems would be more complicated so this patch is focused on shmem. This also unblock the support for soft offlining shmem THP. [akpm@linux-foundation.org: coding style fixes] [arnd@arndb.de: fix uninitialized variable use in me_pagecache_clean()] Link: https://lkml.kernel.org/r/20211022064748.4173718-1-arnd@kernel.org [Fix invalid pointer dereference in shmem_read_mapping_page_gfp() with a slight different implementation from what Ajay Garg and Muchun Song proposed and reworked the error handling of shmem_write_begin() suggested by Linus] Link: https://lore.kernel.org/linux-mm/20211111084617.6746-1-ajaygargnsit@gmail.com/ Link: https://lkml.kernel.org/r/20211020210755.23964-6-shy828301@gmail.com Link: https://lkml.kernel.org/r/20211116193247.21102-1-shy828301@gmail.com Signed-off-by: Yang Shi Signed-off-by: Arnd Bergmann Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: Peter Xu Cc: Ajay Garg Cc: Muchun Song Cc: Andy Lavr Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mike Kravetz --- mm/memory-failure.c | 10 ++++++++- mm/shmem.c | 51 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1d37de089008..7d96be8e93b7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -56,6 +56,7 @@ #include #include #include +#include #include "internal.h" #include "ras/ras_event.h" @@ -705,6 +706,7 @@ static int me_unknown(struct page_state *ps, struct page *p) static int me_pagecache_clean(struct page_state *ps, struct page *p) { struct address_space *mapping; + bool extra_pins; int ret; delete_from_lru_cache(p); @@ -731,6 +733,12 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) return MF_FAILED; } + /* + * The shmem page is kept in page cache instead of truncating + * so is expected to have an extra refcount after error-handling. + */ + extra_pins = shmem_mapping(mapping); + /* * Truncation is a bit tricky. Enable it per file system for now. * @@ -738,7 +746,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) */ ret = truncate_error_page(p, page_to_pfn(p), mapping); - if (has_extra_refcount(ps, p, false)) + if (has_extra_refcount(ps, p, extra_pins)) ret = MF_FAILED; return ret; diff --git a/mm/shmem.c b/mm/shmem.c index d3d8c5e7a296..8b539033dfe2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2521,6 +2521,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping, struct inode *inode = mapping->host; struct shmem_inode_info *info = SHMEM_I(inode); pgoff_t index = pos >> PAGE_SHIFT; + int ret = 0; /* i_mutex is held by caller */ if (unlikely(info->seals & (F_SEAL_GROW | @@ -2531,7 +2532,19 @@ shmem_write_begin(struct file *file, struct address_space *mapping, return -EPERM; } - return shmem_getpage(inode, index, pagep, SGP_WRITE); + ret = shmem_getpage(inode, index, pagep, SGP_WRITE); + + if (ret) + return ret; + + if (PageHWPoison(*pagep)) { + unlock_page(*pagep); + put_page(*pagep); + *pagep = NULL; + return -EIO; + } + + return 0; } static int @@ -2618,6 +2631,12 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (sgp == SGP_CACHE) set_page_dirty(page); unlock_page(page); + + if (PageHWPoison(page)) { + put_page(page); + error = -EIO; + break; + } } /* @@ -3210,7 +3229,8 @@ static const char *shmem_get_link(struct dentry *dentry, page = find_get_page(inode->i_mapping, 0); if (!page) return ERR_PTR(-ECHILD); - if (!PageUptodate(page)) { + if (PageHWPoison(page) || + !PageUptodate(page)) { put_page(page); return ERR_PTR(-ECHILD); } @@ -3218,6 +3238,13 @@ static const char *shmem_get_link(struct dentry *dentry, error = shmem_getpage(inode, 0, &page, SGP_READ); if (error) return ERR_PTR(error); + if (!page) + return ERR_PTR(-ECHILD); + if (PageHWPoison(page)) { + unlock_page(page); + put_page(page); + return ERR_PTR(-ECHILD); + } unlock_page(page); } set_delayed_call(done, shmem_put_link, page); @@ -3866,6 +3893,13 @@ static void shmem_destroy_inodecache(void) kmem_cache_destroy(shmem_inode_cachep); } +/* Keep the page in page cache instead of truncating it */ +static int shmem_error_remove_page(struct address_space *mapping, + struct page *page) +{ + return 0; +} + static const struct address_space_operations shmem_aops = { .writepage = shmem_writepage, .set_page_dirty = __set_page_dirty_no_writeback, @@ -3876,7 +3910,7 @@ static const struct address_space_operations shmem_aops = { #ifdef CONFIG_MIGRATION .migratepage = migrate_page, #endif - .error_remove_page = generic_error_remove_page, + .error_remove_page = shmem_error_remove_page, }; static const struct file_operations shmem_file_operations = { @@ -4316,9 +4350,14 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, error = shmem_getpage_gfp(inode, index, &page, SGP_CACHE, gfp, NULL, NULL, NULL); if (error) - page = ERR_PTR(error); - else - unlock_page(page); + return ERR_PTR(error); + + unlock_page(page); + if (PageHWPoison(page)) { + put_page(page); + return ERR_PTR(-EIO); + } + return page; #else /* From patchwork Wed Nov 23 19:54:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13054180 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 85C56C43219 for ; Wed, 23 Nov 2022 19:54:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CB358E0003; Wed, 23 Nov 2022 14:54:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 857C48E0001; Wed, 23 Nov 2022 14:54:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C0688E0003; Wed, 23 Nov 2022 14:54:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 477598E0001 for ; Wed, 23 Nov 2022 14:54:34 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0B9801A0D74 for ; Wed, 23 Nov 2022 19:54:34 +0000 (UTC) X-FDA: 80165759268.22.48471ED Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 77F15120012 for ; Wed, 23 Nov 2022 19:54:33 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANJiX3s009796; Wed, 23 Nov 2022 19:54:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=5tRxGy5FG4mi1QJpxm1TCWGzceqRhxVq49lDSjVquw0=; b=C6m9/hgabY/gVrfIUn11CirZXP1TfGxPpb2gug/7S4eGLapBfGWUYtQqPs2tmLfhwpPN Z2am/yaM3kxMa55TXDLNKz8RP9mdVBAEBXRrAtKd1A8qJeziBEH2jSlWbk7MvickLei3 9iAFI+YpSSh71beU9Q8K572kBd+lcB/FUd/yjRDWisDfwjxS9KIbUkC4Ren4L87CB3e4 o6PFfia0xzZMqXNcoy5xFEhSRp+RhoFwCoJKrNeLNGGaSENh16zeqwQjD7kWHbDrbyFe 2YOEv8PI93NWWDvixcBi1Qw9Fw3u4TlbC5TwPiCq0qxYE6+L8yXjxCYqNiB+9aTomE+Z 7A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m169535xf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:24 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJU7YJ015679; Wed, 23 Nov 2022 19:54:21 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnk78qf9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 19:54:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOUEs2DWuHqj9ergQqFVYCtkAWCp9c7bWiFighuoVoPTRHkTILF7MVQgECLq1gZygT0ZRDsUrYQtkTK6CdGa6x7DDp1ePNeu3MGre3a4nhueFB9tFAmdODcx0I9+N5d97TmMiA49WSTe4RCGmeh/t7U030qzPTeGgbb8y2vAvwOmNH4Bc4FdiDpzB2uuwF4fCzyZrH4Bu4pu7vCxCsFr74rvpe2Xtaj9LdtLA/uwXsSsZ13V8hJ1eCHGQx63PpJyc5WuL6SLB5ifsBmJlXKLyPJGaT61VpRD26wadMr5wtz906EmWG7Ui3JBhnKJ6e2JIG2A537i9jU/+l2jYJpCtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5tRxGy5FG4mi1QJpxm1TCWGzceqRhxVq49lDSjVquw0=; b=Dwn5rqiSmKPZVf3HE9AbgtZ0zZ10E4RWeJQd783/G6egfLqGUYDnRq1JIb31WH8mPOazZfWwkuegFI8muTxZlPtnDyRP1dUxYt5aFemfGeBr7OPLOj/HF0wJ1jFdBMEa7ualX0rWcoMp9ZaKOxcqhn3GqOk8NRiZ7OAXsDc0mjlfYiXDGndcp+J+50dlEJKpxOhKrAbNyO4f8SP2Eq74rH52jTAMYTavv5MHv4gniiLYJuLGaLQGckGZYIpDsbKfS1cct1+i6ccqZR+XrzoM8q5+Q96sB8WhAdpNEBGLGEgXP/4WxL1LllB1nEbkmFzP1TYdBhIq1RaLgmcMuy2AGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5tRxGy5FG4mi1QJpxm1TCWGzceqRhxVq49lDSjVquw0=; b=VlemyaOYdflt+e5tCVXVmwpG32uZLSNd3CUY4LsjjHACY/QiuJHJ9rrDlHsHKPYJWtDmQzDyXMyMYYT+ta+7xDRpBqf/7ineKK2A+oMT0ybzJWEjRCZp9S2aUl8fLLgmF4anCjgVSh8f1rWrTOfCYpUtshsA/0L/VZ9V/3uqxoE= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB6300.namprd10.prod.outlook.com (2603:10b6:303:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 19:54:19 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8d67:8c42:d124:3721%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 19:54:19 +0000 From: Mike Kravetz To: stable@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Naoya Horiguchi , James Houghton , Oscar Salvador , Miaohe Lin , Muchun Song , Andrew Morton Subject: [PATCH 6/6] hugetlbfs: don't delete error page from pagecache Date: Wed, 23 Nov 2022 11:54:08 -0800 Message-Id: <20221123195408.135161-7-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123195408.135161-1-mike.kravetz@oracle.com> References: <20221123195408.135161-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR03CA0169.namprd03.prod.outlook.com (2603:10b6:303:8d::24) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB6300:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c45e437-3be6-471e-90cb-08dacd8c822f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OBZwQLkKjqv6jeO8c/t6p2Inf9YgirUMDY6mCxI3okG5/3e5owj/DWB7xKk6yzx66Y0tfQcPRyzupgScSLBTp1s8S+TvEBtqUq6yNUyft6KX0YdGNBDiq2I7tcp3colcEEcvG85WNlXkqnVkMhHrF/WTsAopKOEvUwVsGrVSrzpEZouyM+suKkfEcvN+MEwpsUhtkFUafTfkr/7D+QO7Fv9Ma1/s2TM3mMsWk29qeG8Xj04kLVux/j0RSHSweCXGHJUgm9IqV75nJuhmFRMrlr4p5sUBj8HxseezalULcshbtnZ1P0kJR6baulFWAqCKpNBjMFVfVyJ2FNXrnULBXGOL3ftls+1+t/x6az/2FfThofRzAFbvYDU2/8GpCtLta4x6WJDHd+Y6AFdKsmEvn08uR+P/BPNdGzKLgeMQbh0e3DXkJomw1M+rzx5ijhZ8ZDb1PIVyXFWgCwe9HEmkDRfBXNYaJ/+tV1GneKMVb/VJvyJI6hNXqsKHRQ+zM0YyfJBuiyqLMxDhgNOWzsGY3U71iFNdbSgJ7SQv5vIYy/L4FEiTw6rE1cstfvgNbXV/F/V1xUUh+pL4fRyw1GBQXDGvRqw4oEDR65Jk2i4YLwCqdueqiU59Lyw5pBv9VYgmCYYWboI5vuvFzRTj08hI40iYi8LZAFYAw8UCDBI8Xtw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199015)(36756003)(316002)(54906003)(6506007)(186003)(1076003)(83380400001)(2616005)(966005)(6666004)(6486002)(26005)(478600001)(6512007)(41300700001)(44832011)(8936002)(5660300002)(86362001)(38100700002)(2906002)(4326008)(66476007)(66946007)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZX15x9LZvq8dHK0yPlvwZb2Dgcbij6IZe7u1ODUMKx9/DfhJOHhIBEX5hq1T7UeqEOy/5BSVV9aH5vbm3kHR32gxVnLKRJ2A6gdKO2ikgIPMrNotgCtHHTG/xLDmFeR0mruUPLxW9djhoMiM6HAWniEcfaopeAhlMuoOHXS0ZLVFtpp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n4UFUq3PLCfVVw4MIvzXkv23RhA5dpInyg4yJqi0Hyc/EGpARgv+rFM6CQethsrtuveBT9pgR4F4rK1qvoKxqYxO4TZyiw2KGj9K6p5csoAoRQ7nWygL1G6fq2oHAtxp7tI16WbuN3fVlynB+cR988ZjXfh8U97rTBVT4/eklgDmxUIUp5z9oi6ZLVMirlFJYDYRIno/Xv0UDzRojJxHO3nRkFggYbjpGEAAvoVC3wsNctTdl9R0qsuR8hoiYwfs7iHka9sI5s1O47mOVLeJraZC5tEo/UlQLKMjU545ROYlwsOmXEWkshKT5sjWyqne7KhHgpOpxQuAuVJ+zv+t561MaK34DDOB23RJySpSOCvTuApFIivcGHYYPFBWze7YUks4omPT/GDvrOExGKuu+1Ryriax/cCSg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c45e437-3be6-471e-90cb-08dacd8c822f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 19:54:19.1179 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vPRV6f4LnOyRrQpYx18LETs9uTPlYSBAEWYDpcpaC+tbXDlOw4Ju2rj21OHGn8G3fsKlEB6Y3yDbsOFlJKnS3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6300 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230147 X-Proofpoint-GUID: PGSb7m7aGi2HLBslIIIVSJKTBapjVckA X-Proofpoint-ORIG-GUID: PGSb7m7aGi2HLBslIIIVSJKTBapjVckA ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1669233273; a=rsa-sha256; cv=pass; b=vNzcwhFfjani9S1HloYGCQwq1rum28E1SmC+WOyPpJmIovVgjUvSJGiOgbm0H54JorUVSZ kABdjLdyfu0exupwEAYRvRZtZFID2VcVjcZyxb8GxL6l6C5FDWcaVc8oHmOGClZFbkpXgu XZaRSsizysXbixt5GjcTWxH/kFdR2B0= ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="C6m9/hga"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VlemyaOY; spf=pass (imf29.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669233273; 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=5tRxGy5FG4mi1QJpxm1TCWGzceqRhxVq49lDSjVquw0=; b=v0xuPItceyJxzQiTsf5XB9perD3BmXY6hm+uJGGeleaBfjCAOnLnLIDGKUugY6biA9prE0 ETu3uYfWI6W/G+nNtrf8vkkaM4atSX2HKjFPWGw+3DRy0L9nH1w4CeXpBpcUmU5B/KKtj4 wBe1GSYEehmNMEUmqno6RzC5VtPUVZU= X-Rspam-User: X-Stat-Signature: qz5dpkewd6isqwtfwwdph6fwgwoxfgho X-Rspamd-Queue-Id: 77F15120012 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="C6m9/hga"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VlemyaOY; spf=pass (imf29.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspamd-Server: rspam07 X-HE-Tag: 1669233273-263502 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: From: James Houghton commit 8625147cafaa9ba74713d682f5185eb62cb2aedb upstream. This change is very similar to the change that was made for shmem [1], and it solves the same problem but for HugeTLBFS instead. Currently, when poison is found in a HugeTLB page, the page is removed from the page cache. That means that attempting to map or read that hugepage in the future will result in a new hugepage being allocated instead of notifying the user that the page was poisoned. As [1] states, this is effectively memory corruption. The fix is to leave the page in the page cache. If the user attempts to use a poisoned HugeTLB page with a syscall, the syscall will fail with EIO, the same error code that shmem uses. For attempts to map the page, the thread will get a BUS_MCEERR_AR SIGBUS. [1]: commit a76054266661 ("mm: shmem: don't truncate page if memory failure happens") Link: https://lkml.kernel.org/r/20221018200125.848471-1-jthoughton@google.com Signed-off-by: James Houghton Reviewed-by: Mike Kravetz Reviewed-by: Naoya Horiguchi Tested-by: Naoya Horiguchi Reviewed-by: Yang Shi Cc: Axel Rasmussen Cc: James Houghton Cc: Miaohe Lin Cc: Muchun Song Cc: Signed-off-by: Andrew Morton Signed-off-by: Mike Kravetz --- fs/hugetlbfs/inode.c | 13 ++++++------- mm/hugetlb.c | 4 ++++ mm/memory-failure.c | 5 ++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index a2f43f1a85f8..580fcf26a48f 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -361,6 +361,12 @@ static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to) } else { unlock_page(page); + if (PageHWPoison(page)) { + put_page(page); + retval = -EIO; + break; + } + /* * We have the page, copy it to user space buffer. */ @@ -994,13 +1000,6 @@ static int hugetlbfs_migrate_page(struct address_space *mapping, static int hugetlbfs_error_remove_page(struct address_space *mapping, struct page *page) { - struct inode *inode = mapping->host; - pgoff_t index = page->index; - - remove_huge_page(page); - if (unlikely(hugetlb_unreserve_pages(inode, index, index + 1, 1))) - hugetlb_fix_reserve_counts(inode); - return 0; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d8c63d79af20..6c99b217a03e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4775,6 +4775,10 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, ptl = huge_pte_lockptr(h, dst_mm, dst_pte); spin_lock(ptl); + ret = -EIO; + if (PageHWPoison(page)) + goto out_release_unlock; + /* * Recheck the i_size after holding PT lock to make sure not * to leave any page mapped (as page_mapped()) beyond the end diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7d96be8e93b7..f0cfd7d9c425 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -868,6 +868,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) int res = 0; struct page *hpage = compound_head(p); struct address_space *mapping; + bool extra_pins = false; if (!PageHuge(hpage)) return MF_DELAYED; @@ -875,6 +876,8 @@ static int me_huge_page(struct page_state *ps, struct page *p) mapping = page_mapping(hpage); if (mapping) { res = truncate_error_page(hpage, page_to_pfn(p), mapping); + /* The page is kept in page cache. */ + extra_pins = true; } else { unlock_page(hpage); /* @@ -889,7 +892,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) lock_page(hpage); } - if (has_extra_refcount(ps, p, false)) + if (has_extra_refcount(ps, p, extra_pins)) res = MF_FAILED; return res;