linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Minchan Kim <minchan@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] zram: switch to non-atomic entry locking
Date: Fri, 24 Jan 2025 14:06:40 +0900	[thread overview]
Message-ID: <nzna4hdscbx4ktlh27ndoxkcrv2pvy5kruytyms7pzefyymlhv@3q6ivuaa4sz5> (raw)
In-Reply-To: <20250122055831.3341175-2-senozhatsky@chromium.org>

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;


  reply	other threads:[~2025-01-24  5:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22  5:57 [PATCH 0/7] zram: preemptible writes and occasionally preemptible reads Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 1/7] zram: switch to non-atomic entry locking Sergey Senozhatsky
2025-01-24  5:06   ` Sergey Senozhatsky [this message]
2025-01-24 10:30   ` Hillf Danton
2025-01-24 11:03     ` Sergey Senozhatsky
2025-01-24 11:09       ` Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 2/7] zram: do not use per-CPU compression streams Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 3/7] zram: remove two-staged handle allocation Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 4/7] zram: permit reclaim in zstd custom allocator Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 5/7] zram: permit reclaim in recompression handle allocation Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 6/7] zram: remove writestall zram_stats member Sergey Senozhatsky
2025-01-22  5:57 ` [PATCH 7/7] zram: unlock slot bucket during recompression Sergey Senozhatsky

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=nzna4hdscbx4ktlh27ndoxkcrv2pvy5kruytyms7pzefyymlhv@3q6ivuaa4sz5 \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    /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