Re: [PATCH v3 1/4] fuse: Make the fuse unique value a per-cpu counter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 3 Apr 2025 at 22:23, Bernd Schubert <bschubert@xxxxxxx> 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux