From: Eric Dumazet <eric.dumazet@gmail.com>
To: Nick Piggin <npiggin@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@ZenIV.linux.org.uk>,
Stephen Rothwell <sfr@canb.auug.org.au>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [patch] fs: scale vfsmount refcount (was Re: rcu-walk and dcache scaling tree update and status)
Date: Mon, 13 Dec 2010 08:25:13 +0100 [thread overview]
Message-ID: <1292225113.18698.22.camel@edumazet-laptop> (raw)
In-Reply-To: <20101213024217.GC6522@amd>
Le lundi 13 décembre 2010 à 13:42 +1100, Nick Piggin a écrit :
> + */
> +static inline void add_mnt_count(struct vfsmount *mnt, int n)
maybe name it __add_mnt_count() (should be called with preempt off)
> +{
> +#ifdef CONFIG_SMP
> + (*per_cpu_ptr(mnt->mnt_count, smp_processor_id())) += n;
__this_cpu_add(mnt->mnt_count, n);
> +#else
> + mnt->mnt_count += n;
> +#endif
> +}
and define a preempt safe version :
static inline void __add_mnt_count(struct vfsmount *mnt, int n)
{
#ifdef CONFIG_SMP
__this_cpu_add(mnt->mnt_count, n);
#else
mnt->mnt_count += n;
#endif
}
static inline void add_mnt_count(struct vfsmount *mnt, int n)
{
#ifdef CONFIG_SMP
this_cpu_add(mnt->mnt_count, n);
#else
preempt_disable();
mnt->mnt_count += n;
preempt_enable();
#endif
}
> +
> +static inline void set_mnt_count(struct vfsmount *mnt, int n)
> +{
> +#ifdef CONFIG_SMP
> + preempt_disable();
> + (*per_cpu_ptr(mnt->mnt_count, smp_processor_id())) = n;
> + preempt_enable();
last 3 lines can be replaced by :
this_cpu_write(mnt->mnt_count, n);
> +#else
> + mnt->mnt_count = n;
> +#endif
> +}
> +
> #ifdef CONFIG_SMP
> int __percpu *mnt_writers;
> + int __percpu *mnt_count;
> #else
> int mnt_writers;
> + int mnt_count;
> #endif
You could use a struct and one per cpu allocation to use one cache line
for both objects :
struct mnt_counters {
int writers;
int count;
};
...
#ifdef CONFIG_SMP
struct mnt_counters __percpu *mnt_counters;
#else
struct mnt_counters mnt_counters;
#endif
This would use one pointer instead of two in SMP
next prev parent reply other threads:[~2010-12-13 7:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-13 2:37 rcu-walk and dcache scaling tree update and status Nick Piggin
2010-12-13 2:42 ` [patch] fs: scale vfsmount refcount (was Re: rcu-walk and dcache scaling tree update and status) Nick Piggin
2010-12-13 3:31 ` Nick Piggin
2010-12-13 3:43 ` Nick Piggin
2010-12-13 7:25 ` Eric Dumazet [this message]
2010-12-13 8:33 ` Nick Piggin
2010-12-14 12:40 ` Nick Piggin
2010-12-15 8:16 ` Andreas Dilger
2010-12-15 10:24 ` Nick Piggin
2010-12-13 2:53 ` rcu-walk and dcache scaling tree update and status Ed Tomlinson
2010-12-13 2:59 ` Nick Piggin
2010-12-13 3:45 ` Stephen Rothwell
2010-12-13 3:50 ` Nick Piggin
2010-12-13 3:40 ` Stephen Rothwell
2010-12-13 3:48 ` Nick Piggin
2010-12-14 0:03 ` Stephen Rothwell
2010-12-14 0:16 ` Stephen Rothwell
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=1292225113.18698.22.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@kernel.dk \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/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
all inboxes | Powered by JetHome®