public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: xarray reserve/release?
Date: Tue, 19 Feb 2019 16:53:49 -0700	[thread overview]
Message-ID: <20190219235349.GA17351@ziepe.ca> (raw)

Hey Matt,

Did you intend that xa_release doesn't work on allocating arrays:

	xa_init_flags(&xa, XA_FLAGS_ALLOC);
	xa_reserve(&xa, 0, GFP_KERNEL);
	WARN_ON(xa_empty(&xa));
	xa_release(&xa, 0);
	WARN_ON(!xa_empty(&xa));

Triggers the second WARN_ON. 

If FLAGS_ALLOC is removed this passes

This creates kind of a confusing / super unexpected situation where 

   xa_for_each (xa, id)
       xa_erase(xa, id);
   WARN_ON(!xa_empty(&xa))

Is not safe with XA_FLAGS_ALLOC??

Seems like at least deserves a documentation note.. Or maybe ALLOC
xa_empty should do something different?

Thanks,
Jason

             reply	other threads:[~2019-02-19 23:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 23:53 Jason Gunthorpe [this message]
2019-02-20  1:26 ` xarray reserve/release? Matthew Wilcox
2019-02-20  3:46   ` Jason Gunthorpe
2019-02-20 17:14     ` Matthew Wilcox
2019-02-20 17:43       ` Jason Gunthorpe
2019-02-20 20:47         ` Matthew Wilcox
2019-02-20 21:18           ` Jason Gunthorpe

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=20190219235349.GA17351@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@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