From patchwork Fri Jul 29 01:40:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12931863 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 820F2C00140 for ; Fri, 29 Jul 2022 01:40:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B790B94000A; Thu, 28 Jul 2022 21:40:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8467940007; Thu, 28 Jul 2022 21:40:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B06D94000A; Thu, 28 Jul 2022 21:40:52 -0400 (EDT) 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 746FC940007 for ; Thu, 28 Jul 2022 21:40:52 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 531711A1091 for ; Fri, 29 Jul 2022 01:40:52 +0000 (UTC) X-FDA: 79738433544.27.DD01D5D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id D7E4C4002C for ; Fri, 29 Jul 2022 01:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659058851; 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=uHCAtjKZb2F/RWm6an0jiLe9Ivmk/LTJJW/gUBH3IyE=; b=UMtlD86tCEgq4P5alY/2+yqc4dUS0/WHWGAy0si/33cKjFYIA6aiRjwijjt9O1aPx4PHIM RiafF0BqwnaucU88bHOvKZh96pse6zh/glNZyLZjYwdPvC7PUdPUOqiwsuI8P6fAFPBxkd WQ4M0+HLqD+F1goX/NP8WoKKhGgGhnA= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-159-XPBN-SMlP2GB9WM2LSZhVg-1; Thu, 28 Jul 2022 21:40:50 -0400 X-MC-Unique: XPBN-SMlP2GB9WM2LSZhVg-1 Received: by mail-qk1-f199.google.com with SMTP id bj26-20020a05620a191a00b006b5c4e2dc77so2622042qkb.16 for ; Thu, 28 Jul 2022 18:40:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uHCAtjKZb2F/RWm6an0jiLe9Ivmk/LTJJW/gUBH3IyE=; b=w/MAaxGTE3H8/LdJdOm8Lz1R4N1KpUeHzSiTUTfZ1Ctatm1V6KmAzpFspCiI/8uv63 iAuanTMNh56cB7L6Jo8JIPtKw1kKaYtpbQKY/N1OUvJDeMgkvckoz2gaBuCUhdGBkj14 GSn/BYFGH2NP5bjWl6E77+z1dXJd3ZhVkHgDKCmbfuiGHN+19UWluz4MZrUoe3Zo8p/e YfnCk1bYBxDCFB+WsV9bX4UGi5T8TL0NUDmYegRx20N1fdXzEuuhQ37ZH7lWAnEKUlnX HMeUkTTNf/qjSoFXXh8t9Y9meWw74YacFov6SabfzyH2qvqfdu2TXAynOHXjTY8E515Q 8AsA== X-Gm-Message-State: AJIora8n3z7TUyRNR5RuYSyAUVX/6FMFEuVGglum/MX5ennffv7qGF0b voa2CQ4RFhRygW8x0KnJlHb/KaJugrdArNA+lAPJsunOHKE1MsgJYJxpzMCGX1fwJgoBxhkQzP4 mlv9SrU1P5reSsO4qfGu4txZVr7eqA6I2NKSVdJFMeqlkSWWDlR5VXDImZ4YH X-Received: by 2002:a05:620a:440e:b0:6b2:82cf:d7f9 with SMTP id v14-20020a05620a440e00b006b282cfd7f9mr1167970qkp.761.1659058849608; Thu, 28 Jul 2022 18:40:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tfN//pDoVVznadr+/YqP0HOgEHhd9oPJGkyGyuWdvXw2h2kgiA9ytnZN60UnD+9V24+DCcyQ== X-Received: by 2002:a05:620a:440e:b0:6b2:82cf:d7f9 with SMTP id v14-20020a05620a440e00b006b282cfd7f9mr1167951qkp.761.1659058849320; Thu, 28 Jul 2022 18:40:49 -0700 (PDT) Received: from localhost.localdomain (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id u9-20020a05620a454900b006b259b5dd12sm1584531qkp.53.2022.07.28.18.40.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 Jul 2022 18:40:48 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Huang Ying , peterx@redhat.com, Andrea Arcangeli , Andrew Morton , "Kirill A . Shutemov" , Nadav Amit , Hugh Dickins , David Hildenbrand , Vlastimil Babka Subject: [PATCH RFC 4/4] mm/x86: Define __ARCH_SWP_OFFSET_BITS Date: Thu, 28 Jul 2022 21:40:41 -0400 Message-Id: <20220729014041.21292-5-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220729014041.21292-1-peterx@redhat.com> References: <20220729014041.21292-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659058852; a=rsa-sha256; cv=none; b=5RP4EFyxRts8Ru9/VqM4riVccL0TeUk0xzxSnvw/TcVroCT4mwb1r/r6vJ0WJUeJ3ofK0R NzbGlgV2IMlKJOVO7P7obyvecn0Vi0792z27Yjt7p60INF0MhhBQY36x8SxTfH1iZaF5jb MWqxJlYUYzXgujJGz+jdgPI9CdZIPUU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UMtlD86t; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659058851; 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=uHCAtjKZb2F/RWm6an0jiLe9Ivmk/LTJJW/gUBH3IyE=; b=HxDlS43iiWCmQh5K6Pb8LX1D6Cj0t7bxjNJFyi+pw6aTVuh3qo6MfP3K0gI0sZdp9k1W4B fgfPAyGMGMQT9IR3GUKI2s4n9q3VWxmTGJLs1A76oRfl+hikKKMrPR8jo1VhiIC1DzsIEF aoac3LNm4M2UOkbyT0zYInspMbk7nwc= X-Rspamd-Queue-Id: D7E4C4002C X-Rspam-User: X-Stat-Signature: ztjfirjfsfu8emqdie5paw5dj7y6qf8y Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UMtlD86t; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam08 X-HE-Tag: 1659058851-53375 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: This will enable the new migration young bit for all x86 systems for both 32 bits and 64 bits systems (including PAE). Signed-off-by: Peter Xu --- arch/x86/include/asm/pgtable-2level.h | 6 ++++++ arch/x86/include/asm/pgtable-3level.h | 7 +++++++ arch/x86/include/asm/pgtable_64.h | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h index 60d0f9015317..6e70833feb69 100644 --- a/arch/x86/include/asm/pgtable-2level.h +++ b/arch/x86/include/asm/pgtable-2level.h @@ -95,6 +95,12 @@ static inline unsigned long pte_bitop(unsigned long value, unsigned int rightshi #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) #define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) +/* + * This defines how many bits we have in the arch specific swp offset. + * For 32 bits vanilla systems the pte and swap entry has the same size. + */ +#define __ARCH_SWP_OFFSET_BITS (sizeof(swp_entry_t) - SWP_TYPE_BITS) + /* No inverted PFNs on 2 level page tables */ static inline u64 protnone_mask(u64 val) diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h index 28421a887209..8dbf29b51f8b 100644 --- a/arch/x86/include/asm/pgtable-3level.h +++ b/arch/x86/include/asm/pgtable-3level.h @@ -287,6 +287,13 @@ static inline pud_t native_pudp_get_and_clear(pud_t *pudp) #define __pte_to_swp_entry(pte) (__swp_entry(__pteval_swp_type(pte), \ __pteval_swp_offset(pte))) +/* + * This defines how many bits we have in the arch specific swp offset. + * Here since we're putting the 32 bits swap entry into 64 bits pte, the + * limitation is the 32 bits swap entry minus the swap type field. + */ +#define __ARCH_SWP_OFFSET_BITS (sizeof(swp_entry_t) - SWP_TYPE_BITS) + #include #endif /* _ASM_X86_PGTABLE_3LEVEL_H */ diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index e479491da8d5..1714f0ded1db 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -217,6 +217,11 @@ static inline void native_pgd_clear(pgd_t *pgd) /* We always extract/encode the offset by shifting it all the way up, and then down again */ #define SWP_OFFSET_SHIFT (SWP_OFFSET_FIRST_BIT+SWP_TYPE_BITS) +/* + * This defines how many bits we have in the arch specific swp offset. 64 + * bits systems have both swp_entry_t and pte in 64 bits. + */ +#define __ARCH_SWP_OFFSET_BITS (BITS_PER_LONG - SWP_OFFSET_SHIFT) #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS)