Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29405123rwd; Wed, 5 Jul 2023 11:18:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6O3FBp3C+dFDmJuJCkXQmETSGb9ClNpHC63zg3MqUkDVJSTdgUOb3fvwy3abT0pea//yAI X-Received: by 2002:a05:6a20:4325:b0:125:4c0b:93cd with SMTP id h37-20020a056a20432500b001254c0b93cdmr15494845pzk.34.1688581111058; Wed, 05 Jul 2023 11:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688581111; cv=none; d=google.com; s=arc-20160816; b=LE5S3MDao5B7QUAjfHyfQnkH1qU3hea/uItkC7JGM4yis/C092p9K5ym9K2dQzGCd9 uKvHf3LXvm5lhMla1MuavUaoIr0Z5ut6vpVkgGVHg7o2Llua0VKTPt8zz4vlU5Uhcl5D l4Pjr8oBN/Re94UlVZ3aGVPiChiR2NbhVRAlTXsJ5KF+ycv2gSdpiAaShDrmaO23y5wM tqhCs3LPIeeJiIWrqRzP+6FqrzOMcZhfsiCxyURzeOLYLzh/ZeJj35buQ5ZpR6gyk/dL HKYLyWHFGsGqKLpSQ/A3/pwDBr7Ld/0z0zwFXXNyAFEP1DTuHvYC6pENCFg5hJdGwa8K xYrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=j1wTgUxJXx3tp0kUBGY4xdI7MU5ro+vhiugocM4n1ss=; fh=vb006lsvK+2+BSjMoOKPKYp1UBXlerkoYRI+2pRY9B0=; b=E9nILAIUUVrS9zn0HfcSyRLkPie3giHlqcmKqD7/KskHRa3K8hRRj7vNdKBSBzgEaY zqO0Vm5nnNMkw4i12GsEfoXmLVdQXDLlqzXtImGITwSVwUFhfvzc/EhUa7e1aeialyiG n7Jd2q4Fy7UI7SFOVP6c1IgwNfNd5HLGmce7f+la6hgQeU/j2BNpymaA0mYTOIfyjMlO yq2+W2hyfSN9lKEWgpN8y67KeytLf3KAxwuJlDFymDkVLCLaz00oHT8aOAp0tdv4MoJf ljmbKD6YLWP7Zmit7uXAW6YUhWLbSLDc+UU+yo4v+cNtgWtEXMenvsoxpdS99fyjfh9u LNJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qzpbmri+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g34-20020a635222000000b0054fdb18c877si22894889pgb.607.2023.07.05.11.18.17; Wed, 05 Jul 2023 11:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qzpbmri+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232371AbjGER5I (ORCPT + 99 others); Wed, 5 Jul 2023 13:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233247AbjGER5G (ORCPT ); Wed, 5 Jul 2023 13:57:06 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7250F19B5 for ; Wed, 5 Jul 2023 10:57:01 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-51a52a7d859so1921838a12.0 for ; Wed, 05 Jul 2023 10:57:01 -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=TI2drjdR+leEHfptTJ9M1JS/muzZ9E2P9/B54b4nc7Mri5N483qq7wEc2u+XE6TWPJ 8HtcExx69h0qjWBjYlEz9CCBJ3QkChEq9WC9lBThVqvGm0RNN7ciAM3zy1Th+ZdxOnmL bUkesu3bMRJafAnv3aUUur2+KfnEZa3k3uacjtIJwEzTA8xAYYXtqdYrB2uk9BL2Rqvs Mj16ibdu7BzAMOMOS4Bzqr2v3/wh7VTLvfL8OOXtzP5TG5b3f9Xv9Xfels8qfmaSuSzm /M4IP6ZGpdfUQpfFKG1epoJ93OiQ882CgabLc1NIHRlVBADDxv1DkEiVaFukaqI+M75y C8XA== X-Gm-Message-State: ABy/qLazbXPGESuiIzJQyGe2gWoIHxRA/enJ/JzRflitXM396SUZQhJc Yjbzd12caqvVrGx0SJMlL+M0bcKztwndfGn8qldU3A== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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 >