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 58FA7C433F5 for ; Sat, 7 May 2022 00:32:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83C5D6B0071; Fri, 6 May 2022 20:32:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EB996B0073; Fri, 6 May 2022 20:32:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68D8A6B0074; Fri, 6 May 2022 20:32: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 54CD36B0071 for ; Fri, 6 May 2022 20:32:03 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2B2A360E2A for ; Sat, 7 May 2022 00:32:03 +0000 (UTC) X-FDA: 79437069726.10.97F3811 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf21.hostedemail.com (Postfix) with ESMTP id A70C91C0021 for ; Sat, 7 May 2022 00:31:55 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id d17so8964400plg.0 for ; Fri, 06 May 2022 17:32:01 -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=Wn0dXbP2ZNZ5rtmEUdIAq+AKjqvzHBKlvsWStfjh/W0=; b=fOrVM+EV4Gunf/aPtxP1nt32zwg0Xwz4PfvGKYnHCgQwFAwWTfFddYQ/YZ4R+7AKqb yiWWR2ufEtrREpn9n4vplBM48DbtYM0u7ut3ChXkCkslhGtgm7lKrSesCev0H/+ruwKV RUcFjA56oR02AtOyIvEG4He/xOKdub2cATeQ45KylHC3J+N4e1sr09CX/oxFTm32kvDD bEiuOeH3vz12FQVgretkDDpYELaFELIc6FVOqt4G4YCPKtGSfn8wwoIMX7mXf31T6X0Q BAX8mKz3jEOI6r6BdE8CROzOUylSc5p6GfOJjTDCIieZRNatDok1m5TYn7FWJm8VPh0D oIjA== 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=Wn0dXbP2ZNZ5rtmEUdIAq+AKjqvzHBKlvsWStfjh/W0=; b=wlzSQSILnKLkaGGBj1dMuQCh1XY/o0Yd77uKtIir+KWJdd+cJvwGHCvgsf0QLeJz1a eJqbG/SH6Yo+ou/pz+cPCDx38owLDUBjMhbhYLEa7NVyc8KY3sCNuHA3edA+G+p4vdrT va7SRV9uNKfjJKPh/H66JfoQtahDf7knwwa9XhQxDMXoaMqwRHmXSZl154Q5fi2EZIkz Qt/H7rpWMA4C9ETkRRFQ2omkAOnupR1q+xCqTgJ7YkrMu+kiC3Ldh0Vxf73bykXGrj1p qVR5lNSauW3sJBMCasRgFME97LzKOBvHPJVBKBu5jt0Bn3C3gP3HZ0hJQmr2MtTG0PCO 0vvQ== X-Gm-Message-State: AOAM533xSXuzcxDfg4oye20IzzYlOMDCCd4p6Y8O99SyAceX9w8LdUDj 0aqPWcK7u9y3/8/+DFZJIL6yeg== X-Google-Smtp-Source: ABdhPJyckdf3ooD9/x8FQrTgykRhfqi6qP1ZrPcpvmWgj2IWql69kx0Wu/RQ52gT5LiMdQFMnHPxLw== X-Received: by 2002:a17:902:bd05:b0:158:544d:6557 with SMTP id p5-20020a170902bd0500b00158544d6557mr6514519pls.70.1651883520388; Fri, 06 May 2022 17:32:00 -0700 (PDT) Received: from [10.255.89.252] ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id u1-20020a17090341c100b0015e8d4eb278sm2471067ple.194.2022.05.06.17.31.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 May 2022 17:31:59 -0700 (PDT) Message-ID: Date: Sat, 7 May 2022 08:28:05 +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: [PATCH 3/4] mm/memofy-failure.c: optimize hwpoison_filter Content-Language: en-US To: David Hildenbrand , 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: zhenwei pi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: 6pip7r6rebb4dsyj8yb7q8b6ny7yqh16 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=fOrVM+EV; spf=pass (imf21.hostedemail.com: domain of pizhenwei@bytedance.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=pizhenwei@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A70C91C0021 X-HE-Tag: 1651883515-516527 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 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). >> >> 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. > 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). >> >> 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