public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: <shiju.jose@huawei.com>
Cc: <linux-edac@vger.kernel.org>, <linux-cxl@vger.kernel.org>,
	<mchehab@kernel.org>, <dave.jiang@intel.com>,
	<dan.j.williams@intel.com>, <alison.schofield@intel.com>,
	<nifan.cxl@gmail.com>, <vishal.l.verma@intel.com>,
	<ira.weiny@intel.com>, <dave@stgolabs.net>,
	<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
	<tanxiaofei@huawei.com>, <prime.zeng@hisilicon.com>
Subject: Re: [PATCH v2 01/14] rasdaemon: Fix for parsing error when trace event's format file is larger than PAGE_SIZE
Date: Fri, 10 Jan 2025 16:02:44 +0000	[thread overview]
Message-ID: <20250110160244.00006635@huawei.com> (raw)
In-Reply-To: <20250110122641.1668-2-shiju.jose@huawei.com>

On Fri, 10 Jan 2025 12:26:27 +0000
<shiju.jose@huawei.com> wrote:

> From: Shiju Jose <shiju.jose@huawei.com>
> 
> When a trace event's format file is larger than PAGE_SIZE (4096) then
> libtraceevent returns parsing failed when rasdaemon reads the fields.
> The reason found that tep_parse_event() call in the add_event_handler()
> internally fails in libtraceevent because of the incomplete format file
> data read. However libtraceevent did not return error in this stage,
> which is fixed in the following patch for libtraceevent.
> https://lore.kernel.org/all/20250109102338.6128644d@gandalf.local.home/
> 
> When rasdaemon reads a trace event format file,the maximum data size

space after that comma if spinning a v3.

> that can be read is limited to PAGE_SIZE by the seq_read() and
> seq_read_iter() functions in the kernel. This results in userspace
> receiving partial data if the format file is larger than PAGE_SIZE,
> requiring fix in the rasdaemon to read the complete data from the
> format file.
> 
> Add fix for reading trace event format files larger than PAGE_SIZE
> in add_event_handler().
> 
> Signed-off-by: Shiju Jose <shiju.jose@huawei.com>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  ras-events.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/ras-events.c b/ras-events.c
> index 5d8118a..6692a31 100644
> --- a/ras-events.c
> +++ b/ras-events.c
> @@ -376,7 +376,7 @@ static int filter_ras_mc_event(struct ras_events *ras, char *group, char *event,
>  
>  static int get_pagesize(struct ras_events *ras, struct tep_handle *pevent)
>  {
> -	int fd, len, page_size = 4096;
> +	int fd, len, page_size = 8192;
>  	char buf[page_size];
>  
>  	fd = open_trace(ras, "events/header_page", O_RDONLY);
> @@ -827,7 +827,8 @@ static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
>  			     unsigned int page_size, char *group, char *event,
>  			     tep_event_handler_func func, char *filter_str, int id)
>  {
> -	int fd, size, rc;
> +	int fd, rc;
> +	int size = 0;
>  	char *page, fname[MAX_PATH + 1];
>  	struct tep_event_filter *filter = NULL;
>  
> @@ -857,13 +858,17 @@ static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
>  		return rc;
>  	}
>  
> -	size = read(fd, page, page_size);
> +	do {
> +		rc = read(fd, page + size, page_size);
> +		if (rc < 0) {
> +			log(TERM, LOG_ERR, "Can't get arch page size\n");
> +			free(page);
> +			close(fd);
> +			return size;
> +		}
> +		size += rc;
> +	} while (rc > 0);
>  	close(fd);
> -	if (size < 0) {
> -		log(TERM, LOG_ERR, "Can't get arch page size\n");
> -		free(page);
> -		return size;
> -	}
>  
>  	/* Registers the special event handlers */
>  	rc = tep_register_event_handler(pevent, -1, group, event, func, ras);


  reply	other threads:[~2025-01-10 16:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 12:26 [PATCH v2 00/14] rasdaemon: cxl: Update CXL event logging and recording to CXL spec rev 3.1 shiju.jose
2025-01-10 12:26 ` [PATCH v2 01/14] rasdaemon: Fix for parsing error when trace event's format file is larger than PAGE_SIZE shiju.jose
2025-01-10 16:02   ` Jonathan Cameron [this message]
2025-01-10 16:11     ` Shiju Jose
2025-01-10 12:26 ` [PATCH v2 02/14] rasdaemon: cxl: Fix logging of memory event type of DRAM trace event shiju.jose
2025-01-10 12:26 ` [PATCH v2 03/14] rasdaemon: cxl: Fix mismatch in region field's name with kernel " shiju.jose
2025-01-10 12:26 ` [PATCH v2 04/14] rasdaemon: cxl: Add automatic indexing for storing CXL fields in SQLite database shiju.jose
2025-01-10 12:26 ` [PATCH v2 05/14] rasdaemon: cxl: Update common event to CXL spec rev 3.1 shiju.jose
2025-01-10 12:26 ` [PATCH v2 06/14] rasdaemon: cxl: Add Component Identifier formatting for " shiju.jose
2025-01-10 12:26 ` [PATCH v2 07/14] rasdaemon: cxl: Update CXL general media event to " shiju.jose
2025-01-10 12:26 ` [PATCH v2 08/14] rasdaemon: cxl: Update CXL DRAM " shiju.jose
2025-01-10 12:26 ` [PATCH v2 09/14] rasdaemon: cxl: Update memory module " shiju.jose
2025-01-10 12:26 ` [PATCH v2 10/14] rasdaemon: ras-mc-ctl: Fix logging of memory event type in CXL DRAM error table shiju.jose
2025-01-10 12:26 ` [PATCH v2 11/14] rasdaemon: ras-mc-ctl: Update logging of common event data to align with CXL spec rev 3.1 shiju.jose
2025-01-10 12:26 ` [PATCH v2 12/14] rasdaemon: ras-mc-ctl: Update logging of CXL general media " shiju.jose
2025-01-10 12:26 ` [PATCH v2 13/14] rasdaemon: ras-mc-ctl: Update logging of CXL DRAM " shiju.jose
2025-01-10 12:26 ` [PATCH v2 14/14] rasdaemon: ras-mc-ctl: Update logging of CXL memory module " shiju.jose

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=20250110160244.00006635@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=nifan.cxl@gmail.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=shiju.jose@huawei.com \
    --cc=tanxiaofei@huawei.com \
    --cc=vishal.l.verma@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