Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374361

Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures
Date 2016-04-08 18:50 +0200
Message-ID <rlHLA-6M8-11@gated-at.bofh.it> (permalink)
References <rlHiy-6xv-5@gated-at.bofh.it> <rlHiy-6xv-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello, Waiman.

On Fri, Apr 08, 2016 at 12:16:20PM -0400, Waiman Long wrote:
> +/**
> + * __percpu_stats_add - add given count to percpu value
> + * @pcs : Pointer to percpu_stats structure
> + * @stat: The statistics count that needs to be updated
> + * @cnt:  The value to be added to the statistics count
> + */
> +void __percpu_stats_add(struct percpu_stats *pcs, int stat, int cnt)
> +{
> +	/*
> +	 * u64_stats_update_begin/u64_stats_update_end alone are not safe
> +	 * against recursive add on the same CPU caused by interrupt.
> +	 * So we need to set the PCPU_STAT_INTSAFE flag if this is required.
> +	 */
> +	if (IS_STATS64(pcs)) {
> +		uint64_t *pstats64;
> +		unsigned long flags;
> +
> +		pstats64 = get_cpu_ptr(pcs->stats64);
> +		if (pcs->flags & PCPU_STAT_INTSAFE)
> +			local_irq_save(flags);
> +
> +		u64_stats_update_begin(&pcs->sync);
> +		pstats64[stat] += cnt;
> +		u64_stats_update_end(&pcs->sync);
> +
> +		if (pcs->flags & PCPU_STAT_INTSAFE)
> +			local_irq_restore(flags);
> +
> +		put_cpu_ptr(pcs->stats64);
> +	}
> +}

Heh, that's a handful, and, right, u64_stats needs separate irq
protection.  I'm not sure.  If we have to do the above, it's likely
that it'll perform worse than percpu_counter on 32bits.  On 64bits,
percpu_counter would incur extra preempt_disable/enable() operations
but that comes from it not using this_cpu_add_return().  I wonder
whether it'd be better to either use percpu_counter instead or if
necessary extend it to handle multiple counters.  What do you think?

Thanks.

-- 
tejun

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/4] ext4: Improve parallel I/O performance on NVDIMM Waiman Long <Waiman.Long@hpe.com> - 2016-04-08 18:20 +0200
  [PATCH v2 3/4] ext4: Pass in DIO_SKIP_DIO_COUNT flag if inode_dio_begin() called Waiman Long <Waiman.Long@hpe.com> - 2016-04-08 18:20 +0200
  [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures Waiman Long <Waiman.Long@hpe.com> - 2016-04-08 18:20 +0200
    Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit  architectures Tejun Heo <tj@kernel.org> - 2016-04-08 18:50 +0200
      Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures Waiman Long <waiman.long@hpe.com> - 2016-04-08 19:40 +0200
        Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit  architectures Tejun Heo <tj@kernel.org> - 2016-04-08 19:50 +0200
          Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures Waiman Long <waiman.long@hpe.com> - 2016-04-08 20:50 +0200
            Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit  architectures Tejun Heo <tj@kernel.org> - 2016-04-12 00:20 +0200
              Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures Waiman Long <waiman.long@hpe.com> - 2016-04-12 20:20 +0200
  [PATCH v2 1/4] percpu_stats: Simple per-cpu statistics count helper functions Waiman Long <Waiman.Long@hpe.com> - 2016-04-08 18:20 +0200
    Re: [PATCH v2 1/4] percpu_stats: Simple per-cpu statistics count  helper functions kbuild test robot <lkp@intel.com> - 2016-04-08 18:50 +0200
    Re: [PATCH v2 1/4] percpu_stats: Simple per-cpu statistics count  helper functions kbuild test robot <lkp@intel.com> - 2016-04-08 19:50 +0200

csiph-web