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 3FAF6C433FE for ; Sun, 13 Nov 2022 23:56:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18A256B0072; Sun, 13 Nov 2022 18:56:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 113318E0001; Sun, 13 Nov 2022 18:56:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECEE66B0074; Sun, 13 Nov 2022 18:56:35 -0500 (EST) 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 D9CB46B0072 for ; Sun, 13 Nov 2022 18:56:35 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A73D91C5EF4 for ; Sun, 13 Nov 2022 23:56:35 +0000 (UTC) X-FDA: 80130081150.19.4F4678F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 3C9F1140009 for ; Sun, 13 Nov 2022 23:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668383794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EZbvZ1avvMufEpFcdH/nIpwHKdM0wHX6sD3CBlfSiEs=; b=Iq/QnngSGIGZkxR0hVbMJ+16SSb60g8qz04QJqNIqTtQ96gh5PATwaIGZbBCkFlG3mJDZE IFBLk30vyF+vVKCWQjmGnkfGoA6YT/EmQvUI9xdp/Lp2JldiuH1tieJ7x1B+FJzd3+E+jA gIArL72CGse5CKXyoihfGEaA3V5dbho= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-417-bZnWtKHvMyGdBwYdgoNgdg-1; Sun, 13 Nov 2022 18:56:33 -0500 X-MC-Unique: bZnWtKHvMyGdBwYdgoNgdg-1 Received: by mail-qt1-f200.google.com with SMTP id cm12-20020a05622a250c00b003a521f66e8eso7153620qtb.17 for ; Sun, 13 Nov 2022 15:56:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EZbvZ1avvMufEpFcdH/nIpwHKdM0wHX6sD3CBlfSiEs=; b=xXv1S3swf7iNfr9Rar78XP1M+vA7qL0pP73F8TtRByZcC9bi5olXXzuYE3+xCtNm5H Dj75yDCqCSL+P0Hu9gYMBSTxKoTRDPcCX4HgldY9EGwamkFKTY5EeBqEvk85iLxV7mHK 4bzmTmIOmgtQm2bLXKAbY9InStqzdlmhEJYACkyfquRfrKXcVX8JaZXJ65emnCYdBCIx mI+ic+M787XMM8AFNGOJc1xy/9b7EmWyHUtw13GmDd5OXT0zUqYx97uV+5BljTAhO8VQ 5t/242BM0JaF0BB7mmBOFt+CHKC8LwV6V6C1MVIt3kKGX5JKiSNOSidd9KgSsLwW9YmP uCZQ== X-Gm-Message-State: ANoB5pnCo1BwtFfkGoYcR/MQDxNMVSRQtoksMueKLgCQ8LnkddD6XdJV zol+umsOJiXqSBL8A1twPcp0EzcB0y+un5Xryw8LdnYa8MRzkqGOy3mQFYm9r31zopPz5pHa42Q VyCuck2rBX4A= X-Received: by 2002:ae9:c10c:0:b0:6fa:3cb1:da73 with SMTP id z12-20020ae9c10c000000b006fa3cb1da73mr9400846qki.175.1668383792778; Sun, 13 Nov 2022 15:56:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6EsFagGxYt6hjzxI1lLzrGvIO37GXjcoHtfxyk0egSnoJxB+naPS2mbwEdZSVGxZw83Gaq9A== X-Received: by 2002:ae9:c10c:0:b0:6fa:3cb1:da73 with SMTP id z12-20020ae9c10c000000b006fa3cb1da73mr9400831qki.175.1668383792546; Sun, 13 Nov 2022 15:56:32 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id b18-20020ac87552000000b003a5d7b54894sm2781261qtr.31.2022.11.13.15.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 15:56:31 -0800 (PST) Date: Sun, 13 Nov 2022 18:56:30 -0500 From: Peter Xu To: Alistair Popple Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrea Arcangeli , Axel Rasmussen , Ives van Hoorne , Nadav Amit , Andrew Morton , Mike Rapoport , stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm/migrate: Fix read-only page got writable when recover pte Message-ID: References: <20221110203132.1498183-1-peterx@redhat.com> <20221110203132.1498183-2-peterx@redhat.com> <87tu36icej.fsf@nvidia.com> MIME-Version: 1.0 In-Reply-To: <87tu36icej.fsf@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668383795; a=rsa-sha256; cv=none; b=azwUgiw8HJmPHFkQoTyH1FFAI15mhUInBPtcLcUg+7PYban0We4+EesvQl/Lzu6kTbr5EU g5NSOTxCCkPUBjyWtRgkIKHiKYrSn6OWO1QiS8q008FLn8C70ou9zjoMjILn4yA/fUKoO+ Cc6Q+0Y6WCZ7P2n4jbJCN42khQOa3j0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Iq/QnngS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668383795; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EZbvZ1avvMufEpFcdH/nIpwHKdM0wHX6sD3CBlfSiEs=; b=I5ps+Uyl2UmMGJO1IZRyy9fT6fhgVn3/RQs3b3SPUW16ZfA40GCUNBjxhHcGD26CPNM3cb C3nud7rxWiNBZqjbJAVGFwxz4t8+bBcTcaKqy2ARiX4V4b+Oe3z7cXE1pC+3O+EZodde40 u5RxVrmxbdzaYRoC7FbeZxiIo1hv2Rs= X-Rspamd-Queue-Id: 3C9F1140009 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Iq/QnngS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: ibgduigr3nz7dn3ijadfgfynjknrgisr X-HE-Tag: 1668383795-273262 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 Fri, Nov 11, 2022 at 10:42:13AM +1100, Alistair Popple wrote: > Hi Peter, for the patch feel free to add: > > Reviewed-by: Alistair Popple Will do, thanks. > > I did wonder if this should be backported further for migrate_vma as > well given that a migration failure there might lead a shmem read-only > PTE to become read-write. I couldn't think of an obvious reason why that > would cause an actual problem though. > > I think folio_mkclean() will wrprotect the pte for writeback to swap, > but it holds the page lock which prevents migrate_vma installing > migration entries in the first place. > > I suppose there is a small window there because migrate_vma will unlock > the page before removing the migration entries. So to be safe we could > consider going back to 8763cb45ab96 ("mm/migrate: new memory migration > helper for use with device memory") but I doubt in practice it's a real > problem. IIRC migrate_vma API only supports anonymous memory, then it's not affected by this issue? One thing reminded me is I thought mprotect could be affected but I think it's actually not, because mprotect is vma-based, and that should always be fine with current mk_pte(). I'll remove the paragraph on mprotect in the commit message; that could be slightly misleading. -- Peter Xu