From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Price Subject: Re: [PATCH 2/4] mm: Add arch hooks for saving/restoring tags Date: Thu, 23 Apr 2020 13:37:21 +0100 Message-ID: <380bdf0b-aa7c-399c-d16d-b2aecd3f363c@arm.com> References: <20200422142530.32619-1-steven.price@arm.com> <20200422142530.32619-3-steven.price@arm.com> <20200423090919.GA4963@gaia> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from foss.arm.com ([217.140.110.172]:39054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgDWMh0 (ORCPT ); Thu, 23 Apr 2020 08:37:26 -0400 In-Reply-To: <20200423090919.GA4963@gaia> Content-Language: en-GB Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas , Dave Hansen Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, Andrew Morton , Arnd Bergmann , Hugh Dickins , Vincenzo Frascino , Will Deacon On 23/04/2020 10:09, Catalin Marinas wrote: > On Wed, Apr 22, 2020 at 11:08:10AM -0700, Dave Hansen wrote: >> On 4/22/20 7:25 AM, Steven Price wrote: >>> Three new hooks are added to the swap code: >>> * arch_prepare_to_swap() and >>> * arch_swap_invalidate_page() / arch_swap_invalidate_area(). >>> One new hook is added to shmem: >>> * arch_swap_restore_tags() >> >> How do the tags get restored outside of the shmem path? I was expecting >> to see more arch_swap_restore_tags() sites. > > The restoring is done via set_pte_at() -> mte_sync_tags() -> > mte_restore_tags() in the arch code (see patch 3). > arch_swap_restore_tags() just calls mte_restore_tags() directly. > > shmem is slightly problematic as it moves the page from the swap cache > to the shmem one and I think arch_swap_invalidate_page() would have > already been called by the time we get to set_pte_at() (Steven can > correct me if I got this wrong). That's correct - shmem can pull in pages (into it's own cache) and invalidate the swap entries without any process having a PTE restored. So we need to hook shmem to restore the tags even though there's no PTE restored yet. The set_pte_at() 'trick' enables delaying the restoring of the tags (in the usual case) until the I/O for the page has completed, which might be necessary in some cases if the I/O can clobber the tags in memory. I couldn't find a better way of hooking this. Steve