linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Daniel Kiper <dkiper@net-space.pl>
Cc: ian.campbell@citrix.com, akpm@linux-foundation.org,
	andi.kleen@intel.com, haicheng.li@linux.intel.com,
	fengguang.wu@intel.com, jeremy@goop.org, konrad.wilk@oracle.com,
	dan.magenheimer@oracle.com, v.tolstov@selfip.ru,
	xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH R2 7/7] xen/balloon: Xen memory balloon driver with memory hotplug support
Date: Mon, 03 Jan 2011 14:33:22 -0800	[thread overview]
Message-ID: <1294094002.18937.110.camel@nimitz> (raw)
In-Reply-To: <20101229170702.GL2743@router-fw-old.local.net-space.pl>

On Wed, 2010-12-29 at 18:07 +0100, Daniel Kiper wrote:
> +config XEN_BALLOON_MEMORY_HOTPLUG
> +	bool "Xen memory balloon driver with memory hotplug support"
> +	default n
> +	depends on XEN_BALLOON && MEMORY_HOTPLUG
> +	help
> +	  Xen memory balloon driver with memory hotplug support allows expanding
> +	  memory available for the system above limit declared at system startup.
> +	  It is very useful on critical systems which require long run without
> +	  rebooting.

This might be better phrased as "Memory hotplug support for Xen balloon
driver".  It might otherwise confuse people about whether they're seeing
some kind of choice or an _enhancement_ to the existing driver.

Also, why bother even making this a config option?  What are the
downsides if it was always compiled in?  You could even make it a
non-prompting Kconfig option and just automatically turn it on with
XEN_BALLOON && MEMORY_HOTPLUG.


> +static int allocate_memory_resource(struct resource **r, unsigned long nr_pages)
>  {
> -	unsigned long target = balloon_stats.target_pages;
> +	int rc;
> +	resource_size_t r_min, r_size;
> +
> +	/*
> +	 * Look for first unused memory region starting at page
> +	 * boundary. Skip last memory section created at boot time
> +	 * becuase it may contains unused memory pages with PG_reserved
> +	 * bit not set (online_pages require PG_reserved bit set).
> +	 */
> +
> +	*r = kzalloc(sizeof(struct resource), GFP_KERNEL);
> 
> -	target = min(target,
> -		     balloon_stats.current_pages +
> -		     balloon_stats.balloon_low +
> -		     balloon_stats.balloon_high);
> +	if (!*r)
> +		return -ENOMEM;
> 
> -	return target;
> +	(*r)->name = "System RAM";
> +	(*r)->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
> +	r_min = PFN_PHYS(section_nr_to_pfn(pfn_to_section_nr(balloon_stats.boot_max_pfn) + 1));
> +	r_size = nr_pages << PAGE_SHIFT;
> +
> +	rc = allocate_resource(&iomem_resource, *r, r_size, r_min,
> +					ULONG_MAX, PAGE_SIZE, NULL, NULL);
> +
> +	if (rc < 0) {
> +		kfree(*r);
> +		*r = NULL;
> +	}
> +
> +	return rc;
>  }

The double-pointer stuff here ends up looking a little funky.  Is there
any reason you don't just use ERR_PTRs?  That might look a bit more
sane.

> +static void adjust_memory_resource(struct resource **r, unsigned long nr_pages)
> +{
> +	if ((*r)->end + 1 - (nr_pages << PAGE_SHIFT) == (*r)->start) {
> +		BUG_ON(release_resource(*r) < 0);

In some kernels, people do:

	#define BUG_ON(...) do{}while(0)

to save space.  If anyone ever does that with this code, it'll break
horribly.  It's also hard to read these.  So, please break logic actions
_out_ of the BUG_ON() arguments.

That's repeated in quite a few places in here.  Make sure to go get them
all.

It also isn't evident what this patch set is trying to do until you get
down to this 7/7 patch.  You might want to put a more complete
description in 0/7.

-- Dave

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-01-03 22:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-29 17:07 [PATCH R2 7/7] xen/balloon: Xen memory balloon driver with memory hotplug support Daniel Kiper
2011-01-03 22:33 ` Dave Hansen [this message]
2011-01-11 17:51   ` Daniel Kiper
2011-02-03 15:31   ` Daniel Kiper

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=1294094002.18937.110.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi.kleen@intel.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=dkiper@net-space.pl \
    --cc=fengguang.wu@intel.com \
    --cc=haicheng.li@linux.intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=v.tolstov@selfip.ru \
    --cc=xen-devel@lists.xensource.com \
    /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).