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 X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8253DC2D0EC for ; Sat, 11 Apr 2020 01:21:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B1A920769 for ; Sat, 11 Apr 2020 01:21:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B1A920769 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A418F8E0092; Fri, 10 Apr 2020 21:21:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CD388E0067; Fri, 10 Apr 2020 21:21:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86D248E0092; Fri, 10 Apr 2020 21:21:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 69C2B8E0067 for ; Fri, 10 Apr 2020 21:21:43 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2C568824556B for ; Sat, 11 Apr 2020 01:21:43 +0000 (UTC) X-FDA: 76693822086.10.road86_ed0a80c4ea52 X-HE-Tag: road86_ed0a80c4ea52 X-Filterd-Recvd-Size: 2648 Received: from r3-23.sinamail.sina.com.cn (r3-23.sinamail.sina.com.cn [202.108.3.23]) by imf14.hostedemail.com (Postfix) with SMTP for ; Sat, 11 Apr 2020 01:21:41 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.5.127]) by sina.com with ESMTP id 5E911B9F0002A594; Sat, 11 Apr 2020 09:21:37 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 30956854919314 From: Hillf Danton To: Peter Xu Cc: kernel test robot , Andrew Morton , Linux Memory Management List , linux-kernel@vger.kernel.org Subject: Re: f45ec5ff16 ("userfaultfd: wp: support swap and page migration"): BUG: Bad rss-counter state Date: Sat, 11 Apr 2020 09:21:25 +0800 Message-Id: <20200411012126.4544-1-hdanton@sina.com> In-Reply-To: <20200410073209.11164-1-hdanton@sina.com> References: <20200410002518.GG8179@shao2-debian> <20200410073209.11164-1-hdanton@sina.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Hi Peter On Fri, 10 Apr 2020 11:32:34 -0400 Peter Xu wrote: >=20 > I'm not sure this is correct. As I mentioned, the commit wanted to > apply the uffd-wp bit even for the swap entries so that even the swap > entries got swapped in, the page will still be write protected. So > IIUC think we can't remove that. >=20 Thank you for explaining that we would flip-flop uffd-wp in f45ec5ff16. The input to test robot now looks like the diff below after restoring CONFIG_MIGRATION. --- b/mm/mprotect.c +++ c/mm/mprotect.c @@ -139,9 +139,9 @@ static unsigned long change_pte_range(st } ptep_modify_prot_commit(vma, addr, pte, oldpte, ptent); pages++; - } else if (is_swap_pte(oldpte)) { + } else if (IS_ENABLED(CONFIG_MIGRATION)) { swp_entry_t entry =3D pte_to_swp_entry(oldpte); - pte_t newpte; + pte_t newpte =3D oldpte; =20 if (is_write_migration_entry(entry)) { /* @@ -154,7 +154,9 @@ static unsigned long change_pte_range(st newpte =3D pte_swp_mksoft_dirty(newpte); if (pte_swp_uffd_wp(oldpte)) newpte =3D pte_swp_mkuffd_wp(newpte); - } else if (is_write_device_private_entry(entry)) { + } + + if (is_write_device_private_entry(entry)) { /* * We do not preserve soft-dirtiness. See * copy_one_pte() for explanation. @@ -163,8 +165,6 @@ static unsigned long change_pte_range(st newpte =3D swp_entry_to_pte(entry); if (pte_swp_uffd_wp(oldpte)) newpte =3D pte_swp_mkuffd_wp(newpte); - } else { - newpte =3D oldpte; } =20 if (uffd_wp)