From patchwork Fri Jul 29 01:40:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12931862 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 1CBB2C04A68 for ; Fri, 29 Jul 2022 01:40:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6DEE940009; Thu, 28 Jul 2022 21:40:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF6DF940007; Thu, 28 Jul 2022 21:40:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADEAE940009; Thu, 28 Jul 2022 21:40:50 -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 9C355940007 for ; Thu, 28 Jul 2022 21:40:50 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E03D12109D for ; Fri, 29 Jul 2022 01:40:50 +0000 (UTC) X-FDA: 79738433460.28.3E0E3A8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id A70D418002D for ; Fri, 29 Jul 2022 01:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659058849; 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=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=Hei0UT4Xd2mE/KvgiXPoUYwRf8LcHMnsIAYyKx3VYOUDowJ4sIG4/NCdm4sHIbbDP68BPh simTkoYPrE9PrlvnvIpuaj3IWCqck0EGcKDSKxBxHO06O7DFqmTh3GINtDFFVX6HX2FcYL tlWqYIaDMgP1r/wcHzWy4yQeFZkfcFQ= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-LhKkFr1SOeygH9cX1htU3g-1; Thu, 28 Jul 2022 21:40:48 -0400 X-MC-Unique: LhKkFr1SOeygH9cX1htU3g-1 Received: by mail-qt1-f200.google.com with SMTP id i8-20020ac871c8000000b0031ed35facf3so2087138qtp.0 for ; Thu, 28 Jul 2022 18:40:48 -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=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=TH2pTXoL1pH5IlM6Z+URqh/MvBhabFMssoPBPWPPspObpMLaQAgTG6yKMwjWZuYujX ybUUEp6c0++EdXe1kFKlW+2DGAK7buW5FmyETNAp/eXT10UGRrosSx6W+EfDbRsFKFbR MCvmwBzwr/o4U2G9GV7pXG8zwpcKpekVzZNBcMe1tXnDZPZhj0PMbQzf8I5uFTbeTTc4 QNdy1IFomqKwOPSiQ+sxmHgIdneYnkok5XCULLIo0U5OYIQ9ZHyqQ0MsXEvoEUy422Tw PytJkfnv4SivGinBoDA0hYrrvBCIk+AeLciFNck5EYwQ8aePWWJfSCU0CcrUZlr/A4zc FZ/g== X-Gm-Message-State: AJIora9gXGb0eRC7By99IovLka2IVT/GhUTxnlUVUraUk6flMCo+XjmU dxla66myIt5+N+vFwxgvNO+wG99Vy+1PkA5AgiDWyH/qtIFfBHOpuAbjLAxqsbLCqfl9srJxdqZ XhqEoP1uy89fyRB1us4mip+PWTmtZn9kvsq3L3EIbheN2OnCRHSlAlD1ujJPh X-Received: by 2002:a05:620a:19a7:b0:6b6:b88:3c77 with SMTP id bm39-20020a05620a19a700b006b60b883c77mr1212520qkb.128.1659058848107; Thu, 28 Jul 2022 18:40:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZayzexwXnoLh2k6d3k24YaRhYz1essZsiXQQVUsnUpgPU7CF4SN2TaMXPZPqXjes7ezd3dQ== X-Received: by 2002:a05:620a:19a7:b0:6b6:b88:3c77 with SMTP id bm39-20020a05620a19a700b006b60b883c77mr1212495qkb.128.1659058847825; Thu, 28 Jul 2022 18:40:47 -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.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 Jul 2022 18:40:47 -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 3/4] mm/x86: Use SWP_TYPE_BITS in 3-level swap macros Date: Thu, 28 Jul 2022 21:40:40 -0400 Message-Id: <20220729014041.21292-4-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659058850; 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=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=7rKsqDptuBZW78YsI2xmyKtKB/9aNVTt6laiuxztnzRRMCS+UOkdR52GXfMT99Efq2gwN/ pe5qT7Ear4PLAqIQRCATVmLgigBvuyeQSWQdGnVZ/5TgwEmEsV8SAYFUrL8JR0mcQd5wJC M+ZHmPC3CU7xXgSLrxeDTZqw+rV9txQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hei0UT4X; spf=pass (imf16.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659058850; a=rsa-sha256; cv=none; b=NFGnnDiKaxJivzfH4E69nxR9Y036QP7R+PcRkWWZskp4v13A6jG/YOmVg7kXRQp1wd3qlI jV486OKnlxuvHDpT3+W1Z3+MyBF/eDwFdBJS6YFtw4RBrlRgJ+W881Ngn/Fil/IZAFV1Zf N2D/cDovvlyajsDXhTemyUvqtCrPHGQ= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A70D418002D X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hei0UT4X; spf=pass (imf16.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-Stat-Signature: xkkqmp3mc8ew5tmcrtagoachcwxs37dn X-HE-Tag: 1659058849-942160 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: Replace all the magic "5" with the macro. Signed-off-by: Peter Xu --- arch/x86/include/asm/pgtable-3level.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h index e896ebef8c24..28421a887209 100644 --- a/arch/x86/include/asm/pgtable-3level.h +++ b/arch/x86/include/asm/pgtable-3level.h @@ -256,10 +256,10 @@ static inline pud_t native_pudp_get_and_clear(pud_t *pudp) /* 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) -#define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > 5) -#define __swp_type(x) (((x).val) & 0x1f) -#define __swp_offset(x) ((x).val >> 5) -#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) +#define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS) +#define __swp_type(x) (((x).val) & ((1UL << SWP_TYPE_BITS) - 1)) +#define __swp_offset(x) ((x).val >> SWP_TYPE_BITS) +#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << SWP_TYPE_BITS}) /* * Normally, __swp_entry() converts from arch-independent swp_entry_t to