From patchwork Thu Aug 11 16:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12941581 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 1F06BC19F2A for ; Thu, 11 Aug 2022 16:13:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E7428E0003; Thu, 11 Aug 2022 12:13:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CEC18E0002; Thu, 11 Aug 2022 12:13:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 247BA8E0003; Thu, 11 Aug 2022 12:13:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0BF7A8E0001 for ; Thu, 11 Aug 2022 12:13:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 99F261217D7 for ; Thu, 11 Aug 2022 16:13:38 +0000 (UTC) X-FDA: 79787807316.09.C2317DA 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 31B904017E for ; Thu, 11 Aug 2022 16:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660234417; 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=nfi/Ecb+oYo1RXzYzaJhIF6aEHnKWbHUlt161URhhFA=; b=GhsOGOx+UWqgdk2hLvFdA/eje74sCFQsPeRXdDNjHvzK3Otd+Mrpav1B0lpKp30PgCg2wa btm7fZwBHcS040weXYswe/FFkU71n+WM5P4a7vtmKfZUZm+OaoHQgl3n8ew5BA36ineajT YGPkKdNXFqkbrkRMUQfoWriJsUbg+Qo= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-29-3LUFS5QcNdKeaQOQmWXhAA-1; Thu, 11 Aug 2022 12:13:36 -0400 X-MC-Unique: 3LUFS5QcNdKeaQOQmWXhAA-1 Received: by mail-io1-f70.google.com with SMTP id i20-20020a5d88d4000000b0067d13ffbe8cso10007442iol.22 for ; Thu, 11 Aug 2022 09:13:36 -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=nfi/Ecb+oYo1RXzYzaJhIF6aEHnKWbHUlt161URhhFA=; b=rSOdpBoJAd8gYk6xTC0tw2cXxNJcgEhMXLOgamFIpWoI9ZwR607WLV5iHqhoC0WCHl gu2w+SeXPSCGNS/t2MbuPimHR67byjcYIgvmYH/Y5ufoEjW71UzRU/jSjEFkk8wzzPo7 kEAUblvU1z/Z+XOTaK26+VEKNUQk7cIHxhCI7W7FgjabYwGvodVerAqMbnI7YsHl2q0a PgrTvcotoiE5nylQGZHV4EQ0f7yhJx148AYLoEG92LjWUNIFyR6bciqLe6Q4OjD+IBXg hCdJqaveXaf/xNk2WReNeLgagakVrATeuAu7O+89LikrfU280smuNNaDZgT92HNK06XU USog== X-Gm-Message-State: ACgBeo0gwuBwn6pRPNUsisQVNKGNcrzhUJEK0YtRAXujosKsDQ92LPs+ HK7BuIAd3pTt+othtcnNRVVKbZJacTVvSQYRDdNYm3llHVQ6aRbRkJvT8DjiBng3aXBKhpvuVCx DNUBBARWWd/Wku3u87gzro5+5FZMv4OE586r1rmRW0WfJx/+ue4ME+w1bjS9S X-Received: by 2002:a05:6602:4019:b0:684:4cde:9e74 with SMTP id bk25-20020a056602401900b006844cde9e74mr16667iob.53.1660234415607; Thu, 11 Aug 2022 09:13:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR6aerHoxC67XZ45dRi+nnFHBgH3aaV4pC70vmG8Qq33dGhvpVJki9kiKQSL4lwRWMdaL0bZUw== X-Received: by 2002:a05:6602:4019:b0:684:4cde:9e74 with SMTP id bk25-20020a056602401900b006844cde9e74mr16649iob.53.1660234415385; Thu, 11 Aug 2022 09:13:35 -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 t1-20020a92ca81000000b002dd1c3c5c46sm3415429ilo.73.2022.08.11.09.13.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Aug 2022 09:13:34 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , "Kirill A . Shutemov" , Alistair Popple , peterx@redhat.com, Andrea Arcangeli , Minchan Kim , Andrew Morton , David Hildenbrand , Andi Kleen , Nadav Amit , Huang Ying , Vlastimil Babka Subject: [PATCH v4 1/7] mm/x86: Use SWP_TYPE_BITS in 3-level swap macros Date: Thu, 11 Aug 2022 12:13:25 -0400 Message-Id: <20220811161331.37055-2-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220811161331.37055-1-peterx@redhat.com> References: <20220811161331.37055-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=1660234418; a=rsa-sha256; cv=none; b=agJeR2EDffEHgO8R9dc16+q577sVmlQrLXxz527DfFizqhOsoEz+E2Dh0gDEIfUQqGZjwY HnlwJK4hiun7xa6W7vyZYiPwq7ghhsHv7mZPRV3BBZtEoly1ijguLsZQ/3qeQ3+Gtqbj3C Ks2TALi0RiYjFn1AtEEPfwBgbiqgmQs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GhsOGOx+; 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=1660234418; 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=nfi/Ecb+oYo1RXzYzaJhIF6aEHnKWbHUlt161URhhFA=; b=ygvJBfkqKZXiU/1bOWTIZguGTnb2ln4FpmWjKrBZXUAMsbMia5tIdW09C1aVtNBQGq10Kf LAFg1r+hUrfePXcLyJh9f0Le0NDG0LT5T69YCz8lxQtRLm8llWlz5wdos0VcAm6wODneGQ f5UqrZdmAzNQ0oRGji+tNi05/fBVeOI= X-Stat-Signature: q9titms985ii9wtx4tywi6m817r755cw X-Rspamd-Queue-Id: 31B904017E X-Rspam-User: X-Rspamd-Server: rspam03 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GhsOGOx+; 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-HE-Tag: 1660234417-128123 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 Reviewed-by: Huang Ying 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