From patchwork Thu May 23 22:37:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13672346 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 9A61AC25B75 for ; Thu, 23 May 2024 22:38:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F9EE6B0099; Thu, 23 May 2024 18:38:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B72D6B0096; Thu, 23 May 2024 18:38:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B1D66B0099; Thu, 23 May 2024 18:37:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D8FE66B0095 for ; Thu, 23 May 2024 18:37:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5474C1C113B for ; Thu, 23 May 2024 22:37:59 +0000 (UTC) X-FDA: 82151124678.17.9203BF5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 55B0F40020 for ; Thu, 23 May 2024 22:37:57 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D6JxcPEZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716503877; 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=U8kmpLF+0wb5DY59Z4GvPb8KdcMgneGoHIufiMB6jJ8=; b=ZydSTKn3dO+TAujF/WeP5hY5bRxSmmDRUNRyzfNDW9niY/ewQ+EvmppFeRrv40MPqLtKQG RtzGS137gq1EhuoQclgIoazrs0744ak5mIrgm3LdjpSruD44gzFQONr6hrrFEsySfLmB0d 6EBJHrz9ut2Ul48nw3z+P6sRkxxkDdg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D6JxcPEZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.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=1716503877; a=rsa-sha256; cv=none; b=VMKRRvnWNuOCQViiCptPFAjkY/GeAgU3KKaav+bfoYd6FyxnV+Fi41D7OgTduY+iMgChi6 f7mW0WTraJ4SlxMAOrrZed9wGdPN5a3QPEmJa4HVzsjEqj1uVC6v8EnYS0OUlc5K4b2SN5 PN8XlxWM4L3GeW+HzKcfvHSwiE1ZrQU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716503876; 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=U8kmpLF+0wb5DY59Z4GvPb8KdcMgneGoHIufiMB6jJ8=; b=D6JxcPEZ1lnJcYhoDLJGCD2w4F+v0CYaaSaRY+utlB2Cg+pYSpUV+EigMqzsWUfZPwjRuP mNwAnYEPfDnwMkFHuSC+WBrmFklKz/j0RuvjJUl0RJiH32t1akfcdf9B0HL9KdIMZmp8TT kppa323OOmhxVi2/5gbv01bQAKz29PI= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-IglmQGcAM1CLayeeJ5GukA-1; Thu, 23 May 2024 18:37:53 -0400 X-MC-Unique: IglmQGcAM1CLayeeJ5GukA-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5b96a8bb2faso56446eaf.2 for ; Thu, 23 May 2024 15:37:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716503872; x=1717108672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U8kmpLF+0wb5DY59Z4GvPb8KdcMgneGoHIufiMB6jJ8=; b=b4KS6w/1uOCOGTV0EIkufEa/NYTGBRhxP4q/P6vPvrJqdEEYTG0K/KVfr5PVw4iTM4 aLpT2hxtNHewCgyrOZvgghSSKnkSyJ0nBGY03x1ba9wvunZs9qxXfS12t6C+yOFPUPzE mL3g8AVYCLLA+g5em2uM8/z6AZwfj5oyYKcKoAQyaeT4ZP+PtVQuXdnrA5W2SzClGpz6 3k7pWIU9TqAlaolt4SXBk78l/RAe51D92xUZXGLUeEpVl7NSckqTlFlTI8Hi7G9saB0t ZjSNn1/PQiy9BIIsSXXC8A6QmO8ghI/BMiD+ai31m11jbCyMc06Vl+ub6L8FbanUnrP1 uOOg== X-Gm-Message-State: AOJu0Yyz0Y60RwOGan6Ws9TWV3Dd2OaKni3R/HEidgj737yywo5uH4Og N+tgZLKUTvNj63sCDv5sjv+U+RUMbS7ZCDwz8e9yyrMWCQ100+ywv4PWQllhipBfUq3ohpvAHiD AqryHow5gky6CJtd04F1IX5JEvMoo2rs1ZqjuoXnEBKTwilK8Y2Z1Sh+bgTZ96Ymf/xPsUuENon ywz3MlF6+3lNLC4z21OhSmyChY88WcYQ== X-Received: by 2002:a05:6870:f708:b0:24c:67b8:2cb8 with SMTP id 586e51a60fabf-24ca0d87c0amr711193fac.0.1716503872081; Thu, 23 May 2024 15:37:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv6EB8iQs0dh9WTeZd8gUJptLRKFfW4krudfOlO5TrsX7uonwQfj9xz3QTacSLo6+IAfGxJA== X-Received: by 2002:a05:6870:f708:b0:24c:67b8:2cb8 with SMTP id 586e51a60fabf-24ca0d87c0amr711127fac.0.1716503871277; Thu, 23 May 2024 15:37:51 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43fb18af1d2sm1066701cf.65.2024.05.23.15.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 15:37:50 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Jason Gunthorpe , Andrew Morton , Al Viro , Dave Hansen , Andy Lutomirski , Matthew Wilcox , peterx@redhat.com, Dan Williams , "Kirill A . Shutemov" , Mike Rapoport , Ingo Molnar , Michal Hocko , Alex Williamson , Peter Zijlstra , Suren Baghdasaryan , Borislav Petkov , x86@kernel.org Subject: [PATCH RFC 2/2] mm/x86/pat: Do proper PAT bit shift for large mappings Date: Thu, 23 May 2024 18:37:45 -0400 Message-ID: <20240523223745.395337-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240523223745.395337-1-peterx@redhat.com> References: <20240523223745.395337-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 55B0F40020 X-Stat-Signature: ptz5mawn7aqk1rstjgzanai5jxrnco5o X-Rspam-User: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dl0CGvxHuhHIna7LIL/QgZLZJgf27CyOI4nKVsMQ4DGVo2biJ0Cftlnr5taK/mFF3DaXQ5HuTaO1BR8hSNyQo4Nn+AmCPtlFgMmeAaEACjS5mECcxGpT9uzHehnQaDZqGbCl2mKtQUP9Of6ED6aLmuMVCU6+kx8LbI/2fmUDXTkCka9yLvBirqWzEYv0tM9etdpPXB6CsSF6Gdknr9SqbzhbTnfHBaB705VCGXwAT8o/osIdgN6CW6uFhZqVdqae1yPHFQDmzf935VLIplFe3JSP0+BFzWMDLVbtbk8SMxkVxeAc5BYdMkNv05r+1zKcovrjRaEGe+TjYLVVWvH/JtltAm4D/xUe+ht0yB0h5TDE3mu42b9iaGOY8//saXkjhsuxHmpul6e09CY461prPqJKVaEGlq5R7yHxiujboFgpPdC0qkvQ8sBTTKBGTgRbFYEublKskfTp70WMDDh6uZ6fmv05Xqm9Kz/g55aSVwCrsXq73TSX3HW4a2/XeWH7hq20TqAhqCsZ0t3R0Ljk2X/tUacIx6eBrOXpkpuClKjgyQsWLBWlKxaY8pQtXwbEP/MfHdcTW6/BYk/avvhLqI+wEEOWm7G9LA/Xydn2dQOWDYYW7vGLAM2bCfD57VKVMkm0bmGSFNsvwfk1NOwmsKw2RmOkLcQ8Bv7bY 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: List-Subscribe: List-Unsubscribe: For large mappings, the pgtable PAT is set on bit 12 (_PAGE_PAT_LARGE) rather than bit 9 (_PAGE_PAT), while bit 9 is used as PAE hint. Do proper shifting when inject large pfn pgtable mappings to make cache mode alright. Cc: Alex Williamson Cc: Jason Gunthorpe Cc: Al Viro Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Kirill A. Shutemov Cc: x86@kernel.org Signed-off-by: Peter Xu Signed-off-by: Peter Xu --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 317de2afd371..c4a2356b1a54 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1135,7 +1135,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, goto out_unlock; } - entry = pmd_mkhuge(pfn_t_pmd(pfn, prot)); + entry = pmd_mkhuge(pfn_t_pmd(pfn, pgprot_4k_2_large(prot))); if (pfn_t_devmap(pfn)) entry = pmd_mkdevmap(entry); if (write) { @@ -1233,7 +1233,7 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, goto out_unlock; } - entry = pud_mkhuge(pfn_t_pud(pfn, prot)); + entry = pud_mkhuge(pfn_t_pud(pfn, pgprot_4k_2_large(prot))); if (pfn_t_devmap(pfn)) entry = pud_mkdevmap(entry); if (write) {