2007-11-20 01:19:09

by Christoph Lameter

[permalink] [raw]
Subject: [rfc 18/45] cpu alloc: XFS counters

Also remove the useless zeroing after allocation. Allocpercpu already
zeroed the objects.

Signed-off-by: Christoph Lameter <[email protected]>
---
fs/xfs/xfs_mount.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)

Index: linux-2.6/fs/xfs/xfs_mount.c
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_mount.c 2007-11-15 21:17:24.467654585 -0800
+++ linux-2.6/fs/xfs/xfs_mount.c 2007-11-15 21:25:32.643904117 -0800
@@ -1924,7 +1924,7 @@ xfs_icsb_cpu_notify(

mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier);
cntp = (xfs_icsb_cnts_t *)
- per_cpu_ptr(mp->m_sb_cnts, (unsigned long)hcpu);
+ CPU_PTR(mp->m_sb_cnts, (unsigned long)hcpu);
switch (action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
@@ -1976,10 +1976,7 @@ int
xfs_icsb_init_counters(
xfs_mount_t *mp)
{
- xfs_icsb_cnts_t *cntp;
- int i;
-
- mp->m_sb_cnts = alloc_percpu(xfs_icsb_cnts_t);
+ mp->m_sb_cnts = CPU_ALLOC(xfs_icsb_cnts_t, GFP_KERNEL | __GFP_ZERO);
if (mp->m_sb_cnts == NULL)
return -ENOMEM;

@@ -1989,11 +1986,6 @@ xfs_icsb_init_counters(
register_hotcpu_notifier(&mp->m_icsb_notifier);
#endif /* CONFIG_HOTPLUG_CPU */

- for_each_online_cpu(i) {
- cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
- memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
- }
-
mutex_init(&mp->m_icsb_mutex);

/*
@@ -2026,7 +2018,7 @@ xfs_icsb_destroy_counters(
{
if (mp->m_sb_cnts) {
unregister_hotcpu_notifier(&mp->m_icsb_notifier);
- free_percpu(mp->m_sb_cnts);
+ CPU_FREE(mp->m_sb_cnts);
}
mutex_destroy(&mp->m_icsb_mutex);
}
@@ -2056,7 +2048,7 @@ xfs_icsb_lock_all_counters(
int i;

for_each_online_cpu(i) {
- cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ cntp = (xfs_icsb_cnts_t *)CPU_PTR(mp->m_sb_cnts, i);
xfs_icsb_lock_cntr(cntp);
}
}
@@ -2069,7 +2061,7 @@ xfs_icsb_unlock_all_counters(
int i;

for_each_online_cpu(i) {
- cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ cntp = (xfs_icsb_cnts_t *)CPU_PTR(mp->m_sb_cnts, i);
xfs_icsb_unlock_cntr(cntp);
}
}
@@ -2089,7 +2081,7 @@ xfs_icsb_count(
xfs_icsb_lock_all_counters(mp);

for_each_online_cpu(i) {
- cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ cntp = (xfs_icsb_cnts_t *)CPU_PTR(mp->m_sb_cnts, i);
cnt->icsb_icount += cntp->icsb_icount;
cnt->icsb_ifree += cntp->icsb_ifree;
cnt->icsb_fdblocks += cntp->icsb_fdblocks;
@@ -2167,7 +2159,7 @@ xfs_icsb_enable_counter(

xfs_icsb_lock_all_counters(mp);
for_each_online_cpu(i) {
- cntp = per_cpu_ptr(mp->m_sb_cnts, i);
+ cntp = CPU_PTR(mp->m_sb_cnts, i);
switch (field) {
case XFS_SBS_ICOUNT:
cntp->icsb_icount = count + resid;
@@ -2307,7 +2299,7 @@ xfs_icsb_modify_counters(
might_sleep();
again:
cpu = get_cpu();
- icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu);
+ icsbp = (xfs_icsb_cnts_t *)CPU_PTR(mp->m_sb_cnts, cpu);

/*
* if the counter is disabled, go to slow path

--


2007-11-20 08:12:45

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [rfc 18/45] cpu alloc: XFS counters

On Mon, Nov 19, 2007 at 05:11:50PM -0800, [email protected] wrote:
> Also remove the useless zeroing after allocation. Allocpercpu already
> zeroed the objects.

You still haven't answered my comment to the last iteration.

2007-11-20 20:38:43

by Christoph Lameter

[permalink] [raw]
Subject: Re: [rfc 18/45] cpu alloc: XFS counters

On Tue, 20 Nov 2007, Christoph Hellwig wrote:

> On Mon, Nov 19, 2007 at 05:11:50PM -0800, [email protected] wrote:
> > Also remove the useless zeroing after allocation. Allocpercpu already
> > zeroed the objects.
>
> You still haven't answered my comment to the last iteration.

And you have not read the discussion on that subject in the prior
iteration between Peter Zilkstra and me.


2007-11-21 04:47:44

by David Chinner

[permalink] [raw]
Subject: Re: [rfc 18/45] cpu alloc: XFS counters

On Tue, Nov 20, 2007 at 12:38:29PM -0800, Christoph Lameter wrote:
> On Tue, 20 Nov 2007, Christoph Hellwig wrote:
>
> > On Mon, Nov 19, 2007 at 05:11:50PM -0800, [email protected] wrote:
> > > Also remove the useless zeroing after allocation. Allocpercpu already
> > > zeroed the objects.
> >
> > You still haven't answered my comment to the last iteration.
>
> And you have not read the discussion on that subject in the prior
> iteration between Peter Zilkstra and me.

Seeing as I didn't notice this patchest changed XFS (where's the cc?)
until I saw hch's question I'd appreciate a pointer to that discussion
as it's long been deleted from my mailbox.

FWIW, I happen to agree with Christoph (hch) that the shouting
macros are an ugly step backwards, esp. given that is replacing:

#define per_cpu_ptr(ptr, cpu) percpu_ptr((ptr), (cpu))

a set of lowercase macros....

Cheers,

Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group

2007-11-21 04:50:26

by Christoph Lameter

[permalink] [raw]
Subject: Re: [rfc 18/45] cpu alloc: XFS counters

On Wed, 21 Nov 2007, David Chinner wrote:

> Seeing as I didn't notice this patchest changed XFS (where's the cc?)
> until I saw hch's question I'd appreciate a pointer to that discussion
> as it's long been deleted from my mailbox.

http://marc.info/?t=119438263500009&r=2&w=2