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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A829C4332F for ; Sun, 13 Nov 2022 23:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235542AbiKMX5c (ORCPT ); Sun, 13 Nov 2022 18:57:32 -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-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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87tu36icej.fsf@nvidia.com> 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