lttng-dev Archive mirror
 help / color / mirror / Atom feed
From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org>
To: Benjamin Marzinski <bmarzins@redhat.com>,
	lttng-dev@lists.lttng.org,
	Michael Jeanson <mjeanson@efficios.com>
Subject: Re: [lttng-dev] [PATCH urcu] fix: handle EINTR correctly in get_cpu_mask_from_sysfs
Date: Thu, 2 May 2024 09:54:55 -0400	[thread overview]
Message-ID: <2a7f6659-4332-47ed-adbf-45e88915ac6b@efficios.com> (raw)
In-Reply-To: <20240501234242.2395659-1-bmarzins@redhat.com>

On 2024-05-01 19:42, Benjamin Marzinski via lttng-dev wrote:
> If the read() in get_cpu_mask_from_sysfs() fails with EINTR, the code is
> supposed to retry, but the while loop condition has (bytes_read > 0),
> which is false when read() fails with EINTR. The result is that the code
> exits the loop, having only read part of the string.
> 
> Use (bytes_read != 0) in the while loop condition instead, since the
> (bytes_read < 0) case is already handled in the loop.

Thanks for the fix ! It is indeed the right thing to do.

I would like to integrate this fix into the librseq and libside
projects as well though, but I notice the the copy in liburcu
is LGPLv2.1 whereas the copy in librseq and libside are
MIT.

Michael, should we first relicense the liburcu src/compat-smp.h
implementation to MIT so it matches the license of the copies
in librseq and libside ?

Thanks,

Mathieu

> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>   src/compat-smp.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compat-smp.h b/src/compat-smp.h
> index 31fa979..075a332 100644
> --- a/src/compat-smp.h
> +++ b/src/compat-smp.h
> @@ -164,7 +164,7 @@ static inline int get_cpu_mask_from_sysfs(char *buf, size_t max_bytes, const cha
>   
>   		total_bytes_read += bytes_read;
>   		assert(total_bytes_read <= max_bytes);
> -	} while (max_bytes > total_bytes_read && bytes_read > 0);
> +	} while (max_bytes > total_bytes_read && bytes_read != 0);
>   
>   	/*
>   	 * Make sure the mask read is a null terminated string.

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2024-05-02 13:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 23:42 [lttng-dev] [PATCH urcu] fix: handle EINTR correctly in get_cpu_mask_from_sysfs Benjamin Marzinski via lttng-dev
2024-05-02 13:54 ` Mathieu Desnoyers via lttng-dev [this message]
2024-05-02 14:32   ` Michael Jeanson via lttng-dev
2024-05-02 14:34     ` Mathieu Desnoyers via lttng-dev

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=2a7f6659-4332-47ed-adbf-45e88915ac6b@efficios.com \
    --to=lttng-dev@lists.lttng.org \
    --cc=bmarzins@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mjeanson@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).