From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
<rafael@kernel.org>, <bp@alien8.de>, <dan.j.williams@intel.com>,
<tony.luck@intel.com>, <dave@stgolabs.net>,
<alison.schofield@intel.com>, <ira.weiny@intel.com>
Subject: Re: [PATCH 4/4] cxl: Add mce notifier to emit aliased address for extended linear cache
Date: Tue, 24 Dec 2024 12:18:09 +0000 [thread overview]
Message-ID: <20241224121809.0000439c@huawei.com> (raw)
In-Reply-To: <20241204224827.2097263-5-dave.jiang@intel.com>
On Wed, 4 Dec 2024 15:46:49 -0700
Dave Jiang <dave.jiang@intel.com> wrote:
> Below is a setup with extended linear cache configuration with an example
> layout of memory region shown below presented as a single memory region
> consists of 256G memory where there's 128G of DRAM and 128G of CXL memory.
> The kernel sees a region of total 256G of system memory.
>
> 128G DRAM 128G CXL memory
> |-----------------------------------|-------------------------------------|
>
> Data resides in either DRAM or far memory (FM) with no replication. Hot
> data is swapped into DRAM by the hardware behind the scenes. When error is
> detected in one location, it is possible that error also resides in the
> aliased location. Therefore when a memory location that is flagged by MCE
> is part of the special region, the aliased memory location needs to be
> offlined as well.
>
> Add an mce notify callback to identify if the MCE address location is part
> of an extended linear cache region and handle accordingly.
>
> Added symbol export to set_mce_nospec() in x86 code in order to call
> set_mce_nospec() from the CXL MCE notify callback.
>
> Link: https://lore.kernel.org/linux-cxl/668333b17e4b2_5639294fd@dwillia2-xfh.jf.intel.com.notmuch/
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
A couple of minor editorial comments.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> diff --git a/drivers/cxl/core/mce.c b/drivers/cxl/core/mce.c
> new file mode 100644
> index 000000000000..f983822992a4
> --- /dev/null
> +++ b/drivers/cxl/core/mce.c
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright(c) 2024 Intel Corporation. All rights reserved. */
> +#include <linux/notifier.h>
> +#include <linux/set_memory.h>
> +#include <asm/mce.h>
> +#include <cxlmem.h>
> +#include "mce.h"
> +
> +static int cxl_handle_mce(struct notifier_block *nb, unsigned long val,
> + void *data)
> +{
> + struct cxl_memdev_state *mds = container_of(nb, struct cxl_memdev_state,
> + mce_notifier);
> + struct cxl_memdev *cxlmd = mds->cxlds.cxlmd;
> + struct cxl_port *endpoint = cxlmd->endpoint;
> + struct mce *mce = (struct mce *)data;
Explicit cast not needed or useful. C lets us not bother when casting
from void *
> + u64 spa, spa_alias;
> + unsigned long pfn;
> +
> + if (!mce || !mce_usable_address(mce))
> + return NOTIFY_DONE;
> +
> + spa = mce->addr & MCI_ADDR_PHYSADDR;
> +
> + pfn = spa >> PAGE_SHIFT;
> + if (!pfn_valid(pfn))
> + return NOTIFY_DONE;
> +
> + spa_alias = cxl_port_get_spa_cache_alias(endpoint, spa);
> + if (!spa_alias)
> + return NOTIFY_DONE;
> +
> + pfn = spa_alias >> PAGE_SHIFT;
> +
> + /*
> + * Take down the aliased memory page. The original memory page flagged
> + * by the MCE will be taken cared of by the standard MCE handler.
> + */
> + dev_emerg(mds->cxlds.dev, "Offlining aliased SPA address: %#llx\n",
> + spa_alias);
> + if (!memory_failure(pfn, 0))
> + set_mce_nospec(pfn);
> +
> + return NOTIFY_OK;
> +}
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 8bf4efb2c48c..b279148ec3ff 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3435,6 +3435,31 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled)
> }
> EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, CXL);
>
> +u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa)
> +{
> + struct cxl_region_ref *iter;
> + unsigned long index;
> +
> + guard(rwsem_write)(&cxl_region_rwsem);
> +
> + xa_for_each(&endpoint->regions, index, iter) {
> + struct cxl_region_params *p = &iter->region->params;
> +
> + if (p->res->start <= spa && spa <= p->res->end) {
> + if (!p->cache_size)
> + return 0;
> +
> + if (spa > p->res->start + p->cache_size)
> + return spa - p->cache_size;
> +
> + return spa + p->cache_size;
> + }
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_port_get_spa_cache_alias, CXL);
Quotes needed (the patch that changed that has been annoying this cycle!)
prev parent reply other threads:[~2024-12-24 12:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 22:46 [PATCH 0/4] acpi/hmat / cxl: Add exclusive caching enumeration and RAS support Dave Jiang
2024-12-04 22:46 ` [PATCH 1/4] acpi: numa: Add support to enumerate and store extended linear address mode Dave Jiang
2024-12-04 22:46 ` [PATCH 2/4] acpi/hmat / cxl: Add extended linear cache support for CXL Dave Jiang
2024-12-09 8:32 ` Li Ming
2024-12-09 16:24 ` Dave Jiang
2024-12-24 12:05 ` Jonathan Cameron
2025-01-07 17:24 ` Dave Jiang
2024-12-04 22:46 ` [PATCH 3/4] cxl: Add extended linear cache address alias emission for cxl events Dave Jiang
2024-12-24 12:11 ` Jonathan Cameron
2025-01-07 19:41 ` Dave Jiang
2025-01-10 14:59 ` Jonathan Cameron
2024-12-04 22:46 ` [PATCH 4/4] cxl: Add mce notifier to emit aliased address for extended linear cache Dave Jiang
2024-12-24 12:18 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241224121809.0000439c@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox