From patchwork Wed Jul 31 07:56:11 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: 1966923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WJscwdTW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WYl106btJz1yfG for ; Wed, 31 Jul 2024 18:01:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WJscwdTW; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WYl104x9Kz3dRP for ; Wed, 31 Jul 2024 18:01:40 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WJscwdTW; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::433; helo=mail-pf1-x433.google.com; envelope-from=ritesh.list@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WYkwW37F1z3d2S for ; Wed, 31 Jul 2024 17:57:47 +1000 (AEST) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70d2b921cdfso4772672b3a.0 for ; Wed, 31 Jul 2024 00:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722412665; x=1723017465; darn=lists.ozlabs.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=UbALxTqSqlEVKnoz62IgytvWvcETkWPldZLYnVFh9W4=; b=WJscwdTWHcTNW9NVoq386sdgb2rW5o4UgXusccq6CdmOO1Pn53DuWhGZDMkoButWy2 cgTbj6+lh7KYuK4J5onQe7hGuYlIvByHVoQJbv7Td4QMxJVCkr0O0jUlYLZyJiHPLshc c2y2sP7h0WC4q+AsRyy1Z3JC/p9t4N4Xd30PC/RE57FvrXCTepyVWf+2I9d2ih8kdTpZ X7k0U3zct0BOrk/u+3V4xkfXmhpXOzh6vsyo6aPt0tVUM4Q/HOCbfNYFvpOaKhJeMHTB 8Kz8AlbRuX3s9tPXwTfhRkrANnWQVPagisd1i8GDQLmUIZBJpkzNb3wjUSNN4NH5Au3w Y3Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722412665; x=1723017465; 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=UbALxTqSqlEVKnoz62IgytvWvcETkWPldZLYnVFh9W4=; b=lpu9AzYKeDUe6oBrOZuF4jHVOtd+iO/dGVKizOSbFiv75RylAL7479kDHCg549X9Ai adtccykt0SHHAoN/KkK1c0vz7mWJ2H+iLcYKa2T+OZotrJvybKAYcNnya34B6PaRkbaA BLy/LZUGLQOxgNj4rWPkCzIByIucs8ef4hFZmez/Ot2FrjbIPFC6AfPmgGWWs9NfElQj NHhBM/Eej9kYEnIUKCnzzfukNMza2b1WKXFQ/LYzHhNqXcrKAuzwul7ocnkb4IO3eVgY McZaEl9gsW6tUo1tVxPUy8yiC0G179ZGpFyKD/wIKDLV5aKsgNmLIDms+soKHavHmCJl ALEA== X-Gm-Message-State: AOJu0YxLoHOl9QvBr+E7VVWhNqZHMSTDh3dhE+h45SjLXWlKVrSFscIl iX7LtkI2P81LwReKwkFIwXG/YvIJGELDFNyio6FjCygi1IxwlzihpsIJHA== X-Google-Smtp-Source: AGHT+IEzxyRVOeCaCY954crrhmdRysIFEVHaRyW4RQuGke8M+TLewXN4ywzl7YIlQvNN50l5nIQxvA== X-Received: by 2002:a05:6a00:138e:b0:705:6a0a:de14 with SMTP id d2e1a72fcca58-70ece9ebba7mr16338761b3a.1.1722412664651; Wed, 31 Jul 2024 00:57:44 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.83.154]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead6e16fbsm9788372b3a.19.2024.07.31.00.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 00:57:44 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev Subject: [RFC v1 07/10] book3s64/hash: Disable debug_pagealloc if it requires more memory Date: Wed, 31 Jul 2024 13:26:11 +0530 Message-ID: <771cddcc8298575d27cde85e0dc6b85755f9dd9e.1722408881.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Donet Tom , Madhavan Srinivasan , "Ritesh Harjani \(IBM\)" , Christophe Leroy , Pavithra Prakash , "Aneesh Kumar K . V" , Nicholas Piggin , Hari Bathini Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 3f3eaf0a254b..906cd167180a 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) >> PAGE_SHIFT; + 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);