linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, maple-tree@lists.infradead.org
Subject: Re: [PATCH v2 2/5] rosebush: Add new data structure
Date: Wed, 26 Jun 2024 14:07:58 +0100	[thread overview]
Message-ID: <ZnwSrjqHmOzSjShI@casper.infradead.org> (raw)
In-Reply-To: <20240625211803.2750563-3-willy@infradead.org>

On Tue, Jun 25, 2024 at 10:17:57PM +0100, Matthew Wilcox (Oracle) wrote:
> Rosebush is a resizing hash table.  See
> Docuemntation/core-api/rosebush.rst for details.

I thought I had more debugging enabled than I actually did, and
there's some unbalanced RCU locking.  I'll fold this fix in:

diff --git a/lib/rosebush.c b/lib/rosebush.c
index 47106a04d11d..ab2d314cecec 100644
--- a/lib/rosebush.c
+++ b/lib/rosebush.c
@@ -305,13 +305,14 @@ static int rbh_split_bucket(struct rbh *rbh, struct rbh_bucket *bucket,
 	rcu_read_unlock();
 
 	/* XXX: use slab */
+	err = -ENOMEM;
 	buckets[0] = kmalloc(sizeof(*bucket), GFP_KERNEL);
 	if (!buckets[0])
-		return -ENOMEM;
+		goto nomem;
 	buckets[1] = kmalloc(sizeof(*bucket), GFP_KERNEL);
 	if (!buckets[1]) {
 		kfree(buckets[0]);
-		return -ENOMEM;
+		goto nomem;
 	}
 
 //printk("%s: adding buckets %p %p for hash %d\n", __func__, buckets[0], buckets[1], hash);
@@ -320,6 +321,8 @@ static int rbh_split_bucket(struct rbh *rbh, struct rbh_bucket *bucket,
 	table = (struct rbh_table *)(tagged & (tagged + 1));
 	mask = tagged - (unsigned long)table;
 	hash &= mask;
+
+	err = 0;
 	if (rbh_dereference_protected(table->buckets[hash], rbh) != bucket)
 		goto free;
 
@@ -354,14 +357,17 @@ static int rbh_split_bucket(struct rbh *rbh, struct rbh_bucket *bucket,
 	rbh_resize_unlock(rbh);
 	kvfree_rcu_mightsleep(bucket);
 
+	rcu_read_lock();
 	return 0;
 free:
 	rbh_resize_unlock(rbh);
 //printk("%s: freeing bucket %p\n", __func__, bucket);
-	kfree(buckets[0]);
 	kfree(buckets[1]);
+nomem:
+	kfree(buckets[0]);
 
-	return 0;
+	rcu_read_lock();
+	return err;
 }
 
 static int __rbh_insert(struct rbh *rbh, u32 hash, void *p)

  parent reply	other threads:[~2024-06-26 13:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 21:17 [PATCH v2 0/5] Rosebush, a new hash table Matthew Wilcox (Oracle)
2024-06-25 21:17 ` [PATCH v2 1/5] tools: Add kernel stubs needed for rosebush Matthew Wilcox (Oracle)
2024-06-25 21:17 ` [PATCH v2 2/5] rosebush: Add new data structure Matthew Wilcox (Oracle)
2024-06-25 23:36   ` Dr. David Alan Gilbert
2024-06-26 13:16     ` Matthew Wilcox
2024-06-26 13:07   ` Matthew Wilcox [this message]
2024-06-29 19:45   ` Markus Elfring
2024-07-01  1:32     ` Matthew Wilcox
2024-07-01  5:21       ` [v2 " Markus Elfring
2024-07-01 14:18         ` Paul E. McKenney
2024-07-02  1:04   ` [PATCH v2 " Bagas Sanjaya
2024-06-25 21:17 ` [PATCH v2 3/5] rosebush: Add test suite Matthew Wilcox (Oracle)
2024-06-28 15:18   ` Pankaj Raghav (Samsung)
2024-06-29  5:13   ` Jeff Johnson
2024-06-25 21:17 ` [PATCH v2 4/5] tools: Add support for running rosebush tests in userspace Matthew Wilcox (Oracle)
2024-06-29  5:15   ` Jeff Johnson
2024-06-25 21:18 ` [PATCH v2 5/5] dcache: Convert to use rosebush Matthew Wilcox (Oracle)

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=ZnwSrjqHmOzSjShI@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maple-tree@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).