From patchwork Fri Sep 6 13:09:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiwang Fu X-Patchwork-Id: 13794165 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 A36D8CE7B09 for ; Fri, 6 Sep 2024 13:09:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07ED96B007B; Fri, 6 Sep 2024 09:09:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 007FE6B0082; Fri, 6 Sep 2024 09:09:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC3E96B0085; Fri, 6 Sep 2024 09:09:38 -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 B51116B007B for ; Fri, 6 Sep 2024 09:09:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 38A84A7BAB for ; Fri, 6 Sep 2024 13:09:38 +0000 (UTC) X-FDA: 82534345236.22.7DD2665 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf29.hostedemail.com (Postfix) with ESMTP id 85F9B120028 for ; Fri, 6 Sep 2024 13:09:35 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KirClQq7; spf=pass (imf29.hostedemail.com: domain of fuhaiwang@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=fuhaiwang@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725628126; a=rsa-sha256; cv=none; b=TpMhpJDTSAKJ7zkNCTViYg4AasDWTZ5Mv5ucD4F5hbWVPri3ZiUz4Sb0L0SDtA7gQsJEgR eWSa+7K0qgSRv8RUYsgrFhK+jhyHsi+Posu+lmpvaSoROlCxlAFVsrvXNOurwdpoGbCJMX rZ+1K6Z/FEskvShINuopramyXe2R8HE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KirClQq7; spf=pass (imf29.hostedemail.com: domain of fuhaiwang@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=fuhaiwang@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725628126; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=fJajFCqDzvxotVKyqfFZXW5cvxptzp+3OPXG+GlIUGs=; b=5yRKuG2egdXlv9vIuBJnX7PW7gdmhPJ9EK39Ak+hVnE1vQ/JIJcYga7KyGZlbrsSsrMoGo 87CDVdeRTYBQGmaVW27TyK8Z2T8C+sDJbQxFuDHGoFwFDNmzHS9T0bVdhizBrE5a35eKW8 9jtkQoOLClV/fy+zA1ZwW206BUDWjWs= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20551eeba95so19983955ad.2 for ; Fri, 06 Sep 2024 06:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1725628174; x=1726232974; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fJajFCqDzvxotVKyqfFZXW5cvxptzp+3OPXG+GlIUGs=; b=KirClQq7C23CF/OfaALyUstFag4jJ+oiNlGDCKkNCIt1ZAVNswRTIOjvI8ZKIoymb3 k/jknqWhtFmiSW1SwnMZoRJSZnfQ5w2TxzbCaTehsN/zkEMHNfB9arRL9H84uCVzpAle ZyLP/ugzTbsAh/ILcnJvuHpRpVqwYu60r+ifE8u1jc15qCmvcXgd7aRqqddS9OajDm/A 50FlDmTDOmOjGax3CuotRPquwUYCq+a+8zkycrCRFYhyCb2JYQVqNAq1Co/YvF3QSZuk FaUVt5sYof8Fiz+j4T05WvL4ZDm8TO8VvMSLX8QLht0Hl+qjOtWYlFlwyU7q0wNW9EYs CHxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725628174; x=1726232974; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fJajFCqDzvxotVKyqfFZXW5cvxptzp+3OPXG+GlIUGs=; b=NZhOKGMt6RnOW8+UdcVX5myjGLMNyj87aj5lAZrXeme6fa/xOjBdy32+tFXVXyDc/y zmTpVZCq3KCG/MO0BwT1T/R4+tDdc1f2SR5RAJuM7X8RO5ZSCik/ZKa/I+GaYx1XurPX tP2UB9mr9v+tKvwwvpukGMdhEUO4m+4Ui+OGw2gue2QuCtZas+Qt1kik9nhQUloNzr9y 9h5qwR2biIiktFzP5mMB5QBfrKzOpryNXpXMsY9DrL+nPoWol9jx9hosdqp8noyee7me aKLyRhykfpB5kGBlyCqBRed7VZUmbLY47wN2qRiqfCG2aW/XeA0p5kDhur8ZteiegXVf jciQ== X-Forwarded-Encrypted: i=1; AJvYcCUxYDoYNZCEwi68xuPDHfuh+i6xWhEhfZhP+d+hQbHtZjmkL8rf2NgXt+glHDHwLR4oUQqw4amMig==@kvack.org X-Gm-Message-State: AOJu0YygRTVpzcDHAfvPN6VAwo939RYxid4TxEpUnCiT1wj0mhkxAZF8 m0TwIypuA4H9LggqW5Jtvz5QkpT9EjMMzPZi5OHfkkfpTO/Z2QWRXLaAKkZrlPQ= X-Google-Smtp-Source: AGHT+IEqMvxJYGTr1MplRvnRtTL+3ix6m4N5T1NPlcfCFEpIUvtMlO7Aptwd/qLAnbDIWmwh7qDiXw== X-Received: by 2002:a17:902:e84a:b0:202:47a4:7a1e with SMTP id d9443c01a7336-206f04e1e09mr24038145ad.16.1725628173870; Fri, 06 Sep 2024 06:09:33 -0700 (PDT) Received: from CWMV1S3.bytedance.net ([203.208.167.151]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea55b05sm42764465ad.202.2024.09.06.06.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 06:09:33 -0700 (PDT) From: Haiwang Fu To: akpm@linux-foundation.org, ryan.roberts@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, fuhaiwang@bytedance.com Subject: [PATCH] mm/vmalloc:arm64 support cont-pte huge vmalloc mapping Date: Fri, 6 Sep 2024 21:09:19 +0800 Message-Id: <20240906130919.3765401-1-fuhaiwang@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Stat-Signature: qcmbpk1jmsj6quscr1i587uifg9ayp67 X-Rspamd-Queue-Id: 85F9B120028 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725628175-907212 X-HE-Meta: U2FsdGVkX1/gJeK167vSEPcWuepVl05UdoHl4T1KVNVOQPCHeE407DdbGMU2P51dVaYs0fL/1nDctY7aMlNxC3JHOC0kTV+sTLQkgp4GQA0MLIYDSYgE1kyYdcUhy56x9IEOiaFt1lBkwJgzZNdcAKxbq+Q1fUcFACtNVAb86qyYl5EsshoQWDhqxMVCZse+iPdM8YdKOkVo4rWvQ4GJAFX2TuK5XMqFeVY2RClE90euX8e35rgxTmIg0/Nb6Nr51RIvTAISvSywVtyEXbEnTrftIFz8q+RRtdFsjUy+VIyJojelYSMtuVtRsHym18xFDXrQ5D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op: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: fuhaiwang Arm64 support contiguous bit which is used to increase the mapping size at the pmd and pte level. Now huge vmalloc support PMD and PTE level mapping, and support multi size at pte level. arm64: implement the fllowing interface on arm64 to support cont-pte huge vmalloc mapping. arch_vmap_pte_supported_shift(*) arch_vmap_pte_range_map_size(*) Signed-off-by: fuhaiwang --- arch/arm64/include/asm/pgtable.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index c329ea061dc9..3f32e3150680 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1814,6 +1814,34 @@ static inline void clear_young_dirty_ptes(struct vm_area_struct *vma, #endif /* CONFIG_ARM64_CONTPTE */ +static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, + u64 pfn, unsigned int max_page_shift) +{ + if (end - addr < CONT_PTE_SIZE) + return PAGE_SIZE; + + if ((1UL << max_page_shift) < CONT_PTE_SIZE) + return PAGE_SIZE; + + if (!IS_ALIGNED(addr, CONT_PTE_SIZE)) + return PAGE_SIZE; + + if (!IS_ALIGNED(PFN_PHYS(pfn), CONT_PTE_SIZE)) + return PAGE_SIZE; + + return CONT_PTE_SIZE; +} +#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size + +static inline int arch_vmap_pte_supported_shift(unsigned long size) +{ + if (size >= CONT_PTE_SIZE) + return CONT_PTE_SHIFT; + else + return PAGE_SHIFT; +} +#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */