Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4918436iob; Mon, 9 May 2022 04:52:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl/zg+F/StFCJzWbglPOya5jZNgf5wz3vSlNH16mPsDhdHTQOcrCTxIg/iIvp7SaYQxudc X-Received: by 2002:a17:902:d547:b0:15e:c404:5a3b with SMTP id z7-20020a170902d54700b0015ec4045a3bmr15679846plf.110.1652097145253; Mon, 09 May 2022 04:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652097145; cv=none; d=google.com; s=arc-20160816; b=yk5Tw1d0md/+ncBZmod3pYxPXJQNxQVF+YznthOKkWx89mbU9CUZ9xeSPrj6Rq8A4X Cz575FGoTITDQpuaeX30CIvvrHlphKjzv8A3QDlkH3qrdhZE7lY5EGVzidEEMhPh7hEp Bc15uW4bj+i+NB6BGT6rEAgWVwb31+zPa9ddqLoDpN4rQeo78A/A/5KWGDygxqWUsxMp 74jdGyLnQMABk2BVVOVdZyv6o6y3MgU7yzBskHTYvtzv7kUK8oyNam3c1TfYak98pNJR +e8Wtttff1be22rcM6csB3NNdjW0+xdMDPouTgkc4vaWC9F8nOuSNNEUKjlwMHvdvZYm Xmmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=JqGcGcuUwLK05LGJI1ajsT/xW0rShgwvLzQMUoOkfkw=; b=kGe1HIR1syFOIa0JLXyyy0PbK/AT0geVYiiexxcRY2feNPSa8AvxPjc38lHSlxXYQg V5ycTDv1c9SC3+BOsAepnuAOFcmP2Y+KyzaNXuQqoxxy9kOSbAxgHNemZOJYll1bAuRc mX9uRbtBZ2/zl2pxKcc2L711yaLoHSJT1ngdOWDcld1aZKo45TpgOejvgTbrhz9xqpW9 fOhx2t+akbgnIYH6dRjck7T1o9J8kmtW8JiDCzSHutEtTfd144G0ynyU/0362h8LHhj9 2jy8vFKMuiL1cj93wm7rk4pAGRGG1yTTdhrIFQoAvee0RPborxhfLyiS28nGPdwwmV4G h6xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=EX80u1Fg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f11-20020a056a00238b00b0050d5b4ee692si15324745pfc.106.2022.05.09.04.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:52:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=EX80u1Fg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7727229FF3; Mon, 9 May 2022 04:01:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbiEILFB (ORCPT + 99 others); Mon, 9 May 2022 07:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbiEILE6 (ORCPT ); Mon, 9 May 2022 07:04:58 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06D7219C17 for ; Mon, 9 May 2022 04:00:59 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id v11so11941075pff.6 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=QNrgdCe6oARGvZRC9chIXl+gfEBgUZUj9gQeLCkhFvvAHBzV2JbdQ2D6U3ios6GOFm NxRoUutQytYhGEVicO2xfh188ZCgOEq9Txvm2zeEn3WW3DPuRI2K+zNObML+yHu0Oxf2 H/F5AICknd09rnvU5NN2Cp4+fviPSVaeEMwr1pi4NzYhXnLbPhS8ZMlL4iNIE0XFDAhn I4MiL59P5AW28l4lz/09+9AYOx0dwxh+7LXUuUpHSYJdTavRCiJ3U8Ebf3xfWsEM8xVc jwpe7dGly0A9+dvlMN25W35GDvt+bjNwAga9ybFoRJ5Myw5XgY12/2j//1thxqJGepql M67Q== X-Gm-Message-State: AOAM530KCAc9fNPUq36q/tq2Igzqz17Jfnf6KLqMlN68mc5g0FE90XLJ jdB5Ih0ifilEG1MhietsKJ2FkA== 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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