mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: dhowells@redhat.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org,
	"Robert P. J. Day" <rpjday@crashcourse.ca>
Subject: Re: [PATCH] Fix order_base_2(0)
Date: Thu, 15 Dec 2011 00:33:44 +0000	[thread overview]
Message-ID: <24657.1323909224@redhat.com> (raw)
In-Reply-To: <CA+55aFxEszjub9-MJD0irFs8y3hzGe3Ph=7RqWfkJ-0jKFtCeA@mail.gmail.com>

Linus Torvalds <torvalds@linux-foundation.org> wrote:

> Does anybody actually *want* order_base_2(0)?

There aren't actually that many users:

| arch/mips/include/asm/mach-powertv/ioremap.h:#define _IOR_OFFSET_WIDTH(n)    (1 << order_base_2(n))

Doesn't look like it should ever be 0.  In fact, this looks like a case for
using roundup_pow_of_two() directly.

| arch/powerpc/platforms/pseries/iommu.c:       len = order_base_2(max_addr);

Not sure.  Doesn't look likely, but can memory_hotplug_max() be 0 if hotplug
is not supported?

| arch/x86/kvm/x86.c:   return hash_32(gfn & 0xffffffff, order_base_2(ASYNC_PF_PER_VCPU));

Constant 64.  Can't be 0.

| fs/ext4/indirect.c:   blk_bits = order_base_2(lblock);

lblock *could* perhaps be 0.  Being negative is checked for, but not for it
being 0.

| fs/ext4/mballoc.c:    int blocksize_bits = order_base_2(size);
| fs/jbd2/journal.c:    int i = order_base_2(size) - 10;

Can't be 0.

| fs/jbd2/journal.c:    int i = order_base_2(size) - 10;

Hmmm...  Can jbd2_alloc() be given a 0 size?  (Or jbd2_free() for that matter)

| mm/percpu-km.c:       pages = alloc_pages(GFP_KERNEL, order_base_2(nr_pages));
| mm/percpu-km.c:               __free_pages(chunk->data, order_base_2(nr_pages));

Can pcpu_group_sizes[0] be less than PAGE_SIZE?

I can't tell from a cursory inspection of pcpu_setup_first_chunk().

In fact, pcpu_create_chunk() could do order_base_2() then subtract PAGE_SHIFT
rather than shifting and then taking the log.

David

  parent reply	other threads:[~2011-12-15  0:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 11:40 David Howells
2011-12-14 23:55 ` Linus Torvalds
2011-12-15  0:33 ` David Howells [this message]
2011-12-18  7:15 ` Milton Miller

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=24657.1323909224@redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpjday@crashcourse.ca \
    --cc=torvalds@linux-foundation.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

Powered by JetHome