Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp30089lqc; Thu, 29 Feb 2024 09:27:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVStOlAbLSsNhHUEt3vehSvl50db0MPsKNEhnaL6EPxdg+uBpx7XuCX6pcEXLizX+p6lzClW1ycJWwBKoHPGbXdYJYi2ZxwFrREYCETEQ== X-Google-Smtp-Source: AGHT+IFrfW3uNB134TTBxCeiRLR39P+l1SV9SPNKi44AQnyZPP+RopTFNmAWWtpAetjWZkfhbxu7 X-Received: by 2002:a05:6402:4494:b0:565:8339:5753 with SMTP id er20-20020a056402449400b0056583395753mr1986508edb.40.1709227626017; Thu, 29 Feb 2024 09:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709227626; cv=pass; d=google.com; s=arc-20160816; b=cQEtWRl0GFcUlMyXbDMRSf+rczH0TsHf7+04pFKufFtTVITiszUumKRt4iXhsVihC7 Fg0NwwWHGqn2coXiAEz6iiSZaT6/M/m0LWLY+Z0NE1HrH6p2G7j30SHM/vaouWVm8BJy es3hk738+9KDKIpD0wBK+Ga15pdDSOyOyshY6DjMsrYKvT5y7lpVi6A6HjvLFlwi/cAS 33/oEzH1fLzDqxdliEQBikyqFd4xJpc3NxZB7GLr8ECJ5o9jmoAhweT51WgJIxL4NAe2 NJBdW2ustoqQHqqC8wlIGkqXi5y9crwDoucBtOIcKBYxJcZdhVUJynB6R/KBmBRCVvad 9OMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4qqu5sgF80AYjbWmsdAscREgugMIXQd1osZQ9WOEYdg=; fh=ESQHWEeMOuEkCRdGxCy8//2r8If2caE33uQjc5uxZQ8=; b=PmlcZRfi5xp0CQophuE52TA89a+CeI9i1h0++xXh7C1xx3PvLLPqL7dlO6YgPoLWUP 6rnu+8smVVeM8FE5Dp0bPRiG5xBQ5X+fbd42f4559U9IXVgGbTtBGedpBE47Zgr4SgiK kIhYpdy6e+XUVIPAPBKnl6rNbw0Px8d/9ZgpbMvlqF4HHLwmJgjVkAEM+mtjbNZ8nzad ktpxu2c/z9LVUmYiEHaEYKCKfZtc+3sXwStz0oQuSB8Ky3G/fPW2ZRbbnge8QSTWHgxO GzjvmocDYQARyAdrZZEqV9JSjKWTPVTh1bBPNDSKQznBLJ91VpVGQxAODvYQzwo5cmGq Wc2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iE/bZrx8"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87168-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k17-20020a056402341100b00564c8800f5esi744506edc.354.2024.02.29.09.27.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iE/bZrx8"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87168-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id BB28C1F24C19 for ; Thu, 29 Feb 2024 17:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A0F670AD0; Thu, 29 Feb 2024 17:27:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iE/bZrx8" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 A53785E082; Thu, 29 Feb 2024 17:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709227620; cv=none; b=potryGPIIHOjjs50krfXwEoN/rMKE0C/+rbdZV1Hj30NapaTHfTPRR8wy+YGnHKlkLn4dSorPGMMLtor1wevqQoD/zYtFxpvgCV1sIY5LkacCJawPJZgJ5Jx6wx7ZNqh4tH/LpeE2RlzLf7GHnokc7ARItkdx/AShKttRrC6Pzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709227620; c=relaxed/simple; bh=/JaDBH1RUWq1bA062JryjFL4ALd2l03adAlP7w/617s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O1pZYdJUPWS6iMnuJCzTUmli+Slig/2VjLrZaUYomY8k7uUNKF+mZJzFKARedL08XtuUh5p/mBP9rvjjc7uPVHgXD7s3zvQ35NEdKHiVv6D955ZO/R78O8xyQMRSWhpSCuL/uOOIzoidTKZPsC8iv6N0U8uUzPHBNWTOBtiGVuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iE/bZrx8; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709227619; x=1740763619; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/JaDBH1RUWq1bA062JryjFL4ALd2l03adAlP7w/617s=; b=iE/bZrx8WtZ7QF16L0fruAOK8FXRB00cK6Ryx/O7dTVlgV7vwOjpBjSU COZOM7go0WX9RYk7Ch7A7EFrzSmKYjs/a75eFK5FavfiSjG5UmJ79EyVY D+AZm4ta8c5ks5KYsgd5PXvXcoWQaBcqWLwG2VnpIDYnEvLO1Oc61ehad YA7uPFnf4U6rYT7QfTY3/3jd+JhszQ6yoV9dH5qNAy0CAhU5se+BxNAqM 60WDqkbACjVIGdqApgO8xMiijaZ3JxDcz50w3NvxyQB/o/MEg0Usl+HrS M+pExvvYPpLAZm/FckLWdtFq9MrcTzKf4ZuoN6Y/6+KI1i25gmt6hbsEc w==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="3600313" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="3600313" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 09:26:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7820865" Received: from agluck-desk3.sc.intel.com (HELO agluck-desk3) ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 09:26:58 -0800 Date: Thu, 29 Feb 2024 09:26:56 -0800 From: Tony Luck To: "Naik, Avadhut" Cc: Borislav Petkov , "Mehta, Sohil" , "x86@kernel.org" , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "yazen.ghannam@amd.com" , Avadhut Naik Subject: Re: [PATCH] x86/mce: Dynamically size space for machine check records Message-ID: References: <20240212175408.GIZcpbQHVjEtwRKLS-@fat_crate.local> <20240212191401.GLZcpt-XHFqPg3cDw-@fat_crate.local> <20240212220833.GQZcqW4WxKH34i-oBR@fat_crate.local> <20240212221913.GRZcqZYRd6EPTTnN97@fat_crate.local> <20240212224220.GSZcqezMhPojxvIcvO@fat_crate.local> <8ee24cad-e9b8-4321-aad4-9a9ba4f8b7b6@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ee24cad-e9b8-4321-aad4-9a9ba4f8b7b6@amd.com> On Thu, Feb 29, 2024 at 12:42:38AM -0600, Naik, Avadhut wrote: > Hi, > > On 2/28/2024 17:14, Tony Luck wrote: > > 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 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). > > > > Signed-off-by: Tony Luck > > --- > > > > Discussion earlier concluded with the realization that it is > > safe to dynamically allocate the mce_evt_pool at boot time. > > So here's a patch to do that. Scaling algorithm here is a > > simple linear "4 records per possible CPU" with a minimum > > of 80 to match the legacy behavior. I'm open to other > > suggestions. > > > > Note that I threw in a "+1" to the return from ilog2() when > > calling gen_pool_create(). From reading code, and running > > some tests, it appears that the min_alloc_order argument > > needs to be large enough to allocate one of the mce_evt_llist > > structures. > > > > Some other gen_pool users in Linux may also need this "+1". > > > > Somewhat confused here. Weren't we also exploring ways to avoid > duplicate records from being added to the genpool? Has something > changed in that regard? I'm going to cover this in the reply to Boris. > > + mce_numrecords = max(80, num_possible_cpus() * 4); > > + mce_poolsz = mce_numrecords * (1 << order); > > + mce_pool = kmalloc(mce_poolsz, GFP_KERNEL); > > To err on the side of caution, wouldn't kzalloc() be a safer choice here? Seems like too much caution. When mce_gen_pool_add() allocates an entry from the pool it does: memcpy(&node->mce, mce, sizeof(*mce)); llist_add(&node->llnode, &mce_event_llist); between those two lines, every field in the struct mce_evt_llist is written (including any holes in the struct mce part of the structure). -Tony