From patchwork Thu Jan 18 00:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522264 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 39D5F370 for ; Thu, 18 Jan 2024 00:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537694; cv=none; b=uzWvPdKMNZPDOovkZBBbeQIAXo55wBsj3rxj2gvkRBuSaVsA7UBeHePqv5lMzXfYiun/pQUpGFIStC3XssobtiycLL+hgCUCwzrQaxDlooM46MKDSvaganDawpB+BaQHzx4RMOOxrcFLu8A52qtSLrFPXPsjleSZH6FTP04i60I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537694; c=relaxed/simple; bh=hZ0XT3zGZ13N2t/d/jXTzV4fQS2xTLRryKNuiKfor1c=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=ST+robpGTQXz3IRYvJFdWIOeskszVVgpw1c8z/Km7GYkObboNalZ3Qr/++qV29aPG9fEZ8A/3BELSZFISvvY+MD8h7VGYItf122aJ1kfAiXDPdJ5pQyprLHwUFyL/3RD2RsUMP7yDFXpp5344orQOL0xLypbEDRIcYbot7EIc84= 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=Y64zgDr4; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Y64zgDr4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537693; x=1737073693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hZ0XT3zGZ13N2t/d/jXTzV4fQS2xTLRryKNuiKfor1c=; b=Y64zgDr4FJjFZWvkL4l6HyRAUy9+IjLL/I+NGuMxvmfMG7T+85QCVNnM M1YJ4Rd2M1dii3/p2FkoffzqtSwplltM30gsx6semVBzgY9KbfZBP/cyW LnnMVkTe0h2V0UJHnetjAa9AHoBFPmK83RQ8Sd71puL9rDQYn65NgSxw5 6QiBvEVo+V7CDOfhcX8Iv0zxWr1HAej3CZ21CA0k9uoEI0w7y8XgW4aYw HtSoxtEaZUdRs6mcUQ5ySBK9fxT43N3RqDZZTtNBbMy983p0BONWzaJqj lJsccbqa/TTOZTKbz+UlhL8OIq2+Dmf47sXdFZzoK4Xg/VoADaon8ICNu w==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904530" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904530" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577194" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577194" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:10 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 1/7] libcxl: add interfaces for GET_POISON_LIST mailbox commands Date: Wed, 17 Jan 2024 16:28:00 -0800 Message-Id: <22d01bd1af9af5370d1e35094176dbd66ef20dac.1705534719.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield CXL devices maintain a list of locations that are poisoned or result in poison if the addresses are accessed by the host. Per the spec (CXL 3.1 8.2.9.9.4.1), the device returns the Poison List as a set of Media Error Records that include the source of the error, the starting device physical address and length. Trigger the retrieval of the poison list by writing to the memory device sysfs attribute: trigger_poison_list. The CXL driver only offers triggering per memdev, so the trigger by region interface offered here is a convenience API that triggers a poison list retrieval for each memdev contributing to a region. int cxl_memdev_trigger_poison_list(struct cxl_memdev *memdev); int cxl_region_trigger_poison_list(struct cxl_region *region); The resulting poison records are logged as kernel trace events named 'cxl_poison'. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- cxl/lib/libcxl.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ cxl/lib/libcxl.sym | 6 ++++++ cxl/libcxl.h | 2 ++ 3 files changed, 55 insertions(+) diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index af4ca44eae19..cc95c2d7c94a 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -1647,6 +1647,53 @@ CXL_EXPORT int cxl_memdev_disable_invalidate(struct cxl_memdev *memdev) return 0; } +CXL_EXPORT int cxl_memdev_trigger_poison_list(struct cxl_memdev *memdev) +{ + struct cxl_ctx *ctx = cxl_memdev_get_ctx(memdev); + char *path = memdev->dev_buf; + int len = memdev->buf_len, rc; + + if (snprintf(path, len, "%s/trigger_poison_list", + memdev->dev_path) >= len) { + err(ctx, "%s: buffer too small\n", + cxl_memdev_get_devname(memdev)); + return -ENXIO; + } + rc = sysfs_write_attr(ctx, path, "1\n"); + if (rc < 0) { + fprintf(stderr, + "%s: Failed write sysfs attr trigger_poison_list\n", + cxl_memdev_get_devname(memdev)); + return rc; + } + return 0; +} + +CXL_EXPORT int cxl_region_trigger_poison_list(struct cxl_region *region) +{ + struct cxl_memdev_mapping *mapping; + int rc; + + cxl_mapping_foreach(region, mapping) { + struct cxl_decoder *decoder; + struct cxl_memdev *memdev; + + decoder = cxl_mapping_get_decoder(mapping); + if (!decoder) + continue; + + memdev = cxl_decoder_get_memdev(decoder); + if (!memdev) + continue; + + rc = cxl_memdev_trigger_poison_list(memdev); + if (rc) + return rc; + } + + return 0; +} + CXL_EXPORT int cxl_memdev_enable(struct cxl_memdev *memdev) { struct cxl_ctx *ctx = cxl_memdev_get_ctx(memdev); diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym index 8fa1cca3d0d7..277b7e21d6a6 100644 --- a/cxl/lib/libcxl.sym +++ b/cxl/lib/libcxl.sym @@ -264,3 +264,9 @@ global: cxl_memdev_update_fw; cxl_memdev_cancel_fw_update; } LIBCXL_5; + +LIBCXL_7 { +global: + cxl_memdev_trigger_poison_list; + cxl_region_trigger_poison_list; +} LIBCXL_6; diff --git a/cxl/libcxl.h b/cxl/libcxl.h index 0f4f4b2648fb..ecdffe36df2c 100644 --- a/cxl/libcxl.h +++ b/cxl/libcxl.h @@ -460,6 +460,8 @@ enum cxl_setpartition_mode { int cxl_cmd_partition_set_mode(struct cxl_cmd *cmd, enum cxl_setpartition_mode mode); +int cxl_memdev_trigger_poison_list(struct cxl_memdev *memdev); +int cxl_region_trigger_poison_list(struct cxl_region *region); #ifdef __cplusplus } /* extern "C" */ From patchwork Thu Jan 18 00:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522265 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 92D1238A for ; Thu, 18 Jan 2024 00:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537696; cv=none; b=LL6lDww27WpEVhXT5s91pPHMz1KjYp+J9zxLVmXPX5kmZl5BKTmBfpH7GGheqtCkFZFJnzAyi72zC4YUHSNH1tF84EKG3PWE1irjbzZFOWZa1bJIM3/7QrwXhNh4EeKJ5/ffGGf3jaR9XovynLzPoOXEoIp3pgibXhZbwjdyJBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537696; c=relaxed/simple; bh=/6VpUaWnmXTmaZkbBi4KUBqeRnhZehQ/00i3tBBr8aY=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=pMAvrsffYHEr9XTuHZI3nUe+itCnT1KvvnfgD2gKpdEo6IKvNu4nVCVuMUgWbiIr0JUUvZ7ZwSbVrvPFLwhaDKU1+21Su6SnqrIugP1FHx3KEsCRE8wg5LP5JIgF2kkaAVi0VJhw6gj1tIu0AlNWIKyF2evzhT3A0Ifd1MrzYps= 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=CKepddJF; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CKepddJF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537694; x=1737073694; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/6VpUaWnmXTmaZkbBi4KUBqeRnhZehQ/00i3tBBr8aY=; b=CKepddJF/6uFIqztHh8yvQnnbhHpm5EtpCnuWfghjnbl8a/J1VJTalCU Z+Oh9FQM+fbRl/qUOm33MVkoXpW01xqttgLbbITD3JBaGftxnSAqoHitc nMJNkU1Kvs89STeCM7XvsTwgzFW1zvpE6moNHQPNOQxNhQQZXUBQbyVCX l+UjgSdBrPdjwtOGfz9iED4w9aPR1uciiv6b+Eg9XyhkXJR3gRp2Ucge1 oTMW0MEOsBWW7RtXg3OJacQ1UH6xogCfGjjVWDPQsbXDM7bGWWBzW0l/s zSqp14VzGhpHpsyRJo4fIhdwoDmm2tSMd9afga8CrebJmjTKPY8bqVyOW w==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904537" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904537" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577204" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577204" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:13 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 2/7] cxl: add an optional pid check to event parsing Date: Wed, 17 Jan 2024 16:28:01 -0800 Message-Id: <77d576abb7e7f9badbb0c117935ad1bcc74899bd.1705534719.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield When parsing CXL events, callers may only be interested in events that originate from the current process. Introduce an optional argument to the event trace context: event_pid. When event_pid is present, simply skip the parsing of events without a matching pid. It is not a failure to see other, non matching events. The initial use case for this is device poison listings where only the media-error records requested by this process are wanted. Signed-off-by: Alison Schofield Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- cxl/event_trace.c | 5 +++++ cxl/event_trace.h | 1 + 2 files changed, 6 insertions(+) diff --git a/cxl/event_trace.c b/cxl/event_trace.c index db8cc85f0b6f..269060898118 100644 --- a/cxl/event_trace.c +++ b/cxl/event_trace.c @@ -208,6 +208,11 @@ static int cxl_event_parse(struct tep_event *event, struct tep_record *record, return 0; } + if (event_ctx->event_pid) { + if (event_ctx->event_pid != tep_data_pid(event->tep, record)) + return 0; + } + if (event_ctx->parse_event) return event_ctx->parse_event(event, record, &event_ctx->jlist_head); diff --git a/cxl/event_trace.h b/cxl/event_trace.h index ec6267202c8b..7f7773b2201f 100644 --- a/cxl/event_trace.h +++ b/cxl/event_trace.h @@ -15,6 +15,7 @@ struct event_ctx { const char *system; struct list_head jlist_head; const char *event_name; /* optional */ + int event_pid; /* optional */ int (*parse_event)(struct tep_event *event, struct tep_record *record, struct list_head *jlist_head); /* optional */ }; From patchwork Thu Jan 18 00:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522267 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 8D662658 for ; Thu, 18 Jan 2024 00:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537699; cv=none; b=qHf5tn339m/oZGbSe9671EzZFsNh+E9zJ91WYVd9YO3qzf4cF/P001QhE3Zb5wgWzWCuRVBZu6P5gRi9Ben4M8FSQfx2UkzVpZdeYCYCYV+XxJn8T7qmcE38u61XA+EoMd1HyX/xfNNyy68oRPQUAU6aO3VLCUI9ZzAkB50l2jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537699; c=relaxed/simple; bh=0XLw4CP08uGngf2UQEdkpoCE656YckzdRPZcyX89Cio=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=IuKO8gH7fFN25XfNlHkQWBsa/opPmge18Ei31Y6GaQ6zxepXAZg/NuqXv0Nve7SnCZNYXeUDg/aO+3xnW8ilejBcxma7s4tTOr4km/b7j78R6Ckg4j25S1RhmlFs36gUjoXp8mretuhGpZQG01rpxZnPBaGgRpz2HqSgVFy+hs0= 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=mKHH/wXQ; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mKHH/wXQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537696; x=1737073696; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0XLw4CP08uGngf2UQEdkpoCE656YckzdRPZcyX89Cio=; b=mKHH/wXQkIKOFL/ZFZamGzUxhT3cyaeV3HSoE+CmVdi9wEBGUo5axDdK J2dv47puDD2A2iuX0GsyiLjvnnI7dZE5BZAwBYVCfRQv4RXS4d/vt608x j2BFdGwU76dqtllrviipqrddsAKJR3aj8Lyj6wh8YHyL11BOlcK9SZOMi HomKAVzdxFJpogXHfc0mx8phyUMXVk4P2e6N3qs/exE13fFyzNYlYlO7I +xstxEl+LODgFkZDX619+/NjEqlDfnPa055pSvZrxSNIxIUUJXJt3iL0E GPqjXhdS9CYtX1ZH0Tn4SajVugJsW2+M/TZRaWNeC7tQ9O2Je2OIQnGgZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904545" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904545" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577217" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577217" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:14 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 3/7] cxl/event_trace: add a private context for private parsers Date: Wed, 17 Jan 2024 16:28:02 -0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield CXL event tracing provides helpers to iterate through a trace buffer and extract events of interest. It offers two parsing options: a default parser that adds every field of an event to a json object, and a private parsing option where the caller can parse each event as it wishes. Although the private parser can do some conditional parsing based on field values, it has no method to receive additional information needed to make parsing decisions in the callback. Add a private_ctx field to the existing 'struct event_context'. Replace the jlist_head parameter, used in the default parser, with the private_ctx. This is in preparation for adding a private parser requiring additional context for cxl_poison events. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- cxl/event_trace.c | 2 +- cxl/event_trace.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cxl/event_trace.c b/cxl/event_trace.c index 269060898118..fbf7a77235ff 100644 --- a/cxl/event_trace.c +++ b/cxl/event_trace.c @@ -215,7 +215,7 @@ static int cxl_event_parse(struct tep_event *event, struct tep_record *record, if (event_ctx->parse_event) return event_ctx->parse_event(event, record, - &event_ctx->jlist_head); + event_ctx->private_ctx); return cxl_event_to_json(event, record, &event_ctx->jlist_head); } diff --git a/cxl/event_trace.h b/cxl/event_trace.h index 7f7773b2201f..ec61962abbc6 100644 --- a/cxl/event_trace.h +++ b/cxl/event_trace.h @@ -16,8 +16,9 @@ struct event_ctx { struct list_head jlist_head; const char *event_name; /* optional */ int event_pid; /* optional */ + void *private_ctx; /* required with parse_event() */ int (*parse_event)(struct tep_event *event, struct tep_record *record, - struct list_head *jlist_head); /* optional */ + void *private_ctx);/* optional */ }; int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx); From patchwork Thu Jan 18 00:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522266 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 DFB42395 for ; Thu, 18 Jan 2024 00:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537699; cv=none; b=lR0ffhoQ7n2PMASU/gLzwktniQPfQ15NdDT0VMtddlT4QHqMCeUxLskYNc25L86/yWD/ArAEaJdDk+9KoGSg+GGdWAIeXRtwlrpdgiMZl1Tod7X1jOUYclJNRKg8hxxZMf2y+NDWj15BtNvHVj/WzvHeWvjRpmB1ocXgeZELCCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537699; c=relaxed/simple; bh=uxHOPpz1DJf7BmotOR7X3I+QbjiBrrlrJ40kvd+VEdA=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=adp6rUNXPgT54sxaLC4ylfBQ3FiDuZF3zt06Y1/yFq/FpVhKWubFZD0/wQeYHPKscQLAmqy3CstQ6VrX3m2N4EbLd4whYymV/2N+UMQZ/0LYkHdwvXpSNfdBRII3nEYeQBCkRks9WG81ffU++XtsUT2yHrB7xi2/3xiNe+xsT4g= 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=oBAuH5e0; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oBAuH5e0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537698; x=1737073698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uxHOPpz1DJf7BmotOR7X3I+QbjiBrrlrJ40kvd+VEdA=; b=oBAuH5e0R4yx1+dv9FPjgJ68zo0J52PW+1JdnGHEgqo5ve54YgGPlVVC gAJ/W9ZhzZQ3ElDpiVIt7I7ffW/ASdScDhlUMd5O9e97sdK44niKo8/nk JzgJG/0MwOSB2hMlowICVqkv541Br01JfQhShDVg5dRF+GtgcAH9diTaV soaPkqkt9yP7DTCEmm+X53qqRR4ojxiTAyw1cLn5EuifQPcG9vnI1NtJ8 LCA+bNcqbcs4glklhy/FWA+D2Py+P8ZgeepAKAlWz/Tf7aF1Db81ini3C 8WvvqrWPPZHQJVhe5OUWtsLkitYpZstXnlHpZb+jGgoHGWkY+uQAyZaZm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904550" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904550" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577228" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577228" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:16 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 4/7] cxl/event_trace: add helpers get_field_[string|data]() Date: Wed, 17 Jan 2024 16:28:03 -0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield Add helpers to extract the value of an event record field given the field name. This is useful when the user knows the name and format of the field and simply needs to get it. Add signed and unsigned char* versions to support string and u64 data fields. This is in preparation for adding a private parser of cxl_poison events. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- cxl/event_trace.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ cxl/event_trace.h | 5 ++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/cxl/event_trace.c b/cxl/event_trace.c index fbf7a77235ff..8d04d8d34194 100644 --- a/cxl/event_trace.c +++ b/cxl/event_trace.c @@ -15,6 +15,52 @@ #define _GNU_SOURCE #include +static struct tep_format_field *__find_field(struct tep_event *event, + const char *name) +{ + struct tep_format_field **fields; + + fields = tep_event_fields(event); + if (!fields) + return NULL; + + for (int i = 0; fields[i]; i++) { + struct tep_format_field *f = fields[i]; + + if (strcmp(f->name, name) != 0) + continue; + + return f; + } + return NULL; +} + +unsigned char *cxl_get_field_data(struct tep_event *event, + struct tep_record *record, const char *name) +{ + struct tep_format_field *f; + int len; + + f = __find_field(event, name); + if (!f) + return NULL; + + return tep_get_field_raw(NULL, event, f->name, record, &len, 0); +} + +char *cxl_get_field_string(struct tep_event *event, struct tep_record *record, + const char *name) +{ + struct tep_format_field *f; + int len; + + f = __find_field(event, name); + if (!f) + return NULL; + + return tep_get_field_raw(NULL, event, f->name, record, &len, 0); +} + static struct json_object *num_to_json(void *num, int elem_size, unsigned long flags) { bool sign = flags & TEP_FIELD_IS_SIGNED; diff --git a/cxl/event_trace.h b/cxl/event_trace.h index ec61962abbc6..6252f583097a 100644 --- a/cxl/event_trace.h +++ b/cxl/event_trace.h @@ -25,5 +25,8 @@ int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx); int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system, const char *event); int cxl_event_tracing_disable(struct tracefs_instance *inst); - +char *cxl_get_field_string(struct tep_event *event, struct tep_record *record, + const char *name); +unsigned char *cxl_get_field_data(struct tep_event *event, + struct tep_record *record, const char *name); #endif From patchwork Thu Jan 18 00:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522268 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 737A6631 for ; Thu, 18 Jan 2024 00:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537701; cv=none; b=gtDPhU7+d6lodMq93MxxAGyyXYPp9cAOSDaRaGXKPlVODHj2GDrHuPK9npC6vcKTzzZZX6YSM4rKh30sLKNZqd0NxSDyI97+sHHI31DeYSTsmGl6kBPnOXduhQCpb7LeT9l5n1XlMtkUWWS805ajO3sSxV+YLWrIHfT/KL7ETBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537701; c=relaxed/simple; bh=dD7zlqPt0y2qe8Ho4ZS/d8EbHIfCNsOxxrOlJJZs6Ew=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=hDZ3/dFji52HBlKtI15pvO4Ije9RvA1qePHIUNM6POye2Wf7TL/pUpcnf7SQe4bz8WNx9KG3SNdnOs7NrGpD5HCBlzPAlycA+MiDsVvDzKI5bgGC7DCp4JCuyDSqxoD9z/mSEiTgZfTkv2cruIRyGYlfaA9ltOBbc/4HHJDld/s= 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=dNslMTuv; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dNslMTuv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537699; x=1737073699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dD7zlqPt0y2qe8Ho4ZS/d8EbHIfCNsOxxrOlJJZs6Ew=; b=dNslMTuvrtBfNudROgptn3PKEROYdArO0t590sXM8t8tGOgDW5IBH39c tRgyixHsmln27DkKzlBWYdwfwOoIcijlv+BvSOqHRPdTBl8ww+I7teQ3T Qyx6p/4DvlrWtNJAs7LikpRyORHZ4qknpSqprRG8D/YEiTEyk/VewPU49 VN1dHBBgIHRUhx2eCr6gn8BSr0jkgH0hNnfVFYkuuDwkFDGLmr3Y4JCKG xhMosyR/aACJP6Nihnll9I1hdrIFg9yZ1JRgIXSkNv0I3s1d2Q3hOUJRx v0wxogEQ03SIUxPMUgf6J+VLMnZ49XB6ldZDEZVAZP8ayG/jx+qcP714P Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904555" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904555" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577241" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577241" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:18 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 5/7] cxl/list: collect and parse media_error records Date: Wed, 17 Jan 2024 16:28:04 -0800 Message-Id: <17f5eccf769f97b7d2450890a5a185eaaf69be32.1705534719.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield Media_error records are logged as events in the kernel tracing subsystem. To prepare the media_error records for cxl list, enable tracing, trigger the poison list read, and parse the generated cxl_poison events into a json representation. Use the event_trace private parsing option to customize the json representation based on cxl-list calling options and event field settings. Signed-off-by: Alison Schofield --- cxl/json.c | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) diff --git a/cxl/json.c b/cxl/json.c index 7678d02020b6..abe77e1f86d3 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -1,16 +1,20 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2015-2021 Intel Corporation. All rights reserved. #include +#include #include +#include #include #include #include #include #include +#include #include "filter.h" #include "json.h" #include "../daxctl/json.h" +#include "event_trace.h" #define CXL_FW_VERSION_STR_LEN 16 #define CXL_FW_MAX_SLOTS 4 @@ -571,6 +575,208 @@ err_jobj: return NULL; } +/* CXL Spec 3.1 Table 8-140 Media Error Record */ +#define CXL_POISON_SOURCE_UNKNOWN 0 +#define CXL_POISON_SOURCE_EXTERNAL 1 +#define CXL_POISON_SOURCE_INTERNAL 2 +#define CXL_POISON_SOURCE_INJECTED 3 +#define CXL_POISON_SOURCE_VENDOR 7 + +/* CXL Spec 3.1 Table 8-139 Get Poison List Output Payload */ +#define CXL_POISON_FLAG_MORE BIT(0) +#define CXL_POISON_FLAG_OVERFLOW BIT(1) +#define CXL_POISON_FLAG_SCANNING BIT(2) + +struct poison_event_ctx { + struct json_object *jpoison; + const char *region_name; + unsigned long flags; +}; + +int poison_event_to_json(struct tep_event *event, struct tep_record *record, + void *ctx) +{ + struct poison_event_ctx *p_ctx = (struct poison_event_ctx *)ctx; + struct json_object *jobj, *jp, *jpoison = p_ctx->jpoison; + const char *region_name = p_ctx->region_name; + unsigned long flags = p_ctx->flags; + bool overflow = false; + unsigned char *data; + int pflags; + char *str; + + jp = json_object_new_object(); + if (!jp) + return -ENOMEM; + + str = cxl_get_field_string(event, record, "region"); + + /* Skip records not in this region when listing by region */ + if ((region_name) && (strcmp(region_name, str) != 0)) { + json_object_put(jp); + return 0; + } + /* Only display region name in by memdev listings */ + if (!region_name && strlen(str)) { + jobj = json_object_new_string(str); + if (jobj) + json_object_object_add(jp, "region", jobj); + } + /* Only display memdev name in by region listings */ + if (region_name) { + str = cxl_get_field_string(event, record, "memdev"); + jobj = json_object_new_string(str); + if (jobj) + json_object_object_add(jp, "memdev", jobj); + } + + data = cxl_get_field_data(event, record, "dpa"); + jobj = util_json_object_hex(*(uint64_t *)data, flags); + if (jobj) + json_object_object_add(jp, "dpa", jobj); + + data = cxl_get_field_data(event, record, "dpa_length"); + jobj = util_json_object_size(*(uint32_t *)data, flags); + if (jobj) + json_object_object_add(jp, "dpa_length", jobj); + + data = cxl_get_field_data(event, record, "hpa"); + if (*(uint64_t *)data != ULLONG_MAX) { + jobj = util_json_object_hex(*(uint64_t *)data, flags); + if (jobj) + json_object_object_add(jp, "hpa", jobj); + } + + str = cxl_get_field_string(event, record, "source"); + switch (*(uint8_t *)str) { + case CXL_POISON_SOURCE_UNKNOWN: + jobj = json_object_new_string("Unknown"); + break; + case CXL_POISON_SOURCE_EXTERNAL: + jobj = json_object_new_string("External"); + break; + case CXL_POISON_SOURCE_INTERNAL: + jobj = json_object_new_string("Internal"); + break; + case CXL_POISON_SOURCE_INJECTED: + jobj = json_object_new_string("Injected"); + break; + case CXL_POISON_SOURCE_VENDOR: + jobj = json_object_new_string("Vendor"); + break; + default: + jobj = json_object_new_string("Reserved"); + } + json_object_object_add(jp, "source", jobj); + + str = cxl_get_field_string(event, record, "flags"); + pflags = *(uint8_t *)str; + if (pflags) { + char flag_str[32] = { '\0' }; + + if (pflags & CXL_POISON_FLAG_MORE) + strcat(flag_str, "More,"); + if (pflags & CXL_POISON_FLAG_SCANNING) + strcat(flag_str, "Scanning,"); + if (pflags & CXL_POISON_FLAG_OVERFLOW) { + strcat(flag_str, "Overflow,"); + overflow = true; + } + jobj = json_object_new_string(flag_str); + if (jobj) + json_object_object_add(jp, "flags", jobj); + } + if (overflow) { + data = cxl_get_field_data(event, record, "overflow_ts"); + jobj = util_json_object_hex(*(uint64_t *)data, flags); + if (jobj) + json_object_object_add(jp, "overflow_t", jobj); + } + + json_object_array_add(jpoison, jp); + + return 0; +} + +static struct json_object * +util_cxl_poison_events_to_json(struct tracefs_instance *inst, + const char *region_name, unsigned long flags) +{ + struct poison_event_ctx p_ctx = { + .region_name = region_name, + .flags = flags, + }; + struct event_ctx ectx = { + .event_name = "cxl_poison", + .event_pid = getpid(), + .system = "cxl", + .private_ctx = &p_ctx, + .parse_event = poison_event_to_json, + }; + int rc = 0; + + p_ctx.jpoison = json_object_new_array(); + if (!p_ctx.jpoison) + return NULL; + + rc = cxl_parse_events(inst, &ectx); + if (rc < 0) { + fprintf(stderr, "Failed to parse events: %d\n", rc); + json_object_put(p_ctx.jpoison); + return NULL; + } + + if (json_object_array_length(p_ctx.jpoison) == 0) { + json_object_put(p_ctx.jpoison); + return NULL; + } + + return p_ctx.jpoison; +} + +static struct json_object * +util_cxl_poison_list_to_json(struct cxl_region *region, + struct cxl_memdev *memdev, + unsigned long flags) +{ + struct json_object *jpoison = NULL; + struct tracefs_instance *inst; + const char *region_name; + int rc; + + inst = tracefs_instance_create("cxl list"); + if (!inst) { + fprintf(stderr, "tracefs_instance_create() failed\n"); + return NULL; + } + + rc = cxl_event_tracing_enable(inst, "cxl", "cxl_poison"); + if (rc < 0) { + fprintf(stderr, "Failed to enable trace: %d\n", rc); + goto err_free; + } + + if (region) + rc = cxl_region_trigger_poison_list(region); + else + rc = cxl_memdev_trigger_poison_list(memdev); + if (rc) + goto err_free; + + rc = cxl_event_tracing_disable(inst); + if (rc < 0) { + fprintf(stderr, "Failed to disable trace: %d\n", rc); + goto err_free; + } + + region_name = region ? cxl_region_get_devname(region) : NULL; + jpoison = util_cxl_poison_events_to_json(inst, region_name, flags); + +err_free: + tracefs_instance_free(inst); + return jpoison; +} + struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev, unsigned long flags) { @@ -649,6 +855,12 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev, json_object_object_add(jdev, "firmware", jobj); } + if (flags & UTIL_JSON_MEDIA_ERRORS) { + jobj = util_cxl_poison_list_to_json(NULL, memdev, flags); + if (jobj) + json_object_object_add(jdev, "media_errors", jobj); + } + json_object_set_userdata(jdev, memdev, NULL); return jdev; } @@ -987,6 +1199,12 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region, json_object_object_add(jregion, "state", jobj); } + if (flags & UTIL_JSON_MEDIA_ERRORS) { + jobj = util_cxl_poison_list_to_json(region, NULL, flags); + if (jobj) + json_object_object_add(jregion, "media_errors", jobj); + } + util_cxl_mappings_append_json(jregion, region, flags); if (flags & UTIL_JSON_DAX) { From patchwork Thu Jan 18 00:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522269 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 B0603A50 for ; Thu, 18 Jan 2024 00:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537703; cv=none; b=PQAC9RnL1Gmi6oC0vsh6nbDQqpRKp9aUIfFkdxiHiys6XvbF033YcPk7dUF5o7j0HbVY8FuPQbFahWzPe2V9ndC8dUgkPK2hnNTjmkvhfN4JvRS7/4zqbelBbdtJTrXRAtH/NJO4kbRGD1Z1rJK9Fb4xt+yHbYsk49VW4PiblHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537703; c=relaxed/simple; bh=oek0qkt+aBT7WRJCd9+jfLco9THKG0GNqm4+L7t/V4Q=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=e462pjwMSTZaM3bsLdaX3w/U0BGafURsnGcQNzX6vcpkVIML/qMqQTEVwGbkuqTxvbLgOwqT8QalN0nNgiMHpbhoox8Cpg3OyBo0rE0o+huVbZrxjZHl//7mXQbU0akqxidDqNYJMc/EGVNjGzHax8g3LuDjxbHfzQegSyyuWWg= 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=LrX1D59Z; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LrX1D59Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537700; x=1737073700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oek0qkt+aBT7WRJCd9+jfLco9THKG0GNqm4+L7t/V4Q=; b=LrX1D59Zv6oik14IXAb5Bl+4PGjcP1jQ/hHbJV0iGvbgsF7weZxDR9ZT Jw2AmuXLniph+og/Jhz2GDZ6txd7i6MGYCeebFINVgG6oaL4lpvNqJGEh mDf3tbEnCU6HFAOPm3+Rk3oi7+IYJaJoVcdN2GFMjdyzudZ5LkWnHcdH1 kVIlac5W8nJXUtNzrvOViTH4dkmr0p4a6ehOIEis+eKvtXxaF3tnMybjI HLAwg2nDX0AHV3a9th/oU6iGGga9Ej//oIIezT4KQIu9GNsjjrU+ONSOL Sq7zF3WTAaEkhL2slRDTnE8fTb614f+rgpKyvZZp3TxAVDrDlG4fySMPM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904568" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904568" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577253" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577253" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:19 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 6/7] cxl/list: add --media-errors option to cxl list Date: Wed, 17 Jan 2024 16:28:05 -0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield The --media-errors option to 'cxl list' retrieves poison lists from memory devices supporting the capability and displays the returned media_error records in the cxl list json. This option can apply to memdevs or regions. Example usage in the Documentation/cxl/cxl-list.txt update. Signed-off-by: Alison Schofield --- Documentation/cxl/cxl-list.txt | 71 ++++++++++++++++++++++++++++++++++ cxl/filter.h | 3 ++ cxl/list.c | 2 + 3 files changed, 76 insertions(+) diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt index 838de4086678..6105c896938c 100644 --- a/Documentation/cxl/cxl-list.txt +++ b/Documentation/cxl/cxl-list.txt @@ -415,6 +415,77 @@ OPTIONS --region:: Specify CXL region device name(s), or device id(s), to filter the listing. +-L:: +--media-errors:: + Include media-error information. The poison list is retrieved from the + device(s) and media_error records are added to the listing. Apply this + option to memdevs and regions where devices support the poison list + capability. + +---- +# cxl list -m mem1 --media-errors +[ + { + "memdev":"mem1", + "pmem_size":1073741824, + "ram_size":1073741824, + "serial":1, + "numa_node":1, + "host":"cxl_mem.1", + "media_errors":[ + { + "dpa":0, + "dpa_length":64, + "source":"Injected" + }, + { + "region":"region5", + "dpa":1073741824, + "dpa_length":64, + "hpa":1035355557888, + "source":"Injected" + }, + { + "region":"region5", + "dpa":1073745920, + "dpa_length":64, + "hpa":1035355566080, + "source":"Injected" + } + ] + } +] + +# cxl list -r region5 --media-errors +[ + { + "region":"region5", + "resource":1035355553792, + "size":2147483648, + "type":"pmem", + "interleave_ways":2, + "interleave_granularity":4096, + "decode_state":"commit", + "media_errors":[ + { + "memdev":"mem1", + "dpa":1073741824, + "dpa_length":64, + "hpa":1035355557888, + "source":"Injected" + }, + { + "memdev":"mem1", + "dpa":1073745920, + "dpa_length":64, + "hpa":1035355566080, + "source":"Injected" + } + ] + } +] +---- + -v:: --verbose:: Increase verbosity of the output. This can be specified diff --git a/cxl/filter.h b/cxl/filter.h index 3f65990f835a..956a46e0c7a9 100644 --- a/cxl/filter.h +++ b/cxl/filter.h @@ -30,6 +30,7 @@ struct cxl_filter_params { bool fw; bool alert_config; bool dax; + bool media_errors; int verbose; struct log_ctx ctx; }; @@ -88,6 +89,8 @@ static inline unsigned long cxl_filter_to_flags(struct cxl_filter_params *param) flags |= UTIL_JSON_ALERT_CONFIG; if (param->dax) flags |= UTIL_JSON_DAX | UTIL_JSON_DAX_DEVS; + if (param->media_errors) + flags |= UTIL_JSON_MEDIA_ERRORS; return flags; } diff --git a/cxl/list.c b/cxl/list.c index 93ba51ef895c..bcdee0afd405 100644 --- a/cxl/list.c +++ b/cxl/list.c @@ -57,6 +57,8 @@ static const struct option options[] = { "include memory device firmware information"), OPT_BOOLEAN('A', "alert-config", ¶m.alert_config, "include alert configuration information"), + OPT_BOOLEAN('L', "media-errors", ¶m.media_errors, + "include media-error information "), OPT_INCR('v', "verbose", ¶m.verbose, "increase output detail"), #ifdef ENABLE_DEBUG OPT_BOOLEAN(0, "debug", &debug, "debug list walk"), From patchwork Thu Jan 18 00:28:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13522270 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 278D7A5E for ; Thu, 18 Jan 2024 00:28:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537704; cv=none; b=ExF1m2HWbdzpm4fetC0vpDM7bk0K9RaJq3B5h/SXBSuqUV3gboIvJaTAduk6VraVLlCvv8jKX8yqX3KvCSlFWqg9fYW6UHEyhXGzxDZRzvaM2NHjlRLGTDRbSF6FP+Y8Q7TF1RNbTjcvGHuwfv1LH2AcjtnVFsh71yE7hl+jdDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705537704; c=relaxed/simple; bh=zMYBSPVOSUpv6oOK/BknFI1D0COrJaTJ0DmAHe/5ezY=; h=DKIM-Signature:X-IronPort-AV:X-IronPort-AV:Received:X-ExtLoop1: X-IronPort-AV:X-IronPort-AV:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=W2bf+/HgqIQveVXEOSdyAT6cAHr2K9ivfzjaudZWUMVKsjj1/xFS+7mKgoKo3GrlOfT4S0A8Z6Mxbq6k4QMKMATega0QdYIPQjpHO0hjQVPdHd3UKYYPnFVczwkIx4scmJkiCKpzoEiifwbENVLITPwoKsARooRpWMnAK5NhhGI= 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=em5fS6AP; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="em5fS6AP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705537702; x=1737073702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zMYBSPVOSUpv6oOK/BknFI1D0COrJaTJ0DmAHe/5ezY=; b=em5fS6API0oWzfLmcflqY4p2HwnIUUPca2yJtfhy8Nv63DxCRM2/PnjU KMxgHQJZKZUOOG+U1oHpiYEooHZkqzBGdaNTwpGWx276Aoz4ZZcYWIA1n vbT/W7CY9/wVai2p3BDy/pi7fAFIaUN07puMEcENysIJvRmtmbu1wSNvA bVmGfwonUofc9POnLkCjd/isv8BM3I+HT00HLveUU1ldRJgu9HZg7UpkY LkVRWsZYwCnPIMFCFKNpzZwR1U4QK3tKuqBgoUGRXtM6OsUOeyQ9wYFju 2loAN7bidwy7qvxKErRfKt9mvt+9P/s+COmpoIXQqVTcrNfRWYKn+7TJb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="18904582" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="18904582" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10956"; a="777577266" X-IronPort-AV: E=Sophos;i="6.05,201,1701158400"; d="scan'208";a="777577266" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.110.93]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2024 16:28:21 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [PATCH v6 7/7] cxl/test: add cxl-poison.sh unit test Date: Wed, 17 Jan 2024 16:28:06 -0800 Message-Id: <2bfc65ec1bbe0168928f08541ec26d6d5dded345.1705534719.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield Exercise cxl list, libcxl, and driver pieces of the get poison list pathway. Inject and clear poison using debugfs and use cxl-cli to read the poison list by memdev and by region. Signed-off-by: Alison Schofield --- test/cxl-poison.sh | 133 +++++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 + 2 files changed, 135 insertions(+) create mode 100644 test/cxl-poison.sh diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh new file mode 100644 index 000000000000..91c5c0bed1c2 --- /dev/null +++ b/test/cxl-poison.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 Intel Corporation. All rights reserved. + +. "$(dirname "$0")"/common + +rc=77 + +set -ex + +trap 'err $LINENO' ERR + +check_prereq "jq" + +modprobe -r cxl_test +modprobe cxl_test + +rc=1 + +# THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to +# inject, clear, and get the poison list. Do it by memdev and by region. + +find_memdev() +{ + readarray -t capable_mems < <("$CXL" list -b "$CXL_TEST_BUS" -M | + jq -r ".[] | select(.pmem_size != null) | + select(.ram_size != null) | .memdev") + + if [ ${#capable_mems[@]} == 0 ]; then + echo "no memdevs found for test" + err "$LINENO" + fi + + memdev=${capable_mems[0]} +} + +create_x2_region() +{ + # Find an x2 decoder + decoder="$($CXL list -b "$CXL_TEST_BUS" -D -d root | jq -r ".[] | + select(.pmem_capable == true) | + select(.nr_targets == 2) | + .decoder")" + + # Find a memdev for each host-bridge interleave position + port_dev0="$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 0) | .target")" + port_dev1="$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 1) | .target")" + mem0="$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev")" + mem1="$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev")" + + region="$($CXL create-region -d "$decoder" -m "$mem0" "$mem1" | + jq -r ".region")" + if [[ ! $region ]]; then + echo "create-region failed for $decoder" + err "$LINENO" + fi + echo "$region" +} + +# When cxl-cli support for inject and clear arrives, replace +# the writes to /sys/kernel/debug with the new cxl commands. + +inject_poison_sysfs() +{ + memdev="$1" + addr="$2" + + echo "$addr" > /sys/kernel/debug/cxl/"$memdev"/inject_poison +} + +clear_poison_sysfs() +{ + memdev="$1" + addr="$2" + + echo "$addr" > /sys/kernel/debug/cxl/"$memdev"/clear_poison +} + +validate_poison_found() +{ + list_by="$1" + nr_expect="$2" + + poison_list="$($CXL list -r "$list_by" --media-errors | + jq -r '.[].media_errors')" + nr_found=$(jq "length" <<< "$poison_list") + if [ "$nr_found" -ne "$nr_expect" ]; then + echo "$nr_expect poison records expected, $nr_found found" + err "$LINENO" + fi +} + +test_poison_by_memdev() +{ + find_memdev + inject_poison_sysfs "$memdev" "0x40000000" + inject_poison_sysfs "$memdev" "0x40001000" + inject_poison_sysfs "$memdev" "0x600" + inject_poison_sysfs "$memdev" "0x0" + validate_poison_found "-m $memdev" 4 + + clear_poison_sysfs "$memdev" "0x40000000" + clear_poison_sysfs "$memdev" "0x40001000" + clear_poison_sysfs "$memdev" "0x600" + clear_poison_sysfs "$memdev" "0x0" + validate_poison_found "-m $memdev" 0 +} + +test_poison_by_region() +{ + create_x2_region + inject_poison_sysfs "$mem0" "0x40000000" + inject_poison_sysfs "$mem1" "0x40000000" + validate_poison_found "-r $region" 2 + + clear_poison_sysfs "$mem0" "0x40000000" + clear_poison_sysfs "$mem1" "0x40000000" + validate_poison_found "-r $region" 0 +} + +# Turn tracing on. Note that 'cxl list --poison' does toggle the tracing. +# Turning it on here allows the test user to also view inject and clear +# trace events. +echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable + +test_poison_by_memdev +test_poison_by_region + +check_dmesg "$LINENO" + +modprobe -r cxl-test diff --git a/test/meson.build b/test/meson.build index 224adaf41fcc..2706fa5d633c 100644 --- a/test/meson.build +++ b/test/meson.build @@ -157,6 +157,7 @@ cxl_create_region = find_program('cxl-create-region.sh') cxl_xor_region = find_program('cxl-xor-region.sh') cxl_update_firmware = find_program('cxl-update-firmware.sh') cxl_events = find_program('cxl-events.sh') +cxl_poison = find_program('cxl-poison.sh') tests = [ [ 'libndctl', libndctl, 'ndctl' ], @@ -186,6 +187,7 @@ tests = [ [ 'cxl-create-region.sh', cxl_create_region, 'cxl' ], [ 'cxl-xor-region.sh', cxl_xor_region, 'cxl' ], [ 'cxl-events.sh', cxl_events, 'cxl' ], + [ 'cxl-poison.sh', cxl_poison, 'cxl' ], ] if get_option('destructive').enabled()