Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3520821rwb; Mon, 3 Oct 2022 16:49:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rs1ujC/c1jAFDNcMSkCJHWdCgKU3z2JRN6IIeA0TA6BXgGOdL5cmvpIGcwEufCPxRYF4Q X-Received: by 2002:a17:907:6e0d:b0:78b:96ef:f948 with SMTP id sd13-20020a1709076e0d00b0078b96eff948mr5351290ejc.120.1664840977231; Mon, 03 Oct 2022 16:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664840977; cv=none; d=google.com; s=arc-20160816; b=e7mbi5oKOrKV0FkVzO7kYCeNUMYDfCVSHJ6gDgj81v5J7ranxzgMeGiwkDvBG8qtKY a9mjoB6AJ52kUDTOc0afSijTEho6PZKZ7YGiScvAVPpNz4Zq7mbWTAGl1q8SYlOukEXA P+qBAcvy44PHaplq1pXlDxmueRoUQ/+AkbEZlRZZKaOFuqAHEFveFlPAHGe6x+gVY2pU YDuaJ11h8Ig+kdvP3uPW5CaZN3wR8GYRf2nuwkN68XLUWGubYGVigBpnM4sMFSWpBB3/ 9kF+RddBVPdA0s1rwK7eg0/MH+q59eW7xIEtWdbmXY3nc1KPHvyKLiLf8od9J17tsbtx JXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=DmfOOdFXaL0JuSZU4cVh2580j6bx6ldhnISbfDNKWOE=; b=j+PlKRkagFn8s6tCoZO/E5SJi0PGeX8YlALeDI/iMHcuYLfyQ9HoaFE9EmkEVI8rnE V/LB3oGG4f2Ui4WtNAS88L01kFovfCe+qquZ734JtlCnuqL8SpyqTHUecvg/63KldPn/ qOufT9L8XqXp49uBag+F+ymU3LHCJi8rG41VPWlJD96vWFSCVCB18wMQTL39ld6Y98mM CpRCqBqDKiI5D5ok0G3wnRpnaANXYCJiEUubcDg4hJNuhF4lKmzNO/06PuAcdqfLGf0o +z5w7EebWvUZm26oQvqLZ8YeKtVuXPPtrXOg58NSKUbG4hMeB2hvfstz950aJwRZ1dWR 5eZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JCoc10Eh; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr11-20020a170907720b00b007414886601asi9133830ejc.25.2022.10.03.16.49.11; Mon, 03 Oct 2022 16:49:37 -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=@gmail.com header.s=20210112 header.b=JCoc10Eh; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiJCXZi (ORCPT + 99 others); Mon, 3 Oct 2022 19:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiJCXZf (ORCPT ); Mon, 3 Oct 2022 19:25:35 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 976F72A968; Mon, 3 Oct 2022 16:25:34 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id b15so3193979pje.1; Mon, 03 Oct 2022 16:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date; bh=DmfOOdFXaL0JuSZU4cVh2580j6bx6ldhnISbfDNKWOE=; b=JCoc10EhxH6q5Pv4YB6gRBxx31cIlAWCF/wq1sohlxRLphWQMhux2X6tV93TBWsYx/ nSS8GwejbkeGbmbCkxk5nvufaMXoG5RNVW6s75l9qtqW0SDt+HYIZIAkBENvgQxdd8Il bf2cKL8XLSds30n/koPCIeQRxgWnl+2+1siNHrxqoW2J2qaI6IkKdRp7tTuKLmp5GqSt hHDO38kuyJSmWT6uYqQFoA6gmAmtv1RDpK0lzIALr0h/dl505ZeALUcHqOUJdTa8dfuT ICsx0Bidpud/KEWwp2l4IGFJi6IiRxgVyiG8iwtXbWu5MXktVYfpS4uzlUi4W4jBZvZT Dr0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=DmfOOdFXaL0JuSZU4cVh2580j6bx6ldhnISbfDNKWOE=; b=Kvyihu1bue0WWR0oW7wvdFzA1t68CzK5yNQARJ1JfblW08Pkh5it5XlhJZFB8OuQdt +82uF5jz6m+/gJNqoTr9UDSJ0Uz2OpVUbaXtHVOXao+BE+13uKk+jQr1BGQPdUOddDKD tch7MHCR6IGy+UkSi+8qIyDMqHk/HJOuYnaHFtv90ZJOlOP0gmXVVUjmvxDIYQ0wr7Lo egi+FCr5OBSt+tiYSvZ57cyHVA9djIb6bX1Nac+eR6WNnvtZe5GNHUXAKMD3hZS9ejQG bee9etnQKh9jwimWaSHFgd08DGqt9bD11T30s7zzY67NUID2TnfV3xuZTmYZLy5jOMPG 5BhA== X-Gm-Message-State: ACrzQf3mFR5HO4S67n/htFC/PDLsIw5pjs/lZIqKwXawWnoMxleZP4Cx s9lv+Z9hDXNbFax94xyUnz8= X-Received: by 2002:a17:902:c952:b0:176:bb2c:5459 with SMTP id i18-20020a170902c95200b00176bb2c5459mr23390032pla.165.1664839533934; Mon, 03 Oct 2022 16:25:33 -0700 (PDT) Received: from smtpclient.apple ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id q15-20020a17090ad38f00b00209a12b3879sm6848904pju.37.2022.10.03.16.25.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2022 16:25:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH v2 12/39] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW From: Nadav Amit In-Reply-To: <65CF3B29-BF53-4BA3-89D9-5398CEB7F813@gmail.com> Date: Mon, 3 Oct 2022 16:25:27 -0700 Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "jannh@google.com" , "dethoma@microsoft.com" , "linux-arch@vger.kernel.org" , "kcc@google.com" , "bp@alien8.de" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , Andy Lutomirski , "pavel@ucw.cz" , "arnd@arndb.de" , "Moreira, Joao" , Thomas Gleixner , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "jamorris@linux.microsoft.com" , "john.allen@amd.com" , "rppt@kernel.org" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-13-rick.p.edgecombe@intel.com> <64313344833c3b1701002a347d539e69276b66fb.camel@intel.com> <35EEB9F0-D99A-4664-9628-27029B52CFD1@gmail.com> <65CF3B29-BF53-4BA3-89D9-5398CEB7F813@gmail.com> To: "Edgecombe, Rick P" X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Oct 3, 2022, at 4:20 PM, Nadav Amit wrote: > On Oct 3, 2022, at 4:17 PM, Nadav Amit wrote: >=20 >> On Oct 3, 2022, at 3:28 PM, Edgecombe, Rick P = wrote: >>=20 >>> On Mon, 2022-10-03 at 11:11 -0700, Nadav Amit wrote: >>>> Did you have a look at ptep_set_access_flags() and friends and >>>> checked they >>>> do not need to be changed too?=20 >>>=20 >>> ptep_set_access_flags() doesn't actually set any additional dirty = bits >>> on x86, so I think it's ok. >>=20 >> Are you sure about that? (lost my confidence today so I am hesitant). >>=20 >> Looking on insert_pfn(), I see: >>=20 >> entry =3D maybe_mkwrite(pte_mkdirty(entry), = vma); >> if (ptep_set_access_flags(vma, addr, pte, = entry, 1)) ... >>=20 >> This appears to set the dirty bit while potentially leaving the = write-bit >> clear. This is the scenario you want to avoid, no? >=20 > No. I am not paying attention. Ignore. Sorry for the spam. Just this =E2=80=9Cdirty=E2=80=9D argument is = confusing. This indeed seems like a flow that can set the dirty bit. I think.