Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4631005iob; Sun, 8 May 2022 19:54:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6/1CNhjGMRFGad3Z3fGF6DfGPh3y/8JQuN5tX8LvYcEYsdHQt5xfKY8Iv+nRqeKiG+UrP X-Received: by 2002:a17:90a:5515:b0:1dc:c1f1:59bd with SMTP id b21-20020a17090a551500b001dcc1f159bdmr20552438pji.81.1652064898585; Sun, 08 May 2022 19:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652064898; cv=none; d=google.com; s=arc-20160816; b=s+nJFWmE6dtcbWAXg0GKoNv8UgcEBkFqIFv0PxtEaO+PdIc1Vs4U2i0ygTbSPohrQx SygQB+CU0emeMyfW1NLV81rAUfe4LUIRu/9G/DUJublxYFy1mU4oSoNobxtvp5MlwcIK ByqHq6A1od/8ixZzw1fyFgCwjWTBD9rhGnRBeUa9fR5ClX7Rx5dexsdCRaeE6OlC9f/v jlCUrZHivWUfwioS3NBIE2aou6keRr5z3wiKeI8TiI3Rr622DLYPHpCQIN9aX6t9mTJ/ Hkusxg1KSjsz3p/dOpQJelDdWgoOUJpL86zrxTHm/+aQg6ZCgJ8WNN0XtpqOOeWzoAdL cwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=HsmL70Uxpre+Yuw44Bhf/DXDbaU8ZDKhOhdy778k+yo=; b=CmSQ4aaAqLDpZ28VtcccDI4+m7FQvo82TElf63ih8Q/SSu3xo4I15ksJQOIi0vz0PB w0qbMW+dTvThQVw4CsaskHzjAFARNqb8FFvINLIJkJ6myuKGwbFNnhpNmyV5JcM29gQG qNEL7+SMIk6eK3gmYii86GuRK2u2U3plOB2wP2y0WUj5Spu+sOEmxOaqKObAr/DFjW6I 5MuU5SjFSQ0q/+Frdw/Ti0iDSq9bjKA/uGn3M1xPwo9a4fvRU3vdpOf329qyll4/ghD9 Iw0cQaoQpdxBA18kZbM3dUYTx4Qq1O3uN1c3YSA+ewGF+JxQFVDeOdKWT46qlHYcFUf6 LNBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=mlR3d80A; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id bw10-20020a056a00408a00b004fa8832da6dsi11485255pfb.76.2022.05.08.19.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:54:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=mlR3d80A; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 6FB3D81FC6; Sun, 8 May 2022 19:54:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383970AbiEGJ0v (ORCPT + 99 others); Sat, 7 May 2022 05:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiEGJ0u (ORCPT ); Sat, 7 May 2022 05:26:50 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCD33C4B8 for ; Sat, 7 May 2022 02:23:04 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id a191so8018740pge.2 for ; Sat, 07 May 2022 02:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=HsmL70Uxpre+Yuw44Bhf/DXDbaU8ZDKhOhdy778k+yo=; b=mlR3d80AhkwzzC9PKqaXsMDhWbQVXMEC6MCnzg1peU4Wr/mTRivGCNYgM7QRHTa0ub Z3V6OvjENlJU/wkZN2dPGw8DjSuZcoNR2oGUlIRRhQBVH/J/SmIEO4cp5zUEAua7DtmH km6VJHxTPXPOkXf28Bfd8y2Oj/hJ5Li/5hWOGMIjZcnUHnrxLi2Ce7b4K6swCToXCf7T kja+3ZAT4xc4qTctp1GdxZRAwko+jFMeVBxA7mgxWtFLT8zu8kr3WjghwHOyLiP52hWs ZvWYhgOn07sFKhQ0KVq2vNxuL3N6cigDdOzFwBCEHPNwFpfeLQXgfP/Z5DqDonJBga7k jzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=HsmL70Uxpre+Yuw44Bhf/DXDbaU8ZDKhOhdy778k+yo=; b=lAJ6zwv1J7shC0R9AwKXhrgtNZBlSDox58YR5ZmwzjW0+eIo803vnlMDJ5SbcYHd66 mo3c8CzQCeNee+ggypp5YlyqMzrUtgxPqzn8eIFJ8Wmns6bdVoLvjugQUG65fR+UaQ28 XDLd9SCacVtoclItcG3lnJ5zzPKaIPI3dcavy1DAjVxPsJ5vMLquHR0L4onxjn8wBeJx zAQC2Xg5RWkze18RHqR2dsXDSLwfnjSbzEqbxuin65NSPaeKSMH+VkgLoCw69mxgeWp1 Q74xSzw4KHaXu0eqj3IdWPwxrAN2AHcnYg2iDxai6Sote1r9s3lL8isdC6guQl9L3UzO cDCQ== X-Gm-Message-State: AOAM532vVdYKQ83/+nghKgnU13nTM9jx5FGmA5Cz/borkIz36sCC7J5K 5/+jDtTrrJzqoyfYW0UpEq+C5Uz6YMF2tw== X-Received: by 2002:a63:c013:0:b0:3c1:df82:c8b3 with SMTP id h19-20020a63c013000000b003c1df82c8b3mr6045188pgg.141.1651915383734; Sat, 07 May 2022 02:23:03 -0700 (PDT) Received: from [10.255.89.252] ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id y9-20020a17090322c900b0015e8d4eb2e7sm3216427plg.305.2022.05.07.02.22.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 07 May 2022 02:23:02 -0700 (PDT) Message-ID: <23e06fc6-84fe-122e-fc07-02c5bfa7d50b@bytedance.com> Date: Sat, 7 May 2022 17:19:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: Re: Re: [PATCH 3/4] mm/memofy-failure.c: optimize hwpoison_filter Content-Language: en-US To: Naoya Horiguchi Cc: David Hildenbrand , akpm@linux-foundation.org, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wu Fengguang , "Michael S. Tsirkin" , Jason Wang , "virtualization@lists.linux-foundation.org" References: <20220429142206.294714-1-pizhenwei@bytedance.com> <20220429142206.294714-4-pizhenwei@bytedance.com> <20220506085920.GC1356094@u2004> <3c0e25fb-695d-4a29-6de4-c892f89cea7a@bytedance.com> <20220507082045.GA1716199@u2004> From: zhenwei pi In-Reply-To: <20220507082045.GA1716199@u2004> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 5/7/22 16:20, Naoya Horiguchi wrote: > On Sat, May 07, 2022 at 08:28:05AM +0800, zhenwei pi wrote: >> >> On 5/7/22 00:28, David Hildenbrand wrote: >>> On 06.05.22 15:38, zhenwei pi wrote: >>>> >>>> >>>> On 5/6/22 16:59, Naoya Horiguchi wrote: >>>>> On Fri, Apr 29, 2022 at 10:22:05PM +0800, zhenwei pi wrote: >>>>>> In the memory failure procedure, hwpoison_filter has higher priority, >>>>>> if memory_filter() filters the error event, there is no need to do >>>>>> the further work. >>>>> >>>>> Could you clarify what problem you are trying to solve (what does >>>>> "optimize" mean in this context or what is the benefit)? >>>>> >>>> >>>> OK. The 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). > > This is fine to me. > >>>> >>>> 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. I'm not sure if this is >>>> possible or not, please correct me if I misunderstand. > > SetPageHWPoison() can be cancelled in memory_failure(), so simply bundling > it with num_poisoned_pages_inc() might not be optimal. I think that > action_result() is supposed to be called when memory error handling is > effective (not filtered, not cancelled). So moving num_poisoned_pages_inc() > (and notification code in your plan) into this function might be good. > OK, I'll remove this patch(mm/memofy-failure.c: optimize hwpoison_filter) from this series, and fix the other 3 patches in the v2 version. Then try to implement/test as your suggestion in another series. >>>> >>>> 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. >>> >>> Most probably you might want to do that asynchronously, and once the >>> callback succeeds, un-poison the page. >>> >> Yes! >> >>>> >>>> 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. >>> >>> I think QEMU already does that during reboots. Now it would be triggered >>> by the guest for individual pages. >>> >> Yes, currently QEMU supports to un-poison corrupted pages during >> reset/reboot. We can reuse some code to do the work in this case, this >> allows a VM to fix corrupted pages as soon as possible(also no need to >> reset/reboot). > > So this finally allows to replace broken page mapped to guest with > a healthy page without rebooting the guest. That sounds helpful. > > Thanks, > Naoya Horiguchi > Yes, it's my plan. Thanks for your suggestions! >> >>>> >>>> Because [4] and [5] are related to balloon device, also CC Michael, >>>> David and Jason. >>> >>> Doesn't sound too crazy for me, although it's a shame that we always >>> have to use virtio-balloon for such fairly balloon-unrelated things. >>> >> Thanks! >> >> -- >> zhenwei pi -- zhenwei pi