From patchwork Tue Oct 15 01:33:32 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: 13835655 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 D9CD0CFC501 for ; Tue, 15 Oct 2024 01:34:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72B4D6B00A1; Mon, 14 Oct 2024 21:34:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9406B00A2; Mon, 14 Oct 2024 21:34:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50CAC6B00A3; Mon, 14 Oct 2024 21:34:34 -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 E86C16B00A1 for ; Mon, 14 Oct 2024 21:34:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 86BA01605A5 for ; Tue, 15 Oct 2024 01:34:24 +0000 (UTC) X-FDA: 82674116616.26.95A4B28 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 3F771C0002 for ; Tue, 15 Oct 2024 01:34:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="bfwl/WMk"; 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=1728955929; 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=jpwPGGqxMjTTALmPRltkI2obnVC0TIxSM0BTVcrrVEU=; b=v7lbgF6koiNwgRN3OlimeV3uax0LUpoUwQ0QoX+jmP5zROOZk9t9KpZLJlmJ4QufKAuTYE Bj0YXBIwMxpAMHx2eSKcFeEz/Y/t37BLXtQVjUUj7PKLsWQb9HOYWI0FHGV2kOxLcL42mu OzOVVFw6OtYmnsahHnBpJIciTduOydw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728955929; a=rsa-sha256; cv=none; b=wIgtVq5ztZdDWw24UJmb89FwJBj/g2GlxvFcWslxNZLZ7bDpbosQgs0CVskn9Q6YdjSk0E 2nwuBakVZI63W2n7DD6QYMD69H7HzzMVeQh8dAtEf0JkhQI/NkJmJ1leUD3KbKcD5iHcJB NMMEXoZ5YOtdEr+nQSqCYeXzqN1MdxQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="bfwl/WMk"; 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 Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7cd8803fe0aso3293467a12.0 for ; Mon, 14 Oct 2024 18:34:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728956071; x=1729560871; 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=jpwPGGqxMjTTALmPRltkI2obnVC0TIxSM0BTVcrrVEU=; b=bfwl/WMkqQAy8OXyK9wb9hmlo1OawSepebQivNpvJkr3/NphyHAacZBHQVUCRov/7s LqMG1PMWZ2oiazH1BK+7G+Sf5fKgAPeoj0Tf93bHtmiPWIHcZsw7LBC90qTeIcvxFXNw SApKGKn4mi7P4eIYURoZOHv572rx6M5ePWPHpxwtMPNKGdcdoo+fmEBdx0LPtJLf486u iMGWlULqtf79wG4bf9J9xYzT5gbl+X1YKYM+uRIRgi5h7mHDF2OVSn88NpXGV4h9UL/z EaOgUUV2pdzSfEA8RVUp0TnktH2mDd/x0jFrM0pXSWuoIcFgUr6pZxg7O5vfoLdHXLd2 nE7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728956071; x=1729560871; 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=jpwPGGqxMjTTALmPRltkI2obnVC0TIxSM0BTVcrrVEU=; b=wowfps264Vp6rfV+jOBJekSyw514rZxb4inSlb/FRNwBLYJSiyJ7MTdzjcCkaQlitO LsFqmrokxX2cUaoyDsXDYB92L9t3UZc4Qt5p1FzmNaHJNNiEEPoFz1So5fwC2UoEAIHS k1G082zIvcqK90YOsJ7TcjSS5oflgdNNOMUMRxnzn3e/bVEUS+MGNUqp7Pte8XUmYT6g Cf5C8bIxTzEcWBGN7oaFSfslrA2hI06/k6IXPOIqbWP2lg/2p7OjbGnd3rnsJyyU0SWm nUPwqp9o9bW9SRWygTuwOjG/8Rpo+VUB8DGWse1Wnvtpppktlksbed7Jewd32lyJI0VE SqJg== X-Forwarded-Encrypted: i=1; AJvYcCXzBv2nch9yTBX2bge/x7oz+qKinD6TMG8ruA1APG1eqU8RTtdFyFa0c+fnRoXPYmfi0aElNyDJpA==@kvack.org X-Gm-Message-State: AOJu0YxRyabPuw0xxmtXuHOWnoVms7O4VPAeW9zEC/8nKNfF/xGXE9ZC Py4UHz7YgpP60HMBJICc4OtuNcA1pFGBnxFdi/w8ndpAl13Nrlv4 X-Google-Smtp-Source: AGHT+IHYwbiuRk5aKKEVmS1LD0xBTPgGenAkQ5XvzCOzwV/g1bm0dITYhUx7OfVFtgaRIRCqBx30PA== X-Received: by 2002:a05:6a20:c997:b0:1d8:adea:3f7c with SMTP id adf61e73a8af0-1d8bcf18038mr20979021637.14.1728956070636; Mon, 14 Oct 2024 18:34:30 -0700 (PDT) Received: from dw-tp.. ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e77508562sm189349b3a.186.2024.10.14.18.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 18:34:30 -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: [RFC RESEND v2 09/13] book3s64/hash: Disable debug_pagealloc if it requires more memory Date: Tue, 15 Oct 2024 07:03:32 +0530 Message-ID: <79552bdb6dac0d0a39d9c639bdf92f4e66dcaa55.1728954719.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3F771C0002 X-Stat-Signature: 4maqekgq7p3m54zd48mqng9gfc6mjes6 X-HE-Tag: 1728956065-236968 X-HE-Meta: U2FsdGVkX1/GJGmX+idh4N/5QGbW6huZgfud00fs8pHUuxaQtL2GCjaVacL64UxkVfneSztQKDKsI+p8Ickmn1Fm3bJk5ScOCPNcxkFA9zLS8a2gsp0Bl0A0vhR5N917V+l4bV9OrNTrthiXd6fQTypwes6dVI+aOVZJKvhtEcYEozvcoltrqtKiRSCVYj9aTb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blAO0kBqfjidG9izT7/CNA2/roGdGEOt7KxAB7VAAYmn36XnfEIl7du/LhrLw== 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 cc2eaa97982c..cffbb6499ac4 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);