From patchwork Fri Oct 18 17:29:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13842090 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 AB584D3DEA2 for ; Fri, 18 Oct 2024 17:31:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 303496B00A3; Fri, 18 Oct 2024 13:31:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B3AE6B00A4; Fri, 18 Oct 2024 13:31:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 155316B00A5; Fri, 18 Oct 2024 13:31:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E9E166B00A3 for ; Fri, 18 Oct 2024 13:31:04 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6FA32ACF74 for ; Fri, 18 Oct 2024 17:30:40 +0000 (UTC) X-FDA: 82687413354.24.66B65FA Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf28.hostedemail.com (Postfix) with ESMTP id A408BC0024 for ; Fri, 18 Oct 2024 17:30:51 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BZlOn9SZ; spf=pass (imf28.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729272614; 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:in-reply-to:references:references:dkim-signature; bh=c7nu+U6UkRZF2cuN8FLbB8nvBf84Wg4YjQThyWhRKHk=; b=IIlN6jtwgvHypr7pSK1l46xvZyIRYseXSJR23Dglx54BMAR7F0Ir3Hw6DZ5a+b/V3T8PNk WSAHWJtf5JA47zSmYq6ii//+Sby8WcIzcTWGftPFCRyJcvKdnjQVuIzTh+1uqyNPnb1BwA PobyjVBb886OTO3/1AXVhkHJEPjp9mA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BZlOn9SZ; spf=pass (imf28.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729272614; a=rsa-sha256; cv=none; b=IvuNcUKIVDEAHe/Ve6Sv35hpoAH2sngEp0pDKeWu4GhpbdBF2Fw/h8vl/5JtZFevEt4wwd PORTfn3RO29dJX6JnXDxjIED5noD48QMEp/MGAovauyaRjG7rU/7+n2cW537syINp0jZVh 9jZJ+miLFcQD/sKmwSt5MKlJXY7TTqs= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ea8d7341e6so1813820a12.3 for ; Fri, 18 Oct 2024 10:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729272661; x=1729877461; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c7nu+U6UkRZF2cuN8FLbB8nvBf84Wg4YjQThyWhRKHk=; b=BZlOn9SZBGi4w/e9VDhesjlLF6942fhyCI0+w+DUDkJNZRMDksaY6t3ax9VO0AkD4o BC/Dk7QYgDzYWciyXwuW2WEpACdw6+viTXG5gzKikcrA5mG2LIHODjxbyl0eItZMLmYn 9cBa5mRWWbJOZVT2a+hZo1+Jjl8kFDPDNmPno1iMM3IgR9ZZA5+Z6FpflKpQq5/4lpee x0gnUD9ffnVic+iJ5t3VwQ/2fEioBMXOkkXnnlASe1Xs1sgN46CpumPj1W4WkY6C00O3 03kTWM3kbYuv1nKvsTc89iK0IpWYwENHrsBCISaXZ/nwQ5f+90yxJgBGDEK0Bcf0lVuX glOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729272661; x=1729877461; 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=c7nu+U6UkRZF2cuN8FLbB8nvBf84Wg4YjQThyWhRKHk=; b=UxP11LuAztI7CJyfktZ4fea81OZdv7R0VUaFAN8Abbhpy60BzfnKOBnHb2mtmHziDO NUWJSKJHM/6kUrEFU8Xetq2zRWZyb0rM2Bz/p9VK99qh/V1vjPrtZsKsv4lTUgbiYULp SIcpoMPb25JM9h/QEHeDctC3hRjtALyGM9E1eMy6GWN2pE06FTbFY6FC5Ny9wKgZApG/ YqKYTzulD4RvKzcIYlIMeWH2SiJmyOTu4YCXSKSBM8caoAGrpdS5MfqRvfYFZx9/Kpl6 V9YD+zXqWqSoIa/Bf+dI5Gsd+a7aYqlXap/omi1fRXNzinmEd+Ug0GW482KrnVIJZe6w /6Ng== X-Forwarded-Encrypted: i=1; AJvYcCVF4Avq0jQ8pHnsjae078BX3UvRnzr8EdWK9pvPaGLdHcLORmv6qkV9bFaVmM+Yr5oVL6+LLPFBPA==@kvack.org X-Gm-Message-State: AOJu0YwxWGtD1o/htmZ25pb6uDyxZ6J4LIHfn0x9XqXwVBn2WWFBOiUA Jat12Sq6Sf1gbh0YB7GHXC9yHlLTcpLUzqq3IPBC04qsM0kYrCETdPqhz6S9 X-Google-Smtp-Source: AGHT+IHJYrrrqJRfAumO9Q20FqjOKsTO5quh/OtUWisgh37hgw56Q3PPkpt1yyNYXV1te9hYA/UiKQ== X-Received: by 2002:a05:6a21:1519:b0:1d8:a3ab:7228 with SMTP id adf61e73a8af0-1d92c3323d2mr4881461637.0.1729272661553; Fri, 18 Oct 2024 10:31:01 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea3311f51sm1725242b3a.36.2024.10.18.10.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 10:31:00 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, Marco Elver , Alexander Potapenko , Heiko Carstens , Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan , Christophe Leroy , Hari Bathini , "Aneesh Kumar K . V" , Donet Tom , Pavithra Prakash , LKML , "Ritesh Harjani (IBM)" Subject: [PATCH v3 08/12] book3s64/hash: Disable debug_pagealloc if it requires more memory Date: Fri, 18 Oct 2024 22:59:49 +0530 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hz8onkiyt7f4zdb9gsiipxp4exmgjz5s X-Rspamd-Queue-Id: A408BC0024 X-Rspamd-Server: rspam11 X-HE-Tag: 1729272651-193370 X-HE-Meta: U2FsdGVkX1/wphpc3f3axMFfGn+S+ELKgnt6OJSnPQNQJRPkRlOKAd/XZ08ldXitNKg+2r01F2Gx/t7PEtUFtZEwod4vSKP9y0TDDspyqWT7xHrumifRCsbgm1VkrpqBxXgGytcp2TLCOS9JDWLNBwh9/63cNar/RhY2b0YMybzMN82UYNkrj5vc36K5PTjzG24p3h/lT99uHLvpI8Tm3pFZXaZkMdRcqX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ZBKon1JbHo7Zh5SGFJQGaiyLkK349PUL2/fPlCBQ== 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: Make size of the linear map to be allocated in RMA region to be of ppc64_rma_size / 4. If debug_pagealloc requires more memory than that then do not allocate any memory and disable debug_pagealloc. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/mm/book3s64/hash_utils.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 11975a2f7403..f51f2cd9bf22 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -331,9 +331,19 @@ static unsigned long linear_map_hash_count; static DEFINE_RAW_SPINLOCK(linear_map_hash_lock); static inline void hash_debug_pagealloc_alloc_slots(void) { + unsigned long max_hash_count = ppc64_rma_size / 4; + if (!debug_pagealloc_enabled()) return; linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT; + if (unlikely(linear_map_hash_count > max_hash_count)) { + pr_info("linear map size (%llu) greater than 4 times RMA region (%llu). Disabling debug_pagealloc\n", + ((u64)linear_map_hash_count << PAGE_SHIFT), + ppc64_rma_size); + linear_map_hash_count = 0; + return; + } + linear_map_hash_slots = memblock_alloc_try_nid( linear_map_hash_count, 1, MEMBLOCK_LOW_LIMIT, ppc64_rma_size, NUMA_NO_NODE); @@ -344,7 +354,7 @@ static inline void hash_debug_pagealloc_alloc_slots(void) static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot) { - if (!debug_pagealloc_enabled()) + if (!debug_pagealloc_enabled() || !linear_map_hash_count) return; if ((paddr >> PAGE_SHIFT) < linear_map_hash_count) linear_map_hash_slots[paddr >> PAGE_SHIFT] = slot | 0x80; @@ -356,6 +366,9 @@ static int hash_debug_pagealloc_map_pages(struct page *page, int numpages, unsigned long flags, vaddr, lmi; int i; + if (!debug_pagealloc_enabled() || !linear_map_hash_count) + return 0; + local_irq_save(flags); for (i = 0; i < numpages; i++, page++) { vaddr = (unsigned long)page_address(page);