mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Tang Chen <tangchen@cn.fujitsu.com>,
	Yinghai Lu <yinghai@kernel.org>
Subject: Re: [RFC] mm: memblock: change default cnt for regions from 1 to 0
Date: Mon, 27 Oct 2014 10:17:30 -0400	[thread overview]
Message-ID: <20141027141730.GL4436@htj.dyndns.org> (raw)
In-Reply-To: <20141023121840.f88439912f23a3c2a01eb54f@linux-foundation.org>

Hello,

On Thu, Oct 23, 2014 at 12:18:40PM -0700, Andrew Morton wrote:
> On Thu, 23 Oct 2014 17:56:53 +0100 Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote:
> 
> > The default region counts are set to 1 with a comment saying empty
> > dummy entry.
> > 
> > If this is a dummy entry, should this be changed to 0?

My memory is hazy now but I'm pretty sure there's a bunch of stuff
assuming that the array is never empty.

> > We have faced this in mips/kernel/setup.c arch_mem_init.
> > 
> > cma uses memblock. But even with cma disabled.
> > The for_each_memblock(reserved, reg) goes inside the loop.
> > Even without any reserved regions.

Does that matter?  It's a zero-length reservation.

> > Traced it to the following, when the macro
> > for_each_memblock(memblock_type, region) is used.
> > 
> > It expands to add the cnt variable.
> > 
> > for (region = memblock.memblock_type.regions; 		\
> > 	region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
> > 	region++)
> > 
> > In the corner case, that there are no reserved regions.
> > Due to the default 1 value of cnt.
> > The loop under for_each_memblock still runs once.
> > 
> > Even when there is no reserved region.
> > 
> > Is this by design? or unintentional?

It's by design.

> > It might be that this loop runs an extra time every instance out there?

The first actual entry replaces the dummy one and the last removal
makes the entry dummy again, so the dummy one exists iff that's the
only entry.  I don't recall the exact details right now but the choice
was an intentional one.

Thanks.

-- 
tejun

  reply	other threads:[~2014-10-27 14:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 16:56 Zubair Lutfullah Kakakhel
2014-10-23 19:18 ` Andrew Morton
2014-10-27 14:17   ` Tejun Heo [this message]
2014-10-27 14:38     ` Zubair Lutfullah Kakakhel

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=20141027141730.GL4436@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=Zubair.Kakakhel@imgtec.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tangchen@cn.fujitsu.com \
    --cc=yinghai@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

Powered by JetHome