linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Waiman Long <Waiman.Long@hpe.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	Christoph Lameter <cl@linux.com>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	Scott J Norton <scott.norton@hpe.com>,
	Douglas Hatch <doug.hatch@hpe.com>,
	Toshimitsu Kani <toshi.kani@hpe.com>
Subject: Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures
Date: Fri, 8 Apr 2016 12:47:47 -0400	[thread overview]
Message-ID: <20160408164747.GM24661@htj.duckdns.org> (raw)
In-Reply-To: <1460132182-11690-3-git-send-email-Waiman.Long@hpe.com>

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

  reply	other threads:[~2016-04-08 16:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-08 16:16 [PATCH v2 0/4] ext4: Improve parallel I/O performance on NVDIMM Waiman Long
2016-04-08 16:16 ` [PATCH v2 1/4] percpu_stats: Simple per-cpu statistics count helper functions Waiman Long
2016-04-08 16:49   ` kbuild test robot
2016-04-08 17:45   ` kbuild test robot
2016-04-08 16:16 ` [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures Waiman Long
2016-04-08 16:47   ` Tejun Heo [this message]
2016-04-08 17:32     ` Waiman Long
2016-04-08 17:46       ` Tejun Heo
2016-04-08 18:45         ` Waiman Long
2016-04-11 22:17           ` Tejun Heo
2016-04-12 18:15             ` Waiman Long
2016-04-08 16:16 ` [PATCH v2 3/4] ext4: Pass in DIO_SKIP_DIO_COUNT flag if inode_dio_begin() called Waiman Long
2016-04-08 16:16 ` [PATCH v2 4/4] ext4: Make cache hits/misses per-cpu counts Waiman Long

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=20160408164747.GM24661@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=Waiman.Long@hpe.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=cl@linux.com \
    --cc=doug.hatch@hpe.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scott.norton@hpe.com \
    --cc=toshi.kani@hpe.com \
    --cc=tytso@mit.edu \
    /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).