From mboxrd@z Thu Jan 1 00:00:00 1970 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 08093C433FE for ; Mon, 9 May 2022 11:01:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57E136B0071; Mon, 9 May 2022 07:01:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50F8F6B0073; Mon, 9 May 2022 07:01:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3812C6B0074; Mon, 9 May 2022 07:01:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2308F6B0071 for ; Mon, 9 May 2022 07:01:03 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id DEB8C60CC7 for ; Mon, 9 May 2022 11:01:02 +0000 (UTC) X-FDA: 79445912364.27.B33185C Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf03.hostedemail.com (Postfix) with ESMTP id 949B12008A for ; Mon, 9 May 2022 11:00:52 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id g8so11930842pfh.5 for ; Mon, 09 May 2022 04:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JqGcGcuUwLK05LGJI1ajsT/xW0rShgwvLzQMUoOkfkw=; b=EX80u1FgJBDMCHrzbHFVOjvLJY1UUYVtuQOC/wpMOEqIHTAh4jEcrxrWzJW2CQFpPg tauJptGinburWR+S+xrNaby09Sr9vlwlQHzwdrwy0iHshuyXvCgkHYGFu+Aeks0oMXdo iIVG/PtGR/ongrMfBzhfhvJJOHbGZR2SJBqfP8jnR0okDS+NKso52/KTywOTpp4ww5UX PlErlui1S/GuKpm4ZWArZxgrcievn2Eei9iNY/mGvDLmLI8cWpSzDUQwVFmgojyQawfd VCt1692u7d6Z5qvdrYHjGDom0bmizuAfn6zL4r3qKxTI5CG7ICW5E4jW+Td+wI8EfTiT AhRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JqGcGcuUwLK05LGJI1ajsT/xW0rShgwvLzQMUoOkfkw=; b=GThylpu3trnqTRJoPOkRkWmYdLFT7Rk+rKtlHkVXrph65WlNU/QGtZjEXu7tGemXhn DH9led5TpSazgwL9x1cJ3OL7isjq5Lgy8+Op1Tc63wInVCAkXeQA9JIITMW4tQulqiYz LK/i9ql7+fn3+S7lO0JdA7bzQchz6BKdooIVpCVegsiP+UrP1fzz6ZTCF0+9EhQ3/wTr 3ufqx6SUcv67Riq/MlJ5tqSrCmRUwS/M4Rtm7uynPuHVgtQf9KNQk+C8MLOxnfEGr7Bg I69OwNr3SElzRRVVs8227KR4BqX/aqQLUEVdm9DPxPt4FKrDsGDEAE2Gj0Z/90+3h8ZA ZFKQ== X-Gm-Message-State: AOAM532V8mt3Z9/s9XqSgUYU/QBHHKlD4aMIYftFQ6TXp5aPtXReFD8f WsA6LfHckt5yCro3nZTVhZsntQ== X-Google-Smtp-Source: ABdhPJwaGUhNTPgReYxZbf915o71BtxX+6pcZwG8eJNzhOfcIaOxs1UXcmb8oyitY4T6NxyuvXZYdw== X-Received: by 2002:a63:f1e:0:b0:3c1:d54f:fc47 with SMTP id e30-20020a630f1e000000b003c1d54ffc47mr13164738pgl.51.1652094058513; Mon, 09 May 2022 04:00:58 -0700 (PDT) Received: from always-x1.www.tendawifi.com ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id n12-20020a170902968c00b0015e8d4eb244sm6813303plp.142.2022.05.09.04.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:00:57 -0700 (PDT) From: zhenwei pi To: akpm@linux-foundation.org, naoya.horiguchi@nec.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhenwei pi Subject: [PATCH v2 0/5] memory-failure: fix hwpoison_filter Date: Mon, 9 May 2022 18:56:36 +0800 Message-Id: <20220509105641.491313-1-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 949B12008A X-Stat-Signature: jxtprz3gbtujuogzb68tr4af8q9meduh X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=EX80u1Fg; spf=pass (imf03.hostedemail.com: domain of pizhenwei@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=pizhenwei@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1652094052-962556 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: v1 -> v2: - move clear_hwpoisoned_pages() near the definitions of hwpoison_filter*. - fix typo. - remove "mm/memofy-failure.c: optimize hwpoison_filter". - call hwpoison_filter() after get_hwpoison_page(). - disable hwpoison filter during removing - simplify num_poisoned_pages_inc/dec Also add background of this work: As well known, the memory failure mechanism handles memory corrupted event, and try to send SIGBUS to the user process which uses this corrupted page. For the virtualization case, QEMU catches SIGBUS and tries to inject MCE into the guest, and the guest handles memory failure again. Thus the guest gets the minimal effect from hardware memory corruption. The further step I'm working on: 1, try to modify code to decrease poisoned pages in a single place (mm/memofy-failure.c: simplify num_poisoned_pages_dec in this series). 2, try to use page_handle_poison() to handle SetPageHWPoison() and num_poisoned_pages_inc() together. It would be best to call num_poisoned_pages_inc() in a single place too. 3, introduce memory failure notifier list in memory-failure.c: notify the corrupted PFN to someone who registers this list. If I can complete [1] and [2] part, [3] will be quite easy(just call notifier list after increasing poisoned page). 4, introduce memory recover VQ for memory balloon device, and registers memory failure notifier list. During the guest kernel handles memory failure, balloon device gets notified by memory failure notifier list, and tells the host to recover the corrupted PFN(GPA) by the new VQ. 5, host side remaps the corrupted page(HVA), and tells the guest side to unpoison the PFN(GPA). Then the guest fixes the corrupted page(GPA) dynamically. Thanks to Naoya & David for the suggestions! v1: - move clear_hwpoisoned_pages() from sparse.c to memory-failure.c. - simplify num_poisoned_pages_dec(). - call hwpoison_filter() early in memory_failure(). - add hwpoison_filter for soft offline. zhenwei pi (5): mm/memory-failure.c: move clear_hwpoisoned_pages mm/memory-failure.c: simplify num_poisoned_pages_dec mm/memory-failure.c: add hwpoison_filter for soft offline mm/hwpoison: disable hwpoison filter during removing mm/memory-failure.c: simplify num_poisoned_pages_inc/dec mm/hwpoison-inject.c | 1 + mm/internal.h | 11 ++++++ mm/memory-failure.c | 85 ++++++++++++++++++++++++-------------------- mm/page_alloc.c | 1 - mm/sparse.c | 27 -------------- 5 files changed, 59 insertions(+), 66 deletions(-) -- 2.20.1