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 E8A03C4332F for ; Tue, 15 Nov 2022 18:08:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 615986B0071; Tue, 15 Nov 2022 13:08:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C5E86B0072; Tue, 15 Nov 2022 13:08:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 466968E0001; Tue, 15 Nov 2022 13:08:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 38E656B0071 for ; Tue, 15 Nov 2022 13:08:09 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0A3591C69B2 for ; Tue, 15 Nov 2022 18:08:09 +0000 (UTC) X-FDA: 80136460698.11.83AB974 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id ACAFA1A000E for ; Tue, 15 Nov 2022 18:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668535688; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YaV9DXbOMx4t3KxfWAWxFC1KlWvt+Cyg0TC84c9INLk=; b=CkgyVpMuaHkz8Kq3KfkiCxw1ErHolhOVRTItSfdLaDbVwrsbtycSl4HLFP0C4p0tZcsES8 LfRYQ1mQaLf4seMafThnSR6whSZBoUc9UOXHLhUK0KriOjy1nSH/xDzTtgOOUV/7CMaiQ3 0yfrRfWRePsir/BlQyhd7eiHCzFUjHc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-550-a5Hus2oKOLyHN7RbUjzvmw-1; Tue, 15 Nov 2022 13:08:04 -0500 X-MC-Unique: a5Hus2oKOLyHN7RbUjzvmw-1 Received: by mail-wr1-f72.google.com with SMTP id w23-20020adf8bd7000000b002358f733307so3065478wra.17 for ; Tue, 15 Nov 2022 10:08:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YaV9DXbOMx4t3KxfWAWxFC1KlWvt+Cyg0TC84c9INLk=; b=Oz0sb+fgTdnG3tXMPMByWp4nKCICXIyapZB2S+SpBJOUUgQ0xKSpguVwO6b4gWdYHK JKdqGKSrF2W0Jw0wzg5d6KS3TNrdQysv5UeDxIc523zsLPsqMzTAyzRy/pQtaeqWSkpP yyxjSHi5I4NqPEPxXjSDW9U8ODpaMVMBs1PWl/PPNleSa8bcfCNkWhgzt93XKC+wNzfm SYzlO6UcBL9V7YMSazd3M04+jytI+ET2Jl3ie/nDheLNCm2cuCH1knhOCrjjLzCR+FV3 LF6NbZ1kRZCBQuKXzv5P3ASfo/40Q94gJf15JNd3JU52BafP/P8tZsLsnTqqGENtOWt8 sAQw== X-Gm-Message-State: ANoB5pkwZf8uIHA7PJa6ppBIUZ7ZUGOGxv59HpJZlhFS/f9iyzeUL3vB S2qk9qGMFSOK+qa++Euk9L3P1CIdH4Uv3aI8+LuMlil0GOmECIp/SdbKxck0+tLUIVuucRsZNwx QTzHRJl7IGK0= X-Received: by 2002:a05:600c:3ac8:b0:3c6:f252:f072 with SMTP id d8-20020a05600c3ac800b003c6f252f072mr1210427wms.145.1668535683579; Tue, 15 Nov 2022 10:08:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kDog3e2g4dZrQaNUBIv/mNp2vLh/DXOZ8aV1zDYH6nrKZG4euRmQihWvuSTkYhtvNm04g0Q== X-Received: by 2002:a05:600c:3ac8:b0:3c6:f252:f072 with SMTP id d8-20020a05600c3ac800b003c6f252f072mr1210405wms.145.1668535683256; Tue, 15 Nov 2022 10:08:03 -0800 (PST) Received: from ?IPV6:2003:cb:c707:9d00:9303:90ce:6dcb:2bc9? (p200300cbc7079d00930390ce6dcb2bc9.dip0.t-ipconnect.de. [2003:cb:c707:9d00:9303:90ce:6dcb:2bc9]) by smtp.gmail.com with ESMTPSA id bk3-20020a0560001d8300b002366c3eefccsm12567795wrb.109.2022.11.15.10.08.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Nov 2022 10:08:02 -0800 (PST) Message-ID: Date: Tue, 15 Nov 2022 19:08:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v2 1/2] mm/migrate: Fix read-only page got writable when recover pte To: Peter Xu 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 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> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668535688; a=rsa-sha256; cv=none; b=iU/ouHH0ic1wk/y4SobGk7d+RR0xwmyimNnVV0/Bn6ek4RNhVpE2DPgC1fdgWq0jHMuhDa 3ad0rlCq5/dtQ9BW3mybgCiYl82I93uPaDeMBzcRPyCykUWeanpfphLNr9KlBttyjF+0RC euu+zFpo9AKLZr11WyB4zNTOdyOHItM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CkgyVpMu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668535688; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YaV9DXbOMx4t3KxfWAWxFC1KlWvt+Cyg0TC84c9INLk=; b=cwJAUZ+QmaK+Wdcsj87uJH4b2vaQGOCclDZviPr6dGQkv+wbPyVy4hS6C2g0e08kcpM6YQ OruqU+Xg0KbuiEznpSnz4GsWHHeFkvVU0h6JeMo5iJxivdsdCzdMz9ekmsaTtdiIe/4J4c AGGxIJFrAc7M+VGxqGbnmiJ8zlNDK7A= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CkgyVpMu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspam-User: X-Stat-Signature: xenaqjt65q7zaw8biqihtoed5coa9kzu X-Rspamd-Queue-Id: ACAFA1A000E X-Rspamd-Server: rspam11 X-HE-Tag: 1668535688-154816 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 15.11.22 19:03, Peter Xu wrote: > 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. Exactly that's the unintuitive interpretation of "readable_migration_entry". By "wrong" I meant: the naming is wrong. > > 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. Yes, I think any migration will lose fake PROT_NONE. "Fake" as in "not VMA permissions" but "additional permissions imposed by NUMA hinting faults." -- Thanks, David / dhildenb