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 1DB52EB64DA for ; Wed, 5 Jul 2023 17:57:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5A118D0002; Wed, 5 Jul 2023 13:57:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E1998D0001; Wed, 5 Jul 2023 13:57:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 885288D0002; Wed, 5 Jul 2023 13:57:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 78B748D0001 for ; Wed, 5 Jul 2023 13:57:03 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4DA951206E1 for ; Wed, 5 Jul 2023 17:57:03 +0000 (UTC) X-FDA: 80978314326.28.C60B0CB Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf17.hostedemail.com (Postfix) with ESMTP id 70D894001B for ; Wed, 5 Jul 2023 17:57:01 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=qzpbmri+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688579821; 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=j1wTgUxJXx3tp0kUBGY4xdI7MU5ro+vhiugocM4n1ss=; b=GtXPiMqQGCWsZ+q8mfgYNaqLv4WIUCnAKQ63fmlCXb8lFCEmh7GfAUwztyufLzvzpSGo4D HEDa3+bOXipQ/hQh8Z0qKwAbrnXHanNUr8+9jgeZEEXRHFSKnEDNyZykL0veuBw8Nmxgcv vAAdr5f3TYdzlxU9XfHx+awqLA3AAUo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=qzpbmri+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688579821; a=rsa-sha256; cv=none; b=b92MxcRT/36JqxO+0VbC15qahx1tauMF9TOY3pWflaTaCDlzYVSxgPGgIQHOXMdn7wrsHi Myjy/SYjvoPWwtn0PPOi2QoLsZIlEY6oT91KuvO8vdhntxcRoWZKfk4I2UQcvQybKm3ToK tkel2Rk6MJFAo31KooLCsZVeZQD34ik= Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so1318600a12.1 for ; Wed, 05 Jul 2023 10:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688579820; x=1691171820; 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=j1wTgUxJXx3tp0kUBGY4xdI7MU5ro+vhiugocM4n1ss=; b=qzpbmri+UAarope3gQY8JCaH976L2B+n68ws9721gs3jJNB+eNzjn0eF9ZfrEJNMmv 8+WaC+vezGnY6DZqbBVhreJI15TtRVagcdiZqkWT+ln6ShhA3zqC3zFFt+N1Y2UASrAy mkn7DAU2ZiscOT4R9jHsDoHNIs2sqmtiptgyZbEg07lqi7M4nbMzRv6PkOSGkx1vZ14W 5BF6Aeyx2PjsYG5xUCvhhiSQnc/umzUHMm2GUPnWLyhGNdflfghzdmGXv6yquBA9uf59 rNgaUPJjDb4BldD4ttWdUyQVVED83+ru/yq4dlnsF2LWTFXkkpg+UcbCQisk+j4kdPQZ wXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688579820; x=1691171820; 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=j1wTgUxJXx3tp0kUBGY4xdI7MU5ro+vhiugocM4n1ss=; b=Td6+IiSyRYEDgkdjX/9gjpt+Q/QJClRkW+vEcdUKZAIJZzWek1H4kKIGFL/orjrNm3 8u0wEeXuAFli9hibISV0wg809pG9eDnwBMA9/ZPRSvhWV2jQ4NSSq5yZo/fYsCyjtM4S tCqxnxuZ2PTvXFbr8FXHtIvh4WCu6YvDwqrstcMKw4pS4XCcHA78nhJlsel2MmCUp6TR RY/gfIFcIh6E2xzhsXYXpKPzvwy6GDMv2U6u9M00B17rrp7JLvvJk/3e1tSsyx+E8U7P TuW4mXLNka4hf5pr6rtuGvtbvU63dSq60tB8U8bjQU7KFhtU0Pfw2l7FtbtTzlqbIozI WesQ== X-Gm-Message-State: ABy/qLbcZ5evDqmA8DOYBBnlFJeQxA6gZQ+8PR9T7g/8EyCOAJKN/tll et1dxLhGP44/1qZvWBUtzpRyetgWIYyyyuFJcNGoOg== X-Google-Smtp-Source: APBJJlGhNDfk+A5cRCar/5QRGBPxgKX45i6W5UnrxH4GqLaWcyJzVDKBTBgap4g7/sAKGatltVc8+OINzu7yY35sZ1o= X-Received: by 2002:a17:906:648e:b0:992:6d73:5696 with SMTP id e14-20020a170906648e00b009926d735696mr2934926ejm.5.1688579819676; Wed, 05 Jul 2023 10:56:59 -0700 (PDT) MIME-Version: 1.0 References: <20230629205040.665834-1-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Wed, 5 Jul 2023 10:56:23 -0700 Message-ID: Subject: Re: [PATCH v2 1/6] mm: userfaultfd: add new UFFDIO_POISON ioctl To: Peter Xu Cc: James Houghton , Alexander Viro , Andrew Morton , Christian Brauner , David Hildenbrand , Huang Ying , Hugh Dickins , Jiaqi Yan , Jonathan Corbet , "Liam R. Howlett" , Miaohe Lin , Mike Kravetz , "Mike Rapoport (IBM)" , Muchun Song , Nadav Amit , Naoya Horiguchi , Shuah Khan , ZhangPeng , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 70D894001B X-Stat-Signature: ptiw8ho4z7aziiw1hduim9jsu38ab3fu X-HE-Tag: 1688579821-920056 X-HE-Meta: U2FsdGVkX19pWwNd08mDhc/bC2cMJ8S2IBu0QTF2QxXJ0QwHbIv1R+RgLlkO/GyEoAq7TaJHky4U0NdiKa6jvK20rXkGlfkbQNTkS4VvCf303aa1fdTVlxPi3kLX1co7/cdiSZ/CHWxlNC8TI3+7gWpsAmL4gNuSoWCmUhEyvH/dH25cYXHitrK+RCT9gQ32tqYj1v8lVRC0Z9mNw7E0mQNiAD2F7Ff/YER92PLliOVh0yb6NUIgRiYJC+V3UnSkHZT3sz5bWqFbe5Chka4wkV1rPzNIIC9jwImGzhxZ6s1k/VOfF2EnauNXWr79wy77eCMKdd+5PIHj4KuO4pJaJZUM8onzJTEgpnQ6jzOcE8UKl9B03j7DUXQLGqk1VheIo1lhDfS1um1jpsWwbJfxjvMQX0Di93OTMxAV0nBH1uiIfUvu/hI7zmXu5G0WwbXmq54q4v0+eGU6cbMX3UzAV2XGStc6pKxmXajvuYzEEEohqH/2pazKvxpKJOs7mlU46XtS2D74Fx5zbOFVpAQT45LFboNM4z9oaP3E4Ek3taDlVCoRcTarYSkgUmRbfSZ95Or640zjzggie4xWjimrOA3Zp0n15L9ZVK4UWaghznTeRLMcy+eFoq7sqwcdpSRaa1MYH1cjHWrpfdZv6dXQv2WkkBFGlq2cxpP8fSurZI+okkgoz3sPCYSqfzWsGp2YzCsPciMCJqwVu9wNUFieNrEB1/dABboS2ULRYBSnauhrCK+eAXZjfX40IgXMPdQpA4tc2WPGVNY5FR/c7y45iKlrjca9uxF/4RTW1fxvR72XvRqDhIL02822CjXoaUXdGgq6trz/iZcpgn+qhp/6K7XoCRwD5LYoKUaqDYvgj310CHvRFAQGw5NMesq2sXpdyFP+A1DzPBIdWGNNNlVcqiF+ZtBeR6BVy7bVJlhdJoPeJ2KigQMB5Yke41qbcCKtsZK7CeTsId1a/j0KOhl 14mK4dny RnB7gdf+7mifixIHOlLFFYae1//p7LBw80ZZhn8euwO+RvK6EFm8/NdBByIDf1iwdFbbpV65oBF2q9nHz8bn5pNVY8c8QHl6YP19uxPffX6YyCh1BYPfPMr4+GrjQ/pT3ijSJ0v6DgW3ma/wAdrVd1rm3FXfF4YjKm1FRXJwJFm7iUb9AxPqd1o+gRqYpvU6LFyHqOodyRenHovMOrpxMWNNtA167zAtuabVn+X/YZvcFNyqyoSyfTc+ApVmUfSf5KMcNmjFgXOZMw7R42pnWtqwQpLsx0XVKuaL7ckQkfs2+SvI= 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 Wed, Jul 5, 2023 at 9:38=E2=80=AFAM Peter Xu wrote: > > On Wed, Jul 05, 2023 at 09:27:15AM -0700, James Houghton wrote: > > On Wed, Jul 5, 2023 at 9:15=E2=80=AFAM Peter Xu wro= te: > > > > > > On Wed, Jul 05, 2023 at 09:09:19AM -0700, James Houghton wrote: > > > > > > diff --git a/include/linux/swapops.h b/include/linux/swapops.h > > > > > > index 4c932cb45e0b..8259fee32421 100644 > > > > > > --- a/include/linux/swapops.h > > > > > > +++ b/include/linux/swapops.h > > > > > > @@ -394,7 +394,8 @@ typedef unsigned long pte_marker; > > > > > > > > > > > > #define PTE_MARKER_UFFD_WP BIT(0) > > > > > > #define PTE_MARKER_SWAPIN_ERROR BIT(1) > > > > > > -#define PTE_MARKER_MASK (BIT(2) - 1) > > > > > > +#define PTE_MARKER_UFFD_POISON BIT(2) > > > > > > > > > > One more tab. > > > > > > > > > > Though I remembered the last time we discussed IIRC we plan to re= name > > > > > SWAPIN_ERROR and reuse it, could you explain why a new bit is sti= ll needed? > > > > > > > > > > I think I commented this but I'll do it again: IIUC any existing = host > > > > > swapin errors for guest pages should be reported as MCE too, afai= ct, > > > > > happened in kvm context. > > > > > > > > I think swapin errors are treated differently than poison. Swapin > > > > errors get VM_FAULT_SIGBUS, and poison gets VM_FAULT_HWPOISON, so > > > > UFFDIO_POISON should also get VM_FAULT_HWPOISON (so that's what Axe= l > > > > has implemented). And I think that needs a separate PTE marker. > > > > > > My question was, should we also make SWAPIN_ERROR return VM_FAULT_HWP= OISON > > > always? > > > > > > Just to recap from what I already commented above - if a guest page g= ot > > > error in swapin due to block sector failures, it should be treated as > > > VM_FAULT_HWPOISON too, IMHO. IOW, I think current SWAPIN_ERROR is wr= ong > > > when in kvm context and we should fix it first. > > > > Oh! Yes, I agree, though I'm not familiar enough with the users of > > SWAPIN_ERROR to know if we can actually make this change. Sorry I missed this, I'll take another pass looking at existing SWAPIN_ERROR uses, and see if this can be done. Thanks for the thorough review Peter, I'll address this comment and the others in a v3. :) > > Miaohe initially proposed this swapin error facility, let's see whether h= e > can comment; he's already in the cc list. > > AFAICT that's the right thing to do, and it shouldn't affect any existing > user of swapin error if there is. > > Or say, VM_FAULT_HWPOISON should be the same as VM_FAULT_SIGBUS when not = in > kvm context, so shouldn't change a thing in !kvm, while changing that > should fix kvm from crashing a guest where we shouldn't need to. > > -- > Peter Xu >