From patchwork Fri Aug 9 16:08:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13758930 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 93C96C52D7F for ; Fri, 9 Aug 2024 16:09:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B666B6B00A2; Fri, 9 Aug 2024 12:09:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B134A6B00A3; Fri, 9 Aug 2024 12:09:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93E9D6B00A4; Fri, 9 Aug 2024 12:09:30 -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 75C706B00A2 for ; Fri, 9 Aug 2024 12:09:30 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 36C82121117 for ; Fri, 9 Aug 2024 16:09:30 +0000 (UTC) X-FDA: 82433192100.21.9512529 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 3060B12003D for ; Fri, 9 Aug 2024 16:09:27 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpGFTbVt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723219757; a=rsa-sha256; cv=none; b=6/VMhNbM/WFP+owklYsHcinr+LMA+JebbdsLvi5IOvtyg8INPVrdr3oBkKweaMHSZKQphC yGKqVZq7ss8y4YcFHo8+Q/kLnZZvXU/SD/65/WoRvbepwPMtQc23inOLsdj5Tsc2IAmEyA l8CW0P8+kPDLqEmbevMDPUJkDXDZtwA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpGFTbVt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1723219757; 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=ip3F/lMuK2on6ujO8FbOHDG+DYlKv6bK2Y5nLIm/Zzk=; b=z4ft6APio9Ex9mhaZbEO2Bdygqkm/Awub4uvlNQ/dYLtbTk8hk71IXn/Cc8fFj7oq1aDNm 6Ysr9Bu8pFIrf5VsDoUMhLvTAPXvHV5GszDhMbkdOqVexCkqCRZDbk9Pg8jG2oP8YO28aP u3HxrTliqgKq5Xc36ma0yXyPYurXzCQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723219766; 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=ip3F/lMuK2on6ujO8FbOHDG+DYlKv6bK2Y5nLIm/Zzk=; b=LpGFTbVtTohrLvzxpIXLTw/68JaA/e2bvqtH9OdcyDr4M3dL7GL0wehytF2O3k0zkI27Z1 qy43mt1rF+mGCAqaH+810FzBaH6C7OI0f6hRhxo11qmogUg3RIrYODPxQONNBEmkmxN+Xn cUBhgL/Hf6g25S/f4zRD93+En9e0/ZE= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-ddLL0_QROwaWL8nL1tAlsg-1; Fri, 09 Aug 2024 12:09:25 -0400 X-MC-Unique: ddLL0_QROwaWL8nL1tAlsg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4531adc3c76so35721cf.2 for ; Fri, 09 Aug 2024 09:09:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219764; x=1723824564; 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=ip3F/lMuK2on6ujO8FbOHDG+DYlKv6bK2Y5nLIm/Zzk=; b=f6frIQMMe0dUcAF05B+d2vl2pDtDVvNjyl9ePTp3ZJBhGLWPBWyF1l1MTcWxtxUmEs L2AOYy/9irf7lu+DqtfXXb4Cdgoq8XjwDyQVYhNifXU0IPD9iLA7nocMBK179i2t8y2V qtFwM/sZTkpSLhX0XFzyRVqZnBQij+zt/Ld/oDNb0i74Q64YMelKicFwkq5nz/a6hdCp 61qpZe905bId7VHhEBM4eKJ6SpoPVdzO2bzRSQFLCFk//mhikT6I4XMU3tAylPKJMtQk tHIopkR7TfF3zNbEV8NMVTRZfrmXXnp358R9h7B+p9SfiqYJZwWR6sPJsdtGhEH8glTw 7W7g== X-Gm-Message-State: AOJu0Yy9MI8bDufywam1pxJuXsmCmm5BRzFhnlQjKlP4M8O5aRpTZMfp CvJnxrgl9vZ0BE4YH3jHAQCmfipB4B5/rOdeVKYyo6LmVni0+2ZrxGwUs3on7GFLMldn4edkQ29 RsnCE6O0jne7Wgrh0aseSAMty5S8pW23ckNcss0dOluIKDdAl3MueeRPn/UnvrYvvr8MBryDFtB D2swdCqcphIdlwopKCaypSwqkbqfjKr7gS X-Received: by 2002:a05:622a:1b8e:b0:447:e636:9ea9 with SMTP id d75a77b69052e-4531251c724mr14423361cf.3.1723219764323; Fri, 09 Aug 2024 09:09:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHps50LqsfKl8qXevdYdePG8tewmjaKqGlRovYXRf84yciplQ1RIErbjQjT+BAlToj6EpXuWQ== X-Received: by 2002:a05:622a:1b8e:b0:447:e636:9ea9 with SMTP id d75a77b69052e-4531251c724mr14422831cf.3.1723219763777; Fri, 09 Aug 2024 09:09:23 -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-451c870016csm22526741cf.19.2024.08.09.09.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:09:22 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, peterx@redhat.com, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , David Hildenbrand , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao , Matthew Wilcox , Ryan Roberts Subject: [PATCH 04/19] mm: Allow THP orders for PFNMAPs Date: Fri, 9 Aug 2024 12:08:54 -0400 Message-ID: <20240809160909.1023470-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240809160909.1023470-1-peterx@redhat.com> References: <20240809160909.1023470-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspam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F8iuET 9vcaMiK/dWAwlMb+D8C3q5Pe7f7BmkeeUF2U8svA7QSBnslGiYoAt4Pc3jRFEXmcJLLxnoObCGUynd51rqNHpbhcWvOmRTTyw2EF0mSafNXJMoNkXnrFJFyzMRcOENff+FBRpQnQz2ifppQ7gMbiWHc+UDqyQmAG0swqg61NnumlU2GRlsFE4xpa211aB0qCnmt3v2CAvLkmQTtfifMsweay+fhp0dxHdwmUiUcQsYyXtxL/qlHVjadpEzJN6qPe8ai+4LuLmcOQne9PPc6xcrHCuEcAER0myR5yqq6X9eSMJ3JN2pMupjg448EOq0QLYi8LuojmJQ9JOH4B69Thz+JwQ8c2wsZNyS0LtQYXM+Emwe7PeNT4doCtOgROjTmjjMREShRiet+ho4vkH07julPH/PqlvvxJKvjqGd5f3IqmMwcelZ47gsVT64RI7WjNGI0aoFvOAxc/MGJrq0P5uVnPoLtxqFpfzzAT2egSnXnZ5IEGVz0eCoG4ZNjK0QkAwhTgtVEkzW6NlBr2Qds5Aww1bTfI8rR6MJe3hwn8QjaJAGj/wtzM8k6LzAGv+sCwTcF0I 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: This enables PFNMAPs to be mapped at either pmd/pud layers. Generalize the dax case into vma_is_special_huge() so as to cover both. Meanwhile, rename the macro to THP_ORDERS_ALL_SPECIAL. Cc: Matthew Wilcox Cc: Gavin Shan Cc: Ryan Roberts Cc: David Hildenbrand Cc: Zi Yan Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- include/linux/huge_mm.h | 6 +++--- mm/huge_memory.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 2121060232ce..984cbc960d8b 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -76,9 +76,9 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr; /* * Mask of all large folio orders supported for file THP. Folios in a DAX * file is never split and the MAX_PAGECACHE_ORDER limit does not apply to - * it. + * it. Same to PFNMAPs where there's neither page* nor pagecache. */ -#define THP_ORDERS_ALL_FILE_DAX \ +#define THP_ORDERS_ALL_SPECIAL \ (BIT(PMD_ORDER) | BIT(PUD_ORDER)) #define THP_ORDERS_ALL_FILE_DEFAULT \ ((BIT(MAX_PAGECACHE_ORDER + 1) - 1) & ~BIT(0)) @@ -87,7 +87,7 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr; * Mask of all large folio orders supported for THP. */ #define THP_ORDERS_ALL \ - (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DAX | THP_ORDERS_ALL_FILE_DEFAULT) + (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_SPECIAL | THP_ORDERS_ALL_FILE_DEFAULT) #define TVA_SMAPS (1 << 0) /* Will be used for procfs */ #define TVA_IN_PF (1 << 1) /* Page fault handler */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e95b3a468aee..6568586b21ab 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -95,8 +95,8 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, /* Check the intersection of requested and supported orders. */ if (vma_is_anonymous(vma)) supported_orders = THP_ORDERS_ALL_ANON; - else if (vma_is_dax(vma)) - supported_orders = THP_ORDERS_ALL_FILE_DAX; + else if (vma_is_special_huge(vma)) + supported_orders = THP_ORDERS_ALL_SPECIAL; else supported_orders = THP_ORDERS_ALL_FILE_DEFAULT;