lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTi=9VmhTY2y06rG28Bn_m9Gu7wMx4go74OsZTJEz@mail.gmail.com>
Date:	Mon, 13 Dec 2010 19:33:36 +1100
From:	Nick Piggin <npiggin@...il.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	Nick Piggin <npiggin@...nel.dk>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Al Viro <viro@...iv.linux.org.uk>,
	Stephen Rothwell <sfr@...b.auug.org.au>,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [patch] fs: scale vfsmount refcount (was Re: rcu-walk and dcache
 scaling tree update and status)

On Mon, Dec 13, 2010 at 6:25 PM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> 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
> }

That looks good, thanks.


>> +
>> +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);

Yep, thanks.


>> +#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

Yes that's a good point too.

Thanks,
Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ