From: Eric Dumazet <eric.dumazet@gmail.com>
To: jiasheng <jiasheng@iscas.ac.cn>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 10/10] seqlock: Add do_read_seqcount_retry() in front of seqcount_lockdep_reader_access() in read_seqbegin()
Date: Wed, 1 Sep 2021 19:28:33 -0700 [thread overview]
Message-ID: <54d7cad8-30fc-e96e-bf70-ca371b08b128@gmail.com> (raw)
In-Reply-To: <1630549000-3731606-1-git-send-email-jiasheng@iscas.ac.cn>
On 9/1/21 7:16 PM, jiasheng wrote:
> We have found that in the complied files seqcount_lockdep_reader_access()
> appear more than 20 times, and under at least 90% circumstances
> that do_read_seqcount_retry() and seqcount_lockdep_reader_access()
> appear in pairs.
> For example, they appear together in the irqfd_wakeup()
> of the file complie from 'virt/kvm/eventfd.c'.
> But we have found that in the read_seqbegin(), there is only
> seqcount_lockdep_reader_access() instead of the pair.
> Therefore, we consider that the do_read_seqcount_retry()
> might be forgotten.
>
> Signed-off-by: jiasheng <jiasheng@iscas.ac.cn>
> ---
> include/linux/seqlock.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
> index f61e34f..14169ce 100644
> --- a/include/linux/seqlock.h
> +++ b/include/linux/seqlock.h
> @@ -837,8 +837,10 @@ typedef struct {
> */
> static inline unsigned read_seqbegin(const seqlock_t *sl)
> {
> - unsigned ret = read_seqcount_begin(&sl->seqcount);
> -
> + unsigned int ret;
ret contains garbage at this point.
Calling read_seqcount_retry() with garbage is not going to fly.
Have you really compiled and tested this patch ?
A sane compiler would have complained.
> +
> + if (read_seqcount_retry(&sl->seqcount, ret))
> + ret = read_seqcount_begin(&sl->seqcount);
> kcsan_atomic_next(0); /* non-raw usage, assume closing read_seqretry() */
> kcsan_flat_atomic_begin();
> return ret;
>
next prev parent reply other threads:[~2021-09-02 2:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-02 2:16 jiasheng
2021-09-02 2:28 ` Eric Dumazet [this message]
2021-09-02 3:37 jiasheng
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=54d7cad8-30fc-e96e-bf70-ca371b08b128@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=jiasheng@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome