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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 30 Jan 2021 01:38:41 -0700
From:   Andreas Dilger <adilger@...ger.ca>
To:     Harshad Shirwadkar <harshadshirwadkar@...il.com>
Cc:     Ext4 Developers List <linux-ext4@...r.kernel.org>,
        Theodore Ts'o <tytso@....edu>,
        Alex Zhuravlev <bzzz@...mcloud.com>,
        Благодаренко Артём 
        <artem.blagodarenko@...il.com>
Subject: Re: [PATCH 2/4] ext4: drop s_mb_bal_lock and convert protected fields
 to atomic

On Jan 29, 2021, at 3:29 PM, Harshad Shirwadkar <harshadshirwadkar@...il.com> wrote:
> 
> s_mb_buddies_generated gets used later in this patch series to
> determine if the cr 0 and cr 1 optimziations should be performed or
> not. Currently, s_mb_buddies_generated is protected under a
> spin_lock. In the allocation path, it is better if we don't depend on
> the lock and instead read the value atomically. In order to do that,
> we drop s_bal_lock altogether and we convert the only two protected
> fields by it s_mb_buddies_generated and s_mb_generation_time to atomic
> type.
> 
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@...il.com>

Reviewed-by: Andreas Dilger <adilger@...ger.ca>

> ---
> fs/ext4/ext4.h    |  5 ++---
> fs/ext4/mballoc.c | 13 +++++--------
> 2 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 64f25ea2fa7a..6dd127942208 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1552,9 +1552,8 @@ struct ext4_sb_info {
> 	atomic_t s_bal_goals;	/* goal hits */
> 	atomic_t s_bal_breaks;	/* too long searches */
> 	atomic_t s_bal_2orders;	/* 2^order hits */
> -	spinlock_t s_bal_lock;
> -	unsigned long s_mb_buddies_generated;
> -	unsigned long long s_mb_generation_time;
> +	atomic_t s_mb_buddies_generated;	/* number of buddies generated */
> +	atomic64_t s_mb_generation_time;
> 	atomic_t s_mb_lost_chunks;
> 	atomic_t s_mb_preallocated;
> 	atomic_t s_mb_discarded;
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 625242e5c683..11c56b0e6f35 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -816,10 +816,8 @@ void ext4_mb_generate_buddy(struct super_block *sb,
> 	clear_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(grp->bb_state));
> 
> 	period = get_cycles() - period;
> -	spin_lock(&sbi->s_bal_lock);
> -	sbi->s_mb_buddies_generated++;
> -	sbi->s_mb_generation_time += period;
> -	spin_unlock(&sbi->s_bal_lock);
> +	atomic_inc(&sbi->s_mb_buddies_generated);
> +	atomic64_add(period, &sbi->s_mb_generation_time);
> }
> 
> /* The buddy information is attached the buddy cache inode
> @@ -2844,7 +2842,6 @@ int ext4_mb_init(struct super_block *sb)
> 
> 
> 	spin_lock_init(&sbi->s_md_lock);
> -	spin_lock_init(&sbi->s_bal_lock);
> 	sbi->s_mb_free_pending = 0;
> 	INIT_LIST_HEAD(&sbi->s_freed_data_list);
> 
> @@ -2980,9 +2977,9 @@ int ext4_mb_release(struct super_block *sb)
> 				atomic_read(&sbi->s_bal_breaks),
> 				atomic_read(&sbi->s_mb_lost_chunks));
> 		ext4_msg(sb, KERN_INFO,
> -		       "mballoc: %lu generated and it took %Lu",
> -				sbi->s_mb_buddies_generated,
> -				sbi->s_mb_generation_time);
> +		       "mballoc: %u generated and it took %llu",
> +				atomic_read(&sbi->s_mb_buddies_generated),
> +				atomic64_read(&sbi->s_mb_generation_time));
> 		ext4_msg(sb, KERN_INFO,
> 		       "mballoc: %u preallocated, %u discarded",
> 				atomic_read(&sbi->s_mb_preallocated),
> --
> 2.30.0.365.g02bc693789-goog
> 


Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ