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 A5F62C77B7F for ; Thu, 11 May 2023 21:06:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00CD96B0074; Thu, 11 May 2023 17:06:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED8086B0075; Thu, 11 May 2023 17:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D50FA6B0078; Thu, 11 May 2023 17:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BFC0D6B0074 for ; Thu, 11 May 2023 17:06:03 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 84EA41C73FC for ; Thu, 11 May 2023 21:06:03 +0000 (UTC) X-FDA: 80779206606.23.E32947D Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf10.hostedemail.com (Postfix) with ESMTP id 2C964C000F for ; Thu, 11 May 2023 21:05:59 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=iEn7QA6s; spf=pass (imf10.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683839160; h=from:from:sender: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:dkim-signature; bh=vCeq2xThlfZB3ptEpDOPv6geRdVGsuZ5n1puK00a7nI=; b=WiFr1xC3AgXJyqshc4NXrYDHSTS9qyoaxW0aCno+EjChiEvnaylGOTrkbcVPzaVvfNzuFN NhDZk8on9FvjM6LzPx/HLX5ciMxrQRShLpzuIPekAHIKwIH8Tsv1H6syJkpSX5uL4aibam 9cH1DaXprW/GnSSVolWCf5peyZJi0kc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683839160; a=rsa-sha256; cv=none; b=IKMO0fb3shbgjcCczgaN6/nUpDsTUgJljxvdztYJhn0ecyqGjQNJjjP0TVo16oRsx1iaCG HMpi1xlasJPnXHnRVBcP/Qu9Mgzutp9z6fA5QJdytM1NtYDehLmpxjwMBacGDNdzuxfxrk yBB1Cih1xjcR7urZBEpoxqxS2DV/Bag= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=iEn7QA6s; spf=pass (imf10.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-75131c2997bso3110158885a.1 for ; Thu, 11 May 2023 14:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683839159; x=1686431159; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vCeq2xThlfZB3ptEpDOPv6geRdVGsuZ5n1puK00a7nI=; b=iEn7QA6soRHK+uXK3n4TqBcQlPoJaEX2jYbpTglsAhODvMazuXOFhfxfFwkiYGSmF1 4bSBY1X9T+/L3ZH0Lve9uA91vW5G+q7lshvyEPyUI0B3bXviFnkMtjrYkHT/rNm1qh5F SZ6NU5/fWdIptlm7rZanFIuCaOI5efRp9kPDdP/WYTWTLe3yDNZbwUt0nJYXDr5d8HET FVdt8UNAKbRx6YwHMl2l4ZXa72qwyEiMduWdZCy/T0UigM//K/4b+KFG7c1UVBV84pKX GyZ1aH2R4CSXlr5lc+HBuHSLNI/4o9Ioy+qKnwdnAXER5sh5ZcKeCUThHS6BrxrVQTfl OejQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683839159; x=1686431159; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vCeq2xThlfZB3ptEpDOPv6geRdVGsuZ5n1puK00a7nI=; b=O+3Euvtq6vyOzyF03Y+qqsNUnUoAtEDrI17zAluZPMJGyfQk8AafAckqOC+L+PmCcP 4atFHsnnKSFeMhPLZrG8eOgktdaCkTTz74HAFhuU1udvcyoiXn9Q/A2Pq9HMut46Ea/6 JpYXrYCRQomyyxU+rb+shkaEaZRlj0l61bQxuU0HfoW3rLa+q7qS3f3lajkCRhjhJJ9d 9IW94pKpfxAtOWjf+aTWkLaex1Y49oqCuLECI0ok1dEEKJi3lHD6e/IqC2DplW3F7ilv p+bGrUG+ub3FLcRaV7hAk+n1oSPx3lwhFAXppcBymjN04R/KwIX/+2KLsdSXmx/WlqVM x1UA== X-Gm-Message-State: AC+VfDzLIekykmNECTLd87bmJAA+cNccUUZ72Dk8xgK3+F5PIckEixm1 ZdBcnwNw5VY+uj0boStz3HefUaszDjzqT3RHQyU6GA== X-Google-Smtp-Source: ACHHUZ6UOjBrmUdJjmc06SN4JEYsOAg4+qNDvJ7BZtuEAjoG8Ew4RgRjSuY6SvfemUya16xKcm0YOKF6TQd/gjyvVBM= X-Received: by 2002:a05:6214:408:b0:5dd:b986:b44 with SMTP id z8-20020a056214040800b005ddb9860b44mr42769277qvx.6.1683839158749; Thu, 11 May 2023 14:05:58 -0700 (PDT) MIME-Version: 1.0 References: <20230511182426.1898675-1-axelrasmussen@google.com> <20230511202243.GA5466@monkey> In-Reply-To: From: Axel Rasmussen Date: Thu, 11 May 2023 14:05:23 -0700 Message-ID: Subject: Re: [PATCH 1/3] mm: userfaultfd: add new UFFDIO_SIGBUS ioctl To: Mike Kravetz Cc: Alexander Viro , Andrew Morton , Christian Brauner , David Hildenbrand , Hongchen Zhang , Huang Ying , James Houghton , "Liam R. Howlett" , Miaohe Lin , "Mike Rapoport (IBM)" , Nadav Amit , Naoya Horiguchi , Peter Xu , Shuah Khan , ZhangPeng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Jiaqi Yan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: r4euws4ppwa8737177mycdyqc3qif5fb X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2C964C000F X-Rspam-User: X-HE-Tag: 1683839159-160420 X-HE-Meta: U2FsdGVkX18FC49N2q0epMvpmszVAU8hIWd7NN+AXb8KEEjffjYwavnMNzQdEvcxQPgzZ1DUPfv4Pg2ui4DMOrsA/mHuDO0v7tC7wnPjVZXiDaqc7B1VWuY4c7OUkLwB5gfrodIuocX5RhpNARm4uZM0hyH1FiZ6qjP6wB1+XSqE+FUXGSniEjo4Gf6TlOenaM29/2fAF49+/6fIS0mSSnZY+alxN97M/67naOsIlCv0yeTfPI3TJURX4PYvWggIb58hbPXbGUrYEZji7SWWzjMkq/YKtbU1CeED5hEasVmvIRLbj4W5Vk38qJGWdl90Kr4KjiyiJ+HKBOWNcTgUNOlZSgj86zuX6I/S4+AscMeIj7feynxwN5CDMWBUD1vzRakYHRJ3LJ/7W7lqoibtoFfIRvKhXpaA1lmsVLXGYsjtcl10gGZBfAEfLGtjS1zXLv6Gkq2aSERu2yxT4gP6XR2pYl+HJe1304BvSKhFkzNuA8ErhB6hV/58RrGFM7tQoF5dgcYJ9xujAmJ4zxX7egK6RLL6pNWOVTe9wcHkkQSrft7Y6kFolGWx5lY8Zifp4+pgGXhJpHyWIH71ufLoFZyUbW0ygx1MO22QeULSRIyG6UkjvQovOJN8SM+15k5fcesCGOH/+0LKSTm9cDx/PIcHH/NuQg/oT1a9jV5PziPhrtg7FFR2dgp2dkGOEbTZHO0ZV/L0IGisyuiX1HLpu+RocebqRSkQ8p/xB14ySphyfdXDvjCSvh1/odYcCb9DlN+C395q0mlS+solX6SzgBG6EbbQxBCo5ik+5sgc1VdeRaaMSgzbEBHuQQ6P2kjLh/ZG5GpY/6N6cetSo8tmKTKH2lR+/w6qdi04z2N9PDwqBVxWApwQ87VvUzi3aYDf0YdkqzoRU8YfleKcvwCknabXS9eB+TlGUeRrssg4cCCfoGEfy5WlrI+GYqy8lon8elRQAQW0l81A/TA+Dhy Yt+NTavl m9ELK5zAmxOYR7tkSkgNyQZPL7gEM47PDsiza327Y6We57Y78SS8VbUyUdsaHStliFvzCMrHfPqqlaRIQamsy70JKuv5KIvkROr8c7xMaCIV+EW9k2fC+tMSV8Kusra3aBOLVNgGYfRMGD1pbpvbt4amhNH1p0RCknnBb+bpj6tH7v8nHdY2EJ8DnWIXqqmTCQfPAfOghnH1nmSrZRPj8uB/hYcqTgpxNVqkyVwCKV9J2XL7e4G+V7p7AdvEdbIA0+tu453D/ejWWKgxCGFyqpmz2mfHp2jGNUKum6P9gwgcuKvcJK2VPk4IkcJ4k9MMl6PBXSBc5iZw+MB0CKgOhoiXM/bGjV0B4nFZLLom3oC+Jp+a3/4y2gmXARqYB5Tc8xkHrvNLrR/IJJaDUt3ncxLmc/CMvAgW8htX9JFsKoN8SCVzfe4J0oqzp7GrOpK5+/ldj 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 Thu, May 11, 2023 at 1:40=E2=80=AFPM Axel Rasmussen wrote: > > On Thu, May 11, 2023 at 1:29=E2=80=AFPM Mike Kravetz wrote: > > > > On 05/11/23 11:24, Axel Rasmussen wrote: Apologies for the noise, I should have CC'ed +Jiaqi on this series too, since he is working on other parts of the memory poisoning / recovery stuff internally. > > > The basic idea here is to "simulate" memory poisoning for VMs. A VM > > > running on some host might encounter a memory error, after which some > > > page(s) are poisoned (i.e., future accesses SIGBUS). They expect that > > > once poisoned, pages can never become "un-poisoned". So, when we live > > > migrate the VM, we need to preserve the poisoned status of these page= s. > > > > > > When live migrating, we try to get the guest running on its new host = as > > > quickly as possible. So, we start it running before all memory has be= en > > > copied, and before we're certain which pages should be poisoned or no= t. > > > > > > So the basic way to use this new feature is: > > > > > > - On the new host, the guest's memory is registered with userfaultfd,= in > > > either MISSING or MINOR mode (doesn't really matter for this purpos= e). > > > - On any first access, we get a userfaultfd event. At this point we c= an > > > communicate with the old host to find out if the page was poisoned. > > > > Just curious, what is this communication channel with the old host? > > James can probably describe it in more detail / more correctly than I > can. My (possibly wrong :) ) understanding is: > > On the source machine we maintain a bitmap indicating which pages are > clean or dirty (meaning, modified after the initial "precopy" of > memory to the target machine) or poisoned. Eventually the entire > bitmap is sent to the target machine, but this takes some time (maybe > seconds on large machines). After this point though we have all the > information we need, we no longer need to communicate with the source > to find out the status of pages (although there may still be some > memory contents to finish copying over). > > In the meantime, I think the target machine can also ask the source > machine about the status of individual pages (for quick on-demand > paging). > > As for the underlying mechanism, it's an internal protocol but the > publicly-available thing it's most similar to is probably gRPC [1]. At > a really basic level, we send binary serialized protocol buffers [2] > over the network in a request / response fashion. > > [1] https://grpc.io/ > [2] https://protobuf.dev/ > > > -- > > Mike Kravetz > > > > > - If so, we can respond with a UFFDIO_SIGBUS - this places a swap mar= ker > > > so any future accesses will SIGBUS. Because the pte is now "present= ", > > > future accesses won't generate more userfaultfd events, they'll jus= t > > > SIGBUS directly. > > > > > > UFFDIO_SIGBUS does not handle unmapping previously-present PTEs. This > > > isn't needed, because during live migration we want to intercept > > > all accesses with userfaultfd (not just writes, so WP mode isn't usef= ul > > > for this). So whether minor or missing mode is being used (or both), = the > > > PTE won't be present in any case, so handling that case isn't needed. > > >