From patchwork Wed Aug 3 00:37:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12935107 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 7D195C00140 for ; Wed, 3 Aug 2022 00:37:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B110C8E0002; Tue, 2 Aug 2022 20:37:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0B98E0001; Tue, 2 Aug 2022 20:37:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9885A8E0002; Tue, 2 Aug 2022 20:37: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 888A08E0001 for ; Tue, 2 Aug 2022 20:37:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 573D2120F93 for ; Wed, 3 Aug 2022 00:37:50 +0000 (UTC) X-FDA: 79756418700.09.BD9065E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id D991F40112 for ; Wed, 3 Aug 2022 00:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659487069; 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; bh=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=ieAni7vvpWM/eXhHbekwcncgq28zeQxVjGu6g5OrJUeTBQYJXM0pURdss7xpYTce2YYZWV Dyj5HhU08YudA61bJculUF8QIwr2pNCepbUG9p4msMY9OG3OEF7hBeyXdGHAUs3WX80xbN RHRdxVBzLbsYTBM/qn0CM/wa4nivbEI= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-13ExKm0IPaS4iQGwRkKlOA-1; Tue, 02 Aug 2022 20:37:48 -0400 X-MC-Unique: 13ExKm0IPaS4iQGwRkKlOA-1 Received: by mail-qt1-f198.google.com with SMTP id a18-20020a05622a02d200b0031ed7ae9abeso9939976qtx.8 for ; Tue, 02 Aug 2022 17:37: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:mime-version :content-transfer-encoding; bh=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=oaUMnWJ/yzHS04UPfuqnBkMGMHqa6aMgQx9Bs5rvlw+b2yBK7jk8OoOlTUbcVMx++q WOHDqLcJJ15uSADwo89AvJS6i7bDvBzhS6pOIejv4mYbXvwL9v6UQfu0MzteQY7zYkNK GIVLZoXKz4VPmOgJ1pDwkethx2r2bK1691rpjkGywDfFMBclS0vznqGMx7KUrvMqqLKr GcR8R5ZUDDF3UsOqo4fk+byvBaYGP2JFTABurenWkvgfDRUogbRDjuzn1CKIddjvUMro b9Z+Tym1K7p6xSXe/iMOAMUJeM9ow8ccSVIMDUYh+xigBjZ5x7je/oRBbrlp+PIBVC4H UijA== X-Gm-Message-State: ACgBeo2/fhiK210qKExZIcWjQqgLQVQZtN22MBeDZLZZZZodjzYZCW/y pJinNL4kfENJzWg/mfrvSvokAOpZ+CQGi9X4mflN8Y4CBvV49AOC1c43cxSsNAmeM/aLpVh7kGt 8yR027JNu3elEnwwEKKhepjmphAAT8D5714R69ob9H45HLqg11sz+5QdxfU0d X-Received: by 2002:a0c:eb09:0:b0:474:9b46:f9f6 with SMTP id j9-20020a0ceb09000000b004749b46f9f6mr16639437qvp.78.1659487067929; Tue, 02 Aug 2022 17:37:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VOO+RLJg2umykRFY/og+D9grZv9NcB4WO0HpWj1YDpwIMm8DQoa374LSWA88zj9M5F7WI+w== X-Received: by 2002:a0c:eb09:0:b0:474:9b46:f9f6 with SMTP id j9-20020a0ceb09000000b004749b46f9f6mr16639420qvp.78.1659487067615; Tue, 02 Aug 2022 17:37: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 h19-20020ac85e13000000b0031eb02307a9sm10955301qtx.80.2022.08.02.17.37.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Aug 2022 17:37:46 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , peterx@redhat.com Subject: [PATCH] mm/x86: Use SWP_TYPE_BITS in 3-level swap macros Date: Tue, 2 Aug 2022 20:37:45 -0400 Message-Id: <20220803003745.35263-1-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 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=1659487070; 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: references:dkim-signature; bh=MNwWCoZOuwPxSYyDQ6YzxKBvZEYHs5K0G6f2+t5kiFc=; b=55cLDnazhKhXqtfztTIOYZPc3vi6Ipvi9UcHt6wxJB/d4YpsGQyGtkTxgIoXSYG2L1VtN+ uoWO+zzrn9qOreeK9QCJos4aKrmuo3kB1lg68XBkLhEDW/8u45sZRzSWl9XIwx2FBOZxyt Rm6BpDUIeX05Amq4qsgIxhCPUpq/AmI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ieAni7vv; spf=pass (imf01.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=1659487070; a=rsa-sha256; cv=none; b=D1EeChg2sU7JKt7PtTMBTgsdJsLaxnHetCp8e0aN6LmEmiInrKz4ocbbK18cs+HYcktfIZ HLKrcCSLLCQ1vLUgEej+oSEE2l4eJCi/Izj6d6D8RTi0ynebe6KyItuycnldDzeJAo8Pr2 ys9fCEHnw8xI1+EDQoGXBVzgSaM0h5k= X-Stat-Signature: sa8sfyse1xexbucrgxtprzjn34dzcwtg X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D991F40112 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ieAni7vv; spf=pass (imf01.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-HE-Tag: 1659487069-674917 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 Reviewed-by: David Hildenbrand --- 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