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 87C6EC433FE for ; Tue, 15 Nov 2022 18:03:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6B996B0071; Tue, 15 Nov 2022 13:03:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1BB36B0072; Tue, 15 Nov 2022 13:03:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE38F6B0073; Tue, 15 Nov 2022 13:03:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AFB306B0071 for ; Tue, 15 Nov 2022 13:03:50 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6DD701A0DFC for ; Tue, 15 Nov 2022 18:03:50 +0000 (UTC) X-FDA: 80136449820.24.0D73700 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 08462140015 for ; Tue, 15 Nov 2022 18:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668535428; 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=VZPGmCDP4PdFjMklWOBrmsqQLminbKqT3dINkdp9yW4=; b=fZ+rWeSsnKXg293z9HL6yOmD7UDK9J5zQrYxWyZnh99EV/ASOnJhTN5gEz/n1rpNRm9vdd Fotc7xVsMKHM2DR05YWA+e+pdgRGpyd8nNv1CH2Hkq0Vq62DW9VwagKGf/iDH5Eqw44DkJ 3L2ZaLM9cP1fzSvFsAyJGkDMVrpPt5o= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-528-cyZryJS2NeaZRx7bdpN3dw-1; Tue, 15 Nov 2022 13:03:47 -0500 X-MC-Unique: cyZryJS2NeaZRx7bdpN3dw-1 Received: by mail-qk1-f199.google.com with SMTP id ay43-20020a05620a17ab00b006fa30ed61fdso14315283qkb.5 for ; Tue, 15 Nov 2022 10:03:47 -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=VZPGmCDP4PdFjMklWOBrmsqQLminbKqT3dINkdp9yW4=; b=i8clMdFOHKRk8Aj2BDRt/pzO5TXK2p4DbOV+1msqhiPhspVM76C9IbHIzDNnfPFYfe zTBENeE0mYAUKL9QSz5HUU8nY+ojikhJmggm3zN8sYJkJZCSn2uRgomgaUo9eUe844GR Ww/dfjyUB/JYh2IOdCrdth5or0k2ycz9zkZf+xm7Ip+/JxdY2Tx2e1/llfbzNXFP/FCz meHdaKrvzNRMiZDMOdMYueQSy1eQNRt0NAOsr3n1/+KZ8ROU59r+NCg3Cu3NyJ6aH2Lu VKundSjcP5XisCNaeNAP3JtD5zVpdKq4EwoZEWRAdfekAKRIs+XiY90FhjIL8joA2G8u y4Bw== X-Gm-Message-State: ANoB5pnV64P3sEFZV+Mpawiudi9SI2Vro2HXanOezVwxy/dITgqDnYn1 Icn59szT0QYuHohgVClbNZO2gi1p0wkVzcT02hl4Ul13Ghss7W9Z5mU6VwR4Wx0fBMHORHI4gSE YiC8sX7hpzm4= X-Received: by 2002:a0c:fb4f:0:b0:4bb:746b:b643 with SMTP id b15-20020a0cfb4f000000b004bb746bb643mr17508980qvq.19.1668535426682; Tue, 15 Nov 2022 10:03:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mtOCzP7fiXUrDhLbvxXOqillzwqzhWEmXWxlkkc1Rq2ucanEsEPbR5tAtX2D+jVp+DisnVg== X-Received: by 2002:a0c:fb4f:0:b0:4bb:746b:b643 with SMTP id b15-20020a0cfb4f000000b004bb746bb643mr17508949qvq.19.1668535426426; Tue, 15 Nov 2022 10:03:46 -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 e8-20020ac86708000000b003431446588fsm7455092qtp.5.2022.11.15.10.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 10:03:46 -0800 (PST) Date: Tue, 15 Nov 2022 13:03:44 -0500 From: Peter Xu To: David Hildenbrand 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> <9af36be3-313b-e39c-85bb-bf30011bccb8@redhat.com> <82d7a142-8c78-4168-37e9-7b677b18987a@redhat.com> MIME-Version: 1.0 In-Reply-To: <82d7a142-8c78-4168-37e9-7b677b18987a@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668535429; 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=VZPGmCDP4PdFjMklWOBrmsqQLminbKqT3dINkdp9yW4=; b=BdyE5QIFdt5q+9qoV7sVqgbOQoDjs1pkl+NAw9KtaYEVl0YuWJllUYZV2hXTpayvlEZNRb RQiBlaUOmLMd5pYAUcBw+cw8B9oG7rs6t1imR+1MDRypiqdF7e9wvVVVIkmkPb+OOPO1bZ E6GFUfQ7mGZvPePg0o82vYLRo/ZAxho= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fZ+rWeSs; spf=pass (imf26.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668535429; a=rsa-sha256; cv=none; b=8I6m57ezsqu2N50GWG9l0njRZKJjHr0XColUO04skLzpN8wRFyScxnA6/RxWtRGFQluU2J aZEUgX7JxrPomN70lAkJm8nJaDuSS3yWJQfuHxKyjjDRmJ4j4vP2HJpjog5GtzAbH6JIXQ Xd9wwisVgBgPygQivzX/qJQFwb31+iQ= X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 08462140015 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fZ+rWeSs; spf=pass (imf26.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: b97cfwfnqqrifqfcyt14m8odtim4na8j X-HE-Tag: 1668535428-951505 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 Tue, Nov 15, 2022 at 06:22:03PM +0100, David Hildenbrand wrote: > That's precisely what I had in mind recently, and I am happy to hear that > you have similar idea: > > https://lkml.kernel.org/r/20221108174652.198904-6-david@redhat.com > > " > Note that we don't optimize for the actual migration case: > (1) When migration succeeds the new PTE will not be writable because the > source PTE was not writable (protnone); in the future we > might just optimize that case similarly by reusing > can_change_pte_writable()/can_change_pmd_writable() when removing > migration PTEs. > " I see, sorry I haven't yet read it, but sounds doable indeed. > > Currently, "readable_migration_entry" is even wrong: it might be PROT_NONE > and not even readable. Do you mean mprotect(PROT_NONE)? If we read the "read migration entry" as "migration entry with no write bit", it seems still fine, and code-wise after pte recovered it should still be PROT_NONE iiuc because mk_pte() will just make a pte without e.g. _PRESENT bit set on x86 while it'll have the _PROT_NONE bit. May not keep true for numa balancing though: when migration happens after a numa hint applied to a pte, it seems to me it's prone to lose the hint after migration completes (assuming this migration is not the numa balancing operation itself caused by a page access). Doesn't sound like a severe issue though even if I didn't miss something, since if the page got moved around the original hint may need to reconsider anyway. -- Peter Xu