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 39150C433F5 for ; Fri, 6 May 2022 16:28:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A36D76B0072; Fri, 6 May 2022 12:28:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BEE56B0073; Fri, 6 May 2022 12:28:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 811DC6B0074; Fri, 6 May 2022 12:28:28 -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 6AAFF6B0072 for ; Fri, 6 May 2022 12:28:28 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 3646E121A89 for ; Fri, 6 May 2022 16:28:28 +0000 (UTC) X-FDA: 79435851096.11.8BA73C2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id DB7FC40068 for ; Fri, 6 May 2022 16:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651854506; h=from:from: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; bh=Afy3LRmgbTX/W4kOJBv51V2x19c9yS1eYu85zuJRd9c=; b=gWUvg6N7La++DUgnKPV9d+0zxmCQI4hNRcCQX0n3lsONKH/Ji0geA+1aMkEgF1rWIRpMdv ZYnEqX+awXtUsqJhhRVeBfQNtf8dmziNpD6E1Eie81HVuYA4/o+3zOyis8f1BDHPoSnIDv nxf0ER7wAwZpbQS5dv7oxowX1EO0urA= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-hXLt7vjmO8OQDaC7Mexl1g-1; Fri, 06 May 2022 12:28:24 -0400 X-MC-Unique: hXLt7vjmO8OQDaC7Mexl1g-1 Received: by mail-qk1-f198.google.com with SMTP id u7-20020ae9d807000000b00680a8111ef6so5243591qkf.17 for ; Fri, 06 May 2022 09:28:24 -0700 (PDT) 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:organization:in-reply-to :content-transfer-encoding; bh=Afy3LRmgbTX/W4kOJBv51V2x19c9yS1eYu85zuJRd9c=; b=gRO4l1eONko3RPi+ZKzDD0DD49HOQ1XHEPrL4Sj1KP/H1uOtjMmk0QyH/+tbf3hbrd YN06gE/RAG1I+Ksqo/Q5tw9/BJctEOBDoZm8WyzZDIw63iR9CdnmWGEgKf8vR5M5sooy RhiTtJeXx6/WnBgU65KU/GbPNzelU+p+JDUGix/uC4uU/UyGV1sjQvm2H8xhm9ymgmF9 O2K6TpLQ3SfokDwqJxiaDZ175vh3MEEYsaES4j7RvEGo3BIMPqtwO5Zj7ZlhoKc6jexY qP0PWoOvXYf+Ni3091J+rDBcfDNLem+F9Alx3qJDxomjsshO7RUmyxc76h8ABLrkBK8g YdYg== X-Gm-Message-State: AOAM533LO++U0nh3NqPzEiMkgYwl5PoumPyC2fqU7vqXh+Ow6PH3L1iL 4sg3C6Zb96/+ow3LbM/eZBM6OtLvgljkF3bC6ukAtS1M9wcJye9lhz/XQVL1aIhlpSSKVhOTivo yPeAcwNSjWl0= X-Received: by 2002:a05:620a:4405:b0:6a0:30b7:7d5b with SMTP id v5-20020a05620a440500b006a030b77d5bmr2843344qkp.482.1651854504220; Fri, 06 May 2022 09:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9mEOuQZwJEmFcxWadpmKCBaw0BWvAOMjoo5GmSP6daGuDLSFXPHz5F/LLg72a11CQ2+pb/A== X-Received: by 2002:a05:620a:4405:b0:6a0:30b7:7d5b with SMTP id v5-20020a05620a440500b006a030b77d5bmr2843324qkp.482.1651854503954; Fri, 06 May 2022 09:28:23 -0700 (PDT) Received: from [10.23.153.165] ([46.248.132.196]) by smtp.gmail.com with ESMTPSA id l1-20020ae9f001000000b0069fd35d2abcsm2638745qkg.112.2022.05.06.09.28.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 May 2022 09:28:23 -0700 (PDT) Message-ID: Date: Fri, 6 May 2022 18:28:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 3/4] mm/memofy-failure.c: optimize hwpoison_filter To: zhenwei pi , Naoya Horiguchi Cc: 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> From: David Hildenbrand Organization: Red Hat In-Reply-To: <3c0e25fb-695d-4a29-6de4-c892f89cea7a@bytedance.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DB7FC40068 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gWUvg6N7; spf=none (imf27.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Stat-Signature: u96m3jaj6jqwr1e74fhwrwrh5jm9uzss X-HE-Tag: 1651854504-287592 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: 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). > > 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. > > 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. > > 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. > > 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, David / dhildenb