From patchwork Tue Aug 9 22:00:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12939963 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 173F8C25B0D for ; Tue, 9 Aug 2022 22:01:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDC028E0003; Tue, 9 Aug 2022 18:01:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D63AD8E0001; Tue, 9 Aug 2022 18:01:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB4878E0003; Tue, 9 Aug 2022 18:01:07 -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 AD6B58E0001 for ; Tue, 9 Aug 2022 18:01:07 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 84F648124C for ; Tue, 9 Aug 2022 22:01:07 +0000 (UTC) X-FDA: 79781425374.16.7352007 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id ADAA140168 for ; Tue, 9 Aug 2022 22:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660082466; 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=ViWF5oZvZDnfPWYKxgTTuTS7ZUI2Vs+P8BNbSIRNDkc=; b=Wtx9ntMVoao6aSfVQwtkLU6f3kgNof32gE01lYNzjtbXaad5b65BSH0SQc9lObdlVr9ErG QyNdDX0H6a9FJwg3A25sIXJH1/HjzyeYhN7t6Q1bsWrqcFWYcYjsw8aOE1h/dmTEpRS95l w3R0PyIGHncqnJrsT3iqo1hi4geM6Bk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-282-YMwYEx8bNF6HobipVXYWKA-1; Tue, 09 Aug 2022 18:01:05 -0400 X-MC-Unique: YMwYEx8bNF6HobipVXYWKA-1 Received: by mail-qk1-f197.google.com with SMTP id bj26-20020a05620a191a00b006b5c4e2dc77so11196382qkb.16 for ; Tue, 09 Aug 2022 15:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ViWF5oZvZDnfPWYKxgTTuTS7ZUI2Vs+P8BNbSIRNDkc=; b=LZ16Nh5jLZVFhFzjUbY2W1L4iEpfxuQSJPO0yBB20QtCtGuBPPhVVzPg8Y3zMGbEu8 aUSt8sORl8HVuTGmStMfj+x55H/TfMRDU0nbSGJBo+tLGUwBhgDvu4r6iBFmvkwhmLsU RKGgvLbaCXg6kx0PpGOrQF44jSiJpxAxzLYbtzar38vsksBowkKODb79MFFOkYaickP3 iy0ubm8iFxg4KSpw0OW11PRqhGnj+KvpJYRUOQuwjfWPyxetH0nRVNM0xxaiA4L7TdMt 8MAdh3FE5tt+2cN543benpKfFgkY19f8BQPF7kOXUtWq6e0x/erL8WVif69k5+UEbLOG Ui3g== X-Gm-Message-State: ACgBeo0SqnfBDdsanPOUKVdm5eSiwCkTtqPzniP0agwDr86eHTc+v2HC xL8NyHdbraC6QouFN84u/eNa34l2pJLmgAfWTdO42LtWctxtLjTzQLdOoKUriV/oJaHDeU/QVeX EV0db8WV85QNIVU0HbPxsWw7uGQf+t05pX2MHlxvy2kfSK/J6LN8vXzmHFVzW X-Received: by 2002:a05:620a:2552:b0:6b4:8dbf:8992 with SMTP id s18-20020a05620a255200b006b48dbf8992mr18881470qko.109.1660082464726; Tue, 09 Aug 2022 15:01:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dluwUjmka3W+U32hW/DI5Wis2lr4liBhxv8a6zycyIUy5OEofCGKK4slj2jFFitTD8LOwnA== X-Received: by 2002:a05:620a:2552:b0:6b4:8dbf:8992 with SMTP id s18-20020a05620a255200b006b48dbf8992mr18881433qko.109.1660082464471; Tue, 09 Aug 2022 15:01:04 -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 b16-20020a05622a021000b0031eddc83560sm10563383qtx.90.2022.08.09.15.01.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Aug 2022 15:01:04 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Minchan Kim , David Hildenbrand , Nadav Amit , Andrew Morton , Hugh Dickins , Vlastimil Babka , Andrea Arcangeli , Andi Kleen , Huang Ying , "Kirill A . Shutemov" Subject: [PATCH v3 1/7] mm/x86: Use SWP_TYPE_BITS in 3-level swap macros Date: Tue, 9 Aug 2022 18:00:54 -0400 Message-Id: <20220809220100.20033-2-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220809220100.20033-1-peterx@redhat.com> References: <20220809220100.20033-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=1660082466; 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=ViWF5oZvZDnfPWYKxgTTuTS7ZUI2Vs+P8BNbSIRNDkc=; b=5QD7day2/h7w7BvP5YgyRmrghsAPktMBHdjUFhv1+3i6DyFpPy5KbIsz5axZo6FysUe3G3 PurzfyCqvSwS5HjZsT5sT4RUY/m9I8W08BxSr9CUSB/Ikuczx2vAsyyx2pUH5+LIOCSBMj 2WED/Cm6fcscKD58Z8Eoyt8jkIDKJK8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wtx9ntMV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660082466; a=rsa-sha256; cv=none; b=Xv3NouXySUCur8bYLLwa/3lf7/OOhFxwPeL/I2lkQDjlaD34+EqWypoi33o7lQHs/jRZ9N ooz3sg0S7MQcFzVIYvTWYK4cJLa7adtQsT9gAYxhGDILTC80zfZ1xwhW1ZODopVppZ3NWJ O0Btd0wRZT7RG2SMoR6Ma0zenb8ni1E= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wtx9ntMV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: h5i31qsr5eab4g46jybaz4bx7chxkuug X-Rspamd-Queue-Id: ADAA140168 X-Rspam-User: X-HE-Tag: 1660082466-248628 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. Reviewed-by: David Hildenbrand Signed-off-by: Peter Xu Reviewed-by: "Huang, Ying" --- 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