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 F400AC433F5 for ; Tue, 24 May 2022 10:05:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 660948D0002; Tue, 24 May 2022 06:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60C358D0001; Tue, 24 May 2022 06:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCEE8D0002; Tue, 24 May 2022 06:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 416088D0001 for ; Tue, 24 May 2022 06:05:52 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 10161610A7 for ; Tue, 24 May 2022 10:05:52 +0000 (UTC) X-FDA: 79500205344.18.53FD2E8 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf08.hostedemail.com (Postfix) with ESMTP id 4A4791600E8 for ; Tue, 24 May 2022 10:05:27 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id i27so34234327ejd.9 for ; Tue, 24 May 2022 03:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WekZdZTtTNu0NCjGCUwHIK8cT32r5xb10hc0djOUWXs=; b=iQdlwXfcFTeKrLPSKVE/Bm0wY66qW8ercKJraL44NeKyxEydbTPt7CkSnFPLomQQDI Bb6wfH8bHi8LeEWFw87oHU5bQZH7gx6ZNmZAysdrEwZ2uR/YW0qP1THblazfpJx1+3gr T+UoQpVOD+6mq4lpryYZzi85Qoibl0SitRsc5L75FXOkE1mwe1vEb1mkLL+mQkdjyTxZ waO5mZlPtHZy8fz96dJUTLR4Hul/Ea9NeHca6IeTAg+ytGfH9gial0XvID9ws8jwxw6v vhBkSEN2a4i219Ucj2Ld9Rfw1nBGmXZGi15iS6OyNjDT8VfD3LSR/1C3w+W6witY4oV1 icqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WekZdZTtTNu0NCjGCUwHIK8cT32r5xb10hc0djOUWXs=; b=osVzZeaNU+wR3geUzd7rsj8i5khkwdpMek4xPW/c+CtVnQ/Q2ri4I89ZMmNvYFdkmB exGka3RUjUfdZMgHMhmqwo5R8qj4n/Hj+tLUc8w7k/SGH7/5lV6rjBU1YGW/F/u2LSsx WWoSuKJzwFO9anG6PFYbEkGHaGNglUAqEPs928Czbi/3GEyTzOy2829Hd6711RQpFJ8D 220vDwNQtp0CZMViDv4WuirOQxUKypYcEYcBUPl3UEQarMjhb0z3Zk4ObepAyrp9DVWx CrU95KkBCA8zUT0RBEBvOwIPY2OIV25R/2s4p9eyClZ8WlqHZ2X57oisFFg1LtgP/TpP jcOg== X-Gm-Message-State: AOAM531E+zCb8GyBz7SC/wD62tIQ3XrE2plqQjvQbUy6+fGxuXbGh0QX EJg2BjUzcTu2PoZ3NvqkpSbi3NFOvddqBsBYNCo= X-Google-Smtp-Source: ABdhPJz7BFtcuW392zVcxz+55BtKJcIy0OchNSwmEIJCh+IDTmYaxQ2WerYbh16n7ynBHq0RShXf5gQOBDfZGuJlQP0= X-Received: by 2002:a17:906:7309:b0:6f5:ea1:afa with SMTP id di9-20020a170906730900b006f50ea10afamr23767700ejc.170.1653386746877; Tue, 24 May 2022 03:05:46 -0700 (PDT) MIME-Version: 1.0 References: <20220524071403.128644-1-21cnbao@gmail.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Tue, 24 May 2022 22:05:35 +1200 Message-ID: Subject: Re: [PATCH] arm64: enable THP_SWAP for arm64 To: Catalin Marinas Cc: Andrew Morton , Will Deacon , Linux-MM , LAK , LKML , hanchuanhua , =?UTF-8?B?5byg6K+X5piOKFNpbW9uIFpoYW5nKQ==?= , =?UTF-8?B?6YOt5YGl?= , Barry Song , "Huang, Ying" , Minchan Kim , Johannes Weiner , Hugh Dickins , Shaohua Li , Rik van Riel , Andrea Arcangeli , Steven Price Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iQdlwXfc; spf=pass (imf08.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: bjohydrta1fdzhhi4gmqqq8fibmtqfft X-Rspamd-Queue-Id: 4A4791600E8 X-Rspamd-Server: rspam01 X-HE-Tag: 1653386727-204933 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, May 24, 2022 at 8:12 PM Catalin Marinas wrote: > > On Tue, May 24, 2022 at 07:14:03PM +1200, Barry Song wrote: > > From: Barry Song > > > > THP_SWAP has been proved to improve the swap throughput significantly > > on x86_64 according to commit bd4c82c22c367e ("mm, THP, swap: delay > > splitting THP after swapped out"). > > As long as arm64 uses 4K page size, it is quite similar with x86_64 > > by having 2MB PMD THP. So we are going to get similar improvement. > > For other page sizes such as 16KB and 64KB, PMD might be too large. > > Negative side effects such as IO latency might be a problem. Thus, > > we can only safely enable the counterpart of X86_64. > > > > Cc: "Huang, Ying" > > Cc: Minchan Kim > > Cc: Johannes Weiner > > Cc: Hugh Dickins > > Cc: Shaohua Li > > Cc: Rik van Riel > > Cc: Andrea Arcangeli > > Signed-off-by: Barry Song > > --- > > arch/arm64/Kconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index d550f5acfaf3..8e3771c56fbf 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -98,6 +98,7 @@ config ARM64 > > select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36) > > select ARCH_WANT_LD_ORPHAN_WARN > > select ARCH_WANTS_NO_INSTR > > + select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES > > I'm not opposed to this but I think it would break pages mapped with > PROT_MTE. We have an assumption in mte_sync_tags() that compound pages > are not swapped out (or in). With MTE, we store the tags in a slab I assume you mean mte_sync_tags() require that THP is not swapped as a whole, as without THP_SWP, THP is still swapping after being splitted. MTE doesn't stop THP from swapping through a couple of splitted pages, does it? > object (128-bytes per swapped page) and restore them when pages are > swapped in. At some point we may teach the core swap code about such > metadata but in the meantime that was the easiest way. > If my previous assumption is true, the easiest way to enable THP_SWP for this moment might be always letting mm fallback to the splitting way for MTE hardware. For this moment, I care about THP_SWP more as none of my hardware has MTE. diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 45c358538f13..d55a2a3e41a9 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -44,6 +44,8 @@ __flush_tlb_range(vma, addr, end, PUD_SIZE, false, 1) #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#define arch_thp_swp_supported !system_supports_mte + /* * Outside of a few very special situations (e.g. hibernation), we always * use broadcast TLB invalidation instructions, therefore a spurious page diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 2999190adc22..064b6b03df9e 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -447,4 +447,16 @@ static inline int split_folio_to_list(struct folio *folio, return split_huge_page_to_list(&folio->page, list); } +/* + * archs that select ARCH_WANTS_THP_SWAP but don't support THP_SWP due to + * limitations in the implementation like arm64 MTE can override this to + * false + */ +#ifndef arch_thp_swp_supported +static inline bool arch_thp_swp_supported(void) +{ + return true; +} +#endif + #endif /* _LINUX_HUGE_MM_H */ diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 2b5531840583..dde685836328 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -309,7 +309,7 @@ swp_entry_t get_swap_page(struct page *page) entry.val = 0; if (PageTransHuge(page)) { - if (IS_ENABLED(CONFIG_THP_SWAP)) + if (IS_ENABLED(CONFIG_THP_SWAP) && arch_thp_swp_supported()) get_swap_pages(1, &entry, HPAGE_PMD_NR); goto out; } > -- > Catalin Thanks Barry