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]
Message-ID: <nzna4hdscbx4ktlh27ndoxkcrv2pvy5kruytyms7pzefyymlhv@3q6ivuaa4sz5>
Date: Fri, 24 Jan 2025 14:06:40 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, 
	Minchan Kim <minchan@...nel.org>, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/7] zram: switch to non-atomic entry locking

On (25/01/22 14:57), Sergey Senozhatsky wrote:
[..]
>  static bool zram_meta_alloc(struct zram *zram, u64 disksize)
>  {
> -	size_t num_pages, index;
> +	size_t num_ents, index;
>  
> -	num_pages = disksize >> PAGE_SHIFT;
> -	zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table)));
> +	num_ents = disksize >> PAGE_SHIFT;
> +	zram->table = vzalloc(array_size(num_ents, sizeof(*zram->table)));
>  	if (!zram->table)
> -		return false;
> +		goto error;
> +
> +	num_ents /= ZRAM_PAGES_PER_BUCKET_LOCK;
> +	zram->locks = vzalloc(array_size(num_ents, sizeof(*zram->locks)));

This better use ceil().  I'm working on v2.

---

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 0413438e4500..098e86fe70a5 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1486,7 +1486,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
 	if (!zram->table)
 		goto error;
 
-	num_ents /= ZRAM_PAGES_PER_BUCKET_LOCK;
+	num_ents = DIV_ROUND_UP(num_ents, ZRAM_PAGES_PER_BUCKET_LOCK);
 	zram->locks = vzalloc(array_size(num_ents, sizeof(*zram->locks)));
 	if (!zram->locks)
 		goto error;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ