From: Miklos Szeredi <miklos@szeredi.hu>
To: Bernd Schubert <bschubert@ddn.com>
Cc: "Vivek Goyal" <vgoyal@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
linux-fsdevel@vger.kernel.org,
"Joanne Koong" <joannelkoong@gmail.com>,
"Josef Bacik" <josef@toxicpanda.com>
Subject: Re: [PATCH v3 1/4] fuse: Make the fuse unique value a per-cpu counter
Date: Fri, 4 Apr 2025 14:43:32 +0200 [thread overview]
Message-ID: <CAJfpegtBinmb_D=R0zYWF3AoXscwFugRhCMQKP_aRehq5Y_Wfg@mail.gmail.com> (raw)
In-Reply-To: <20250403-fuse-io-uring-trace-points-v3-1-35340aa31d9c@ddn.com>
On Thu, 3 Apr 2025 at 22:23, Bernd Schubert <bschubert@ddn.com> wrote:
> +/**
> + * Get the next unique ID for a request
> + */
> +static inline u64 fuse_get_unique(struct fuse_iqueue *fiq)
> +{
> + int step = FUSE_REQ_ID_STEP * (task_cpu(current));
> + u64 cntr = this_cpu_inc_return(*fiq->reqctr);
> +
> + return cntr * FUSE_REQ_ID_STEP * NR_CPUS + step;
Thinking a bit... this looks wrong.
The reason is that the task could be migrated to a different CPU
between the task_cpu() and the this_cpu_inc_return(), resulting in a
possibly duplicated value.
This could be fixed with a preempt_disable()/preempt_enable() pair,
but I think it would be cleaner to go with my original idea and
initialize the percpu counters to CPUID and increment by NR_CPU *
FUSE_REQ_ID_STEP when fetching a new value.
Thanks,
Miklos
next prev parent reply other threads:[~2025-04-04 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 20:22 [PATCH v3 0/4] fuse: Improve ftraces, per-cpu req unique and code dup removal Bernd Schubert
2025-04-03 20:22 ` [PATCH v3 1/4] fuse: Make the fuse unique value a per-cpu counter Bernd Schubert
2025-04-04 12:43 ` Miklos Szeredi [this message]
2025-04-04 13:19 ` Bernd Schubert
2025-04-03 20:22 ` [PATCH v3 2/4] fuse: Set request unique on allocation Bernd Schubert
2025-04-03 20:22 ` [PATCH v3 3/4] fuse: {io-uring} Avoid _send code dup Bernd Schubert
2025-04-03 20:22 ` [PATCH v3 4/4] fuse: fine-grained request ftraces Bernd Schubert
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='CAJfpegtBinmb_D=R0zYWF3AoXscwFugRhCMQKP_aRehq5Y_Wfg@mail.gmail.com' \
--to=miklos@szeredi.hu \
--cc=bschubert@ddn.com \
--cc=eperezma@redhat.com \
--cc=joannelkoong@gmail.com \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=vgoyal@redhat.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 NNTP newsgroup(s).