Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4875029rwb; Sun, 13 Nov 2022 16:07:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Y1viapAouQLN31UC8V97ZwAc2vQBTnZpiui5x20Av3Dv+HRgD03OjMlkQ8stKjJD26gf7 X-Received: by 2002:a17:902:d918:b0:188:9542:52d with SMTP id c24-20020a170902d91800b001889542052dmr11604068plz.143.1668384439873; Sun, 13 Nov 2022 16:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668384439; cv=none; d=google.com; s=arc-20160816; b=Y2TaugxQko5vxFBY2GLdhLd27wzxADWq1Gk4IOQqCE5qnl1eVsrqsbs62ukdQlE+Ge 3h7y05sjpH0cSsiUrvRFSdnd1T6WfoJsIVrLQTOwJ+gZSuMIc+mdrygQtwaDQ1Min0YT IVCU8wvut2JJ3xzhkwKiPiV63HasJZJJQabtSig+O+Cye4cZ5FuIGh8Kj6f2yiHU/Gz+ 5/eymZd3Ta5Ehh0akvuwsFwyA4Ftp3H3eZP5tQaDZUW1amBOQ9yHg8YGAraOmo0FgynU t2ETFLo2L/9xLlWU21OnZIDJLt1xfxIaR7gJr6vW3c1n/+i0GH1jDVtVDOCA8qitof4T 4DtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EZbvZ1avvMufEpFcdH/nIpwHKdM0wHX6sD3CBlfSiEs=; b=m15MTuMhF6AaCAGdYCvBmeb0/sn7A6rWT3bU9L/DHdKAtvLOSxQIn5zoGnrAdrN0FA N1fA0p88t4xA20S8RUCvhRFU+3mrpkpCSkbRG8GNfNPyMXbtsPHQB2AFmaw1ca/kIDeA z8tV4tWyWtPRQA9l5/Kb/vSNSu3101Z+NAeiJe4WGbV9pL9ebJ7NOVxBBSg+lFaFgg7Y bu+ANDtLcu4pkzTX7IyPcIq9EPmjwM2QzBZUoRUcr0p6cr/MTxICHywMOoAUvZHkCt5/ Bx2auud0/+odMyl36w8d4I9kCm00Z0HbrpFWEaNfhv+AplT/T0aVaBXF8OE6izfrLyEI fuTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Iq/QnngS"; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a170902e54100b001869b2c5f47si9396037plf.326.2022.11.13.16.07.08; Sun, 13 Nov 2022 16:07:19 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b="Iq/QnngS"; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235543AbiKMX5b (ORCPT + 89 others); Sun, 13 Nov 2022 18:57:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbiKMX53 (ORCPT ); Sun, 13 Nov 2022 18:57:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7913A65C6 for ; Sun, 13 Nov 2022 15:56:35 -0800 (PST) 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-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-615-AhaoIhLGMh26HFrKyiJ18Q-1; Sun, 13 Nov 2022 18:56:33 -0500 X-MC-Unique: AhaoIhLGMh26HFrKyiJ18Q-1 Received: by mail-qk1-f198.google.com with SMTP id u5-20020a05620a0c4500b006fb30780443so7583356qki.22 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=PExgr40ipn0IP+VjJx16/LjFOZdwlMhH1MHL4/vmFYoGNrnZyxObUv35OHeX5GH202 Mn/wVvgwboEtvGIIUNjoIbxVHfb0WmIDeftiU+n8zpb2lQWBnztBVrKuQHUHp0hph+Sq Pe12BAhXI27RAWYukfEoPBNGpgKK1ZQBZdx7i+rNbtKAPfxWS7ZIwMpKINW+ybRbmwvK QYBM6OkDiIly1maG1z6wXKKZxH6TCa5BU4r5B8T58p9QQivKW+t+hsGTZK5bx2KJZUME 2SRklbc1ZEhCCR81cs6bEsP2gFUMUURw0ymPq4h5ZejOJuVLQPUhz+Ic2DgHXRVxthip lO5A== X-Gm-Message-State: ANoB5pkz42K06ZkFGlK/Arn6xF9QvxfwLgGMt2bseWO+ll2IgPOq0KiZ XxvnsRckw/xY6tawWl4aokDe4CLZJjCQ86EglEkzybyR0nB/HhHGVlxe5p8jrtoJ/QkSxoISaut U/9HAPOuz1onOeuqDdTIRegRj X-Received: by 2002:ae9:c10c:0:b0:6fa:3cb1:da73 with SMTP id z12-20020ae9c10c000000b006fa3cb1da73mr9400840qki.175.1668383792777; Sun, 13 Nov 2022 15:56:32 -0800 (PST) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87tu36icej.fsf@nvidia.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 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