From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: willy@infradead.org, wei.w.wang@intel.com
Cc: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org,
kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com,
mhocko@kernel.org, akpm@linux-foundation.org,
mawilcox@microsoft.com
Subject: Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations
Date: Thu, 21 Dec 2017 23:37:49 +0900 [thread overview]
Message-ID: <201712212337.JFC57368.tLFOJFVSFHMOOQ@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20171221141805.GA27695@bombadil.infradead.org>
Matthew Wilcox wrote:
> > +/**
> > + * xb_find_set - find the next set bit in a range of bits
> > + * @xb: the xbitmap to search from
> > + * @offset: the offset in the range to start searching
> > + * @size: the size of the range
> > + *
> > + * Returns: the found bit or, @size if no set bit is found.
> > + */
> > +unsigned long xb_find_set(struct xb *xb, unsigned long size,
> > + unsigned long offset)
> > +{
> > + struct radix_tree_root *root = &xb->xbrt;
> > + struct radix_tree_node *node;
> > + void __rcu **slot;
> > + struct ida_bitmap *bitmap;
> > + unsigned long index = offset / IDA_BITMAP_BITS;
> > + unsigned long index_end = size / IDA_BITMAP_BITS;
> > + unsigned long bit = offset % IDA_BITMAP_BITS;
> > +
> > + if (unlikely(offset >= size))
> > + return size;
> > +
> > + while (index <= index_end) {
> > + unsigned long ret;
> > + unsigned int nbits = size - index * IDA_BITMAP_BITS;
> > +
> > + bitmap = __radix_tree_lookup(root, index, &node, &slot);
> > +
> > + if (!node && !bitmap)
> > + return size;
> > +
> > + if (bitmap) {
> > + if (nbits > IDA_BITMAP_BITS)
> > + nbits = IDA_BITMAP_BITS;
> > +
> > + ret = find_next_bit(bitmap->bitmap, nbits, bit);
> > + if (ret != nbits)
> > + return ret + index * IDA_BITMAP_BITS;
> > + }
> > + bit = 0;
> > + index++;
> > + }
> > +
> > + return size;
> > +}
> > +EXPORT_SYMBOL(xb_find_set);
>
> This is going to be slower than the implementation I sent yesterday. If I
> call:
> xb_init(xb);
> xb_set_bit(xb, ULONG_MAX);
> xb_find_set(xb, ULONG_MAX, 0);
>
> it's going to call __radix_tree_lookup() 16 quadrillion times.
> My implementation will walk the tree precisely once.
>
Yes. Wei's patch still can not work.
We should start reviewing Matthew's implementation.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-12-21 14:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 2:30 Wei Wang
2017-12-21 14:18 ` Matthew Wilcox
2017-12-21 14:37 ` Tetsuo Handa [this message]
2017-12-22 8:45 ` Wei Wang
2017-12-21 21:03 ` Matthew Wilcox
2017-12-22 8:49 ` Wei Wang
2018-01-02 14:09 ` Matthew Wilcox
2018-01-03 8:56 ` Wei Wang
2017-12-23 2:59 ` Tetsuo Handa
2017-12-23 3:29 ` Matthew Wilcox
2017-12-23 14:33 ` Tetsuo Handa
2017-12-23 14:58 ` Matthew Wilcox
2017-12-24 7:31 ` Wei Wang
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=201712212337.JFC57368.tLFOJFVSFHMOOQ@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=akpm@linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.com \
--cc=mhocko@kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.w.wang@intel.com \
--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