Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3293970lqp; Tue, 26 Mar 2024 05:36:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBR1B8PSiatxhhN0EFdKa7kSSREPY+d/21cUJ/6Kjy0scYn0hKstPpBMsfVDThnP/E5mFtyp3YKlH5kpKafk2W3Sd1LdrdoFR4rfEbXA== X-Google-Smtp-Source: AGHT+IGiCCzGyhu16xgiYrtMW2srsW/vndood9BGpYSvbbcFILo0MX+l+nGhU3iHvszR7U7UKgMW X-Received: by 2002:a17:902:ec87:b0:1dc:adad:f54b with SMTP id x7-20020a170902ec8700b001dcadadf54bmr10898036plg.44.1711456572661; Tue, 26 Mar 2024 05:36:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711456572; cv=pass; d=google.com; s=arc-20160816; b=Me9ekCPQ2hsGTtAGL0E239IphYr/rStLMttfkm/8BLAJd0N56ymvSOo7KvVeAhJ6ZH 363fP7BgJTMzx4ggY1k7t+Vb93y44XuVE+JnMB53aamh32mSk6jc3C3aKdOhmp9vleuM tCbVdU+6sKmzSs+8Y22Zwv7r0jucGQ0Te/YhKrGMkL3BmLrbQPiY9W/AEHGkhY0lLSqT y6D7L6ktIKrJxR55V04pF2btKKH9Fzqe7E80VQeqVYmIPIL6WmuF6PO3JfUUszHUmgp1 x1AsjPNEnWlPgbQg9BtNoGzcCNY8D89oWKggLIhFnTWuasoMiZeCiV7dEB/NfPGTJX6i 3x0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=fxpZuljtjT2twvLmklrZ+zGqJLtDaFO5N7Hy49wYyRI=; fh=gcHeFn/LetuHXD7eUMvapdJkAeOef4BROUw120Y7ItY=; b=fHjwSbPcNICz2XCVK889/n3oMlgBakyekTOdqzk9SVkYGaKDtOEu2nMg1BPzQ8rJEj dpUmPpL5w4JsETzDxf/623frrK5b871C0Hno9vqBGifJk+96LDdeZTGIcUfLFxenwl+C NEFauinbzQBemoYPtQbcT7oAxINAda8HLE0qu6rrjfSEr2zSgIlV3Uuo5//tCPuZxQ/q U3bYHcuYhevJyGV7TWOyZNP4tYBJlhDrWnCTSgvcap2JMm7Qx+xN3hZ9fBdHWtAeIiyx inrHDVf3tvTHz/rzZel38ax9ofn5j14WQU4UyCPjsnvguAcrfLxYHjK10Dl6cDxhyMxb 1aQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CoxqXOzJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-118984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n15-20020a170903110f00b001def0abd873si1339783plh.198.2024.03.26.05.36.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CoxqXOzJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-118984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B4B16300B77 for ; Tue, 26 Mar 2024 12:36:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2D605BAFA; Tue, 26 Mar 2024 12:36:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CoxqXOzJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Jyge/063" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5B4E1CA9C; Tue, 26 Mar 2024 12:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711456567; cv=none; b=PVx/le/6F2PnZ6/qs9ZLLPQXZ/l4pYuBDJ/IXplgBBDtpaWQIZMjLg5v+snoYIB6N9rDk8IcDxs61y/muoYLdXyaKC1a20aVvAfYVylGAu0qvV6sB9S4iVb61X36aGeGTBHxiMnEMqhnYMJ9FzpanpBlqeL34ADcJLeDNzGCANQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711456567; c=relaxed/simple; bh=Ln00QjIocVOEh7cEbdyeopMQ1njFgOHqxxc5fU7j1UM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=cHX1GugWuaZ+BlcCIZJK6kpj4R7/1iz5uMR7OXjNPNL+PRqt1pRm09OGihT/zWBdMWGPeUXbPrE7bgzfkZXG+7PWdWmMMeGTK7a4Q5OIG/RyJEBKZSnJDnpB8CbHWQ4HJdW/RFpldhNTFk31SDRyDY/VXpftAyRcRnb8LUaWaLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CoxqXOzJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Jyge/063; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 26 Mar 2024 12:35:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711456557; h=from:from:sender:sender:reply-to: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=fxpZuljtjT2twvLmklrZ+zGqJLtDaFO5N7Hy49wYyRI=; b=CoxqXOzJCe9mOekcC4u2yqhPNBOmQJZXaiIdXPTKoOe11CSckMwOYVuK4pF1GWlBYfz7cP dKnlkKPyu4y/CaO4G9ZUbG/xZ3C9VV1Rk88IHYlKbasfkZrVdcnGvtshV95u9MWjjicRtQ x9dtN9JIXnyC1EO/E9Jpr+gsgbGOX+2FYaVYQWRCEq6V5aS5+eUKNv22+OJdWhUvUjcUDM cHitOKwx7ODE1wP9U5aGSdb42KQTDen2afjdLCuLDfsp1TNzk77YecY1Mrm5aWEVFJ/ZOZ NyYXRmlQFJikC85ZdHByq7d2rkGtkbvwNCzJwJyrDU8bC3vAQ6G2iAU5kzo5dw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711456557; h=from:from:sender:sender:reply-to: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=fxpZuljtjT2twvLmklrZ+zGqJLtDaFO5N7Hy49wYyRI=; b=Jyge/063PrHhIILGbSEtIomoxIu6vd2M4D0g1Mi7GHLnlohmPvw+cXIK4aHWf9AUj9ImVb 3eS+HyvRTAiWHxCg== From: "tip-bot2 for Tony Luck" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: ras/core] x86/mce: Dynamically size space for machine check records Cc: Tony Luck , "Borislav Petkov (AMD)" , Sohil Mehta , Avadhut Naik , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240307192704.37213-1-tony.luck@intel.com> References: <20240307192704.37213-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171145655619.10875.5517260204670721403.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the ras/core branch of tip: Commit-ID: 108c6494bdf1dfeaefc0a506e2f471aa92fafdd6 Gitweb: https://git.kernel.org/tip/108c6494bdf1dfeaefc0a506e2f471aa92fafdd6 Author: Tony Luck AuthorDate: Thu, 07 Mar 2024 11:27:04 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 26 Mar 2024 12:40:42 +01:00 x86/mce: Dynamically size space for machine check records Systems with a large number of CPUs may generate a large number of machine check records when things go seriously wrong. But Linux has a fixed-size buffer that can only capture a few dozen errors. Allocate space based on the number of CPUs (with a minimum value based on the historical fixed buffer that could store 80 records). [ bp: Rename local var from tmpp to something more telling: gpool. ] Signed-off-by: Tony Luck Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Sohil Mehta Reviewed-by: Avadhut Naik Link: https://lore.kernel.org/r/20240307192704.37213-1-tony.luck@intel.com --- arch/x86/kernel/cpu/mce/genpool.c | 40 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/genpool.c b/arch/x86/kernel/cpu/mce/genpool.c index fbe8b61..4284749 100644 --- a/arch/x86/kernel/cpu/mce/genpool.c +++ b/arch/x86/kernel/cpu/mce/genpool.c @@ -16,14 +16,14 @@ * used to save error information organized in a lock-less list. * * This memory pool is only to be used to save MCE records in MCE context. - * MCE events are rare, so a fixed size memory pool should be enough. Use - * 2 pages to save MCE events for now (~80 MCE records at most). + * MCE events are rare, so a fixed size memory pool should be enough. + * Allocate on a sliding scale based on number of CPUs. */ -#define MCE_POOLSZ (2 * PAGE_SIZE) +#define MCE_MIN_ENTRIES 80 +#define MCE_PER_CPU 2 static struct gen_pool *mce_evt_pool; static LLIST_HEAD(mce_event_llist); -static char gen_pool_buf[MCE_POOLSZ]; /* * Compare the record "t" with each of the records on list "l" to see if @@ -118,22 +118,32 @@ int mce_gen_pool_add(struct mce *mce) static int mce_gen_pool_create(void) { - struct gen_pool *tmpp; + int mce_numrecords, mce_poolsz, order; + struct gen_pool *gpool; int ret = -ENOMEM; - - tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1); - if (!tmpp) - goto out; - - ret = gen_pool_add(tmpp, (unsigned long)gen_pool_buf, MCE_POOLSZ, -1); + void *mce_pool; + + order = order_base_2(sizeof(struct mce_evt_llist)); + gpool = gen_pool_create(order, -1); + if (!gpool) + return ret; + + mce_numrecords = max(MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU); + mce_poolsz = mce_numrecords * (1 << order); + mce_pool = kmalloc(mce_poolsz, GFP_KERNEL); + if (!mce_pool) { + gen_pool_destroy(gpool); + return ret; + } + ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1); if (ret) { - gen_pool_destroy(tmpp); - goto out; + gen_pool_destroy(gpool); + kfree(mce_pool); + return ret; } - mce_evt_pool = tmpp; + mce_evt_pool = gpool; -out: return ret; }