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 1719BC433EF for ; Mon, 18 Jul 2022 16:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D9096B0072; Mon, 18 Jul 2022 12:07:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 387636B0073; Mon, 18 Jul 2022 12:07:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 277D86B0074; Mon, 18 Jul 2022 12:07:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 18C876B0072 for ; Mon, 18 Jul 2022 12:07:07 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id E404312046A for ; Mon, 18 Jul 2022 16:07:06 +0000 (UTC) X-FDA: 79700699652.27.42CA244 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf31.hostedemail.com (Postfix) with ESMTP id 02C6D20068 for ; Mon, 18 Jul 2022 16:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3XVB/nlrkvDOmjrjaiTf3FsIIT/RNdtwVa0SsHwoaZ8=; b=WyPbVehXqWMqowQ5bKPyc4QfGM IDfPKec/SOw6IEsOAsQJ3a94He/hMADv4zEIktxFk+Qk9W4Y99DZQtHjbaQ1Hv+oRKKksSQ689Ez3 qPkNnK9CJkhgeDmN/H4tU3WNSEROIAjvgVxyclSsrGWe4dFzvDhbcnf89Im2zo381KhiowupCK+1b wuRQL88Nyn/Uw+XiI6JoJ6iFrWAG+vOIY4yGU+d8ZWOZSXdd4gEqM9vmsocP0h2mpFv7nHtEpKDe8 V8VChy+aC0ai8bVAky66dAPlZtTYVwQW/fyygG+zcxZYcDJtzT9MOIJcsEsP5G2hthZkBsPa8QK5I GDvzSGuQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDTGn-00CoMn-3m; Mon, 18 Jul 2022 16:06:53 +0000 Date: Mon, 18 Jul 2022 17:06:53 +0100 From: Matthew Wilcox To: Barry Song <21cnbao@gmail.com> Cc: akpm@linux-foundation.org, anshuman.khandual@arm.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, steven.price@arm.com, will@kernel.org, aarcange@redhat.com, guojian@oppo.com, hanchuanhua@oppo.com, hannes@cmpxchg.org, hughd@google.com, linux-kernel@vger.kernel.org, minchan@kernel.org, shy828301@gmail.com, v-songbaohua@oppo.com, ying.huang@intel.com, zhangshiming@oppo.com Subject: Re: [RESEND PATCH v3] arm64: enable THP_SWAP for arm64 Message-ID: References: <20220718090050.2261-1-21cnbao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220718090050.2261-1-21cnbao@gmail.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658160425; a=rsa-sha256; cv=none; b=Aq0rAeH+YY5UtStpllnsVUebKrHI9Ws0D6IbncH2g8WWVlmGrDkWGx3FC4+4Ib1ehBcxlB pnAkzjYc3vMQchoGRQ9lblIcNN6HmzMqsiBXY0nvV6lEh+YNXyKAX+ebUuFNEPAiAygj1I JyjKrWaE8Fq51B2iI3aGut3ebX6xU7Q= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WyPbVehX; dmarc=none; spf=none (imf31.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658160425; 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=3XVB/nlrkvDOmjrjaiTf3FsIIT/RNdtwVa0SsHwoaZ8=; b=UpJkNBO6t9a0cr3CWQw8/YGNF5rGYMMXJoMpbhvGb1HjS+8RZ+5SOUDp6+zJXFlkX3V5Y5 cTeeWmYrqcsV/rArti+tQOwCMCYAWGONZ2tbnSNga0ZFJ0WEf8tPflI/2KryodX7px1w5N u9bj4hHF9Ne6pk07NQxa9/Ik8nYIdFE= X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WyPbVehX; dmarc=none; spf=none (imf31.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Queue-Id: 02C6D20068 X-Rspamd-Server: rspam12 X-Stat-Signature: pywsbrwpbhk9pgs8jir7ma4zwp3s89au X-HE-Tag: 1658160424-548614 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 Mon, Jul 18, 2022 at 09:00:50PM +1200, Barry Song wrote: > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 1652a9800ebe..e1c540e80eec 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -101,6 +101,7 @@ config ARM64 > select ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP > select ARCH_WANT_LD_ORPHAN_WARN > select ARCH_WANTS_NO_INSTR > + select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES Can't you avoid all the other changes by simply doing: select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES && !ARM64_MTE > select ARCH_HAS_UBSAN_SANITIZE_ALL > select ARM_AMBA > select ARM_ARCH_TIMER > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 0b6632f18364..78d6f6014bfb 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -45,6 +45,12 @@ > __flush_tlb_range(vma, addr, end, PUD_SIZE, false, 1) > #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > +static inline bool arch_thp_swp_supported(void) > +{ > + return !system_supports_mte(); > +} > +#define arch_thp_swp_supported arch_thp_swp_supported > + > /* > * 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 de29821231c9..4ddaf6ad73ef 100644 > --- a/include/linux/huge_mm.h > +++ b/include/linux/huge_mm.h > @@ -461,4 +461,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 2a65a89b5b4d..10b94d64cc25 100644 > --- a/mm/swap_slots.c > +++ b/mm/swap_slots.c > @@ -307,7 +307,7 @@ swp_entry_t folio_alloc_swap(struct folio *folio) > entry.val = 0; > > if (folio_test_large(folio)) { > - if (IS_ENABLED(CONFIG_THP_SWAP)) > + if (IS_ENABLED(CONFIG_THP_SWAP) && arch_thp_swp_supported()) > get_swap_pages(1, &entry, folio_nr_pages(folio)); > goto out; > } > -- > 2.25.1 > >