From: David Rientjes <rientjes@google.com>
To: Shaohui Zheng <shaohui.zheng@intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
haicheng.li@linux.intel.com, lethal@linux-sh.org,
Andi Kleen <ak@linux.intel.com>,
dave@linux.vnet.ibm.com, Greg Kroah-Hartman <gregkh@suse.de>,
Haicheng Li <haicheng.li@intel.com>
Subject: Re: [3/7, v9] NUMA Hotplug Emulator: Add node hotplug emulation
Date: Mon, 27 Dec 2010 23:34:45 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.00.1012272241200.23315@chino.kir.corp.google.com> (raw)
In-Reply-To: <20101222162723.72075372.akpm@linux-foundation.org>
On Wed, 22 Dec 2010, Andrew Morton wrote:
> > Index: linux-hpe4/mm/memory_hotplug.c
> > ===================================================================
> > --- linux-hpe4.orig/mm/memory_hotplug.c 2010-11-30 12:40:43.757622001 +0800
> > +++ linux-hpe4/mm/memory_hotplug.c 2010-11-30 14:02:33.877622002 +0800
> > @@ -924,3 +924,63 @@
> > }
> > #endif /* CONFIG_MEMORY_HOTREMOVE */
> > EXPORT_SYMBOL_GPL(remove_memory);
> > +
> > +#ifdef CONFIG_DEBUG_FS
> > +#include <linux/debugfs.h>
> > +
> > +static struct dentry *memhp_debug_root;
> > +
> > +static ssize_t add_node_store(struct file *file, const char __user *buf,
> > + size_t count, loff_t *ppos)
> > +{
> > + nodemask_t mask;
>
> NODEMASK_ALLOC()?
>
> > + u64 start, size;
> > + char buffer[64];
> > + char *p;
> > + int nid;
> > + int ret;
> > +
> > + memset(buffer, 0, sizeof(buffer));
> > + if (count > sizeof(buffer) - 1)
> > + count = sizeof(buffer) - 1;
>
> This will cause the write to return a smaller number than `count': a
> short write. Some userspace code may then decide to write the
> remainder of the data (whcih is the correct way to use the write()
> syscall).
>
> Could be a bit dangerous, and perhaps simply declaring an error if too
> much data was written would be a better approach.
>
> > + if (copy_from_user(buffer, buf, count))
> > + return -EFAULT;
> > +
> > + size = memparse(buffer, &p);
> > + if (size < (PAGES_PER_SECTION << PAGE_SHIFT))
>
> PAGES_PER_SECTION has type unsigned long, so the rhs of this comparison
> might overflow on 32-bit, should anyone ever try to use this code on
> 32-bit.
>
> otoh the compiler might do it as 64-bit because the lhs is 64-bit. Not
> sure.
>
> > + return -EINVAL;
> > + if (*p != '@')
> > + return -EINVAL;
> > +
> > + start = simple_strtoull(p + 1, NULL, 0);
>
> You disagreed with checkpatch?
>
> > + nodes_andnot(mask, node_possible_map, node_online_map);
> > + nid = first_node(mask);
> > + if (nid == MAX_NUMNODES)
> > + return -ENOMEM;
> > +
> > + ret = add_memory(nid, start, size);
> > + return ret ? ret : count;
> > +}
> > +
> > +static const struct file_operations add_node_file_ops = {
> > + .write = add_node_store,
> > + .llseek = generic_file_llseek,
> > +};
> > +
> > +static int __init node_debug_init(void)
> > +{
> > + if (!memhp_debug_root)
> > + memhp_debug_root = debugfs_create_dir("mem_hotplug", NULL);
> > + if (!memhp_debug_root)
> > + return -ENOMEM;
> > +
> > + if (!debugfs_create_file("add_node", S_IWUSR, memhp_debug_root,
> > + NULL, &add_node_file_ops))
> > + return -ENOMEM;
> > +
> > + return 0;
> > +}
> > +
> > +module_init(node_debug_init);
> > +#endif /* CONFIG_DEBUG_FS */
Shaohui, I'll reply to this message with an updated version of this patch
to address Andrew's comments. You can merge it into your series or Andrew
can take it seperately (although it doesn't do much good without "x86: add
numa=possible command line option" unless you have hotpluggable SRAT
entries and CONFIG_ACPI_NUMA).
--
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>
next prev parent reply other threads:[~2010-12-28 7:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 7:31 [0/7, v9] NUMA Hotplug Emulator (v9) shaohui.zheng
2010-12-10 7:31 ` [1/7, v9] NUMA Hotplug Emulator: Documentation shaohui.zheng
2010-12-10 7:31 ` [2/7, v9] NUMA Hotplug Emulator: Add numa=possible option shaohui.zheng
2010-12-23 0:27 ` Andrew Morton
2010-12-23 1:14 ` David Rientjes
2010-12-10 7:31 ` [3/7, v9] NUMA Hotplug Emulator: Add node hotplug emulation shaohui.zheng
2010-12-23 0:27 ` Andrew Morton
2010-12-23 1:38 ` David Rientjes
2010-12-23 2:20 ` Andrew Morton
2010-12-28 7:34 ` David Rientjes [this message]
2010-12-28 7:34 ` [patch] mm: add " David Rientjes
2010-12-29 2:31 ` [3/7, v9] NUMA Hotplug Emulator: Add " Zheng, Shaohui
2010-12-10 7:31 ` [4/7, v9] NUMA Hotplug Emulator: Abstract cpu register functions shaohui.zheng
2010-12-10 7:31 ` [5/7, v9] NUMA Hotplug Emulator: Support cpu probe/release in x86_64 shaohui.zheng
2010-12-16 16:25 ` Eric B Munson
2010-12-16 23:34 ` Shaohui Zheng
2010-12-23 0:27 ` Andrew Morton
2010-12-23 1:34 ` Shaohui Zheng
2010-12-23 3:21 ` Andrew Morton
2010-12-23 2:24 ` Shaohui Zheng
2010-12-23 5:28 ` Andrew Morton
2010-12-23 4:30 ` Shaohui Zheng
2010-12-10 7:31 ` [6/7, v9] NUMA Hotplug Emulator: Fake CPU socket with logical CPU on x86 shaohui.zheng
2010-12-23 0:27 ` Andrew Morton
2010-12-23 5:10 ` Shaohui Zheng
2010-12-10 7:31 ` [7/7, v9] NUMA Hotplug Emulator: Implement per-node add_memory debugfs interface shaohui.zheng
2010-12-23 0:27 ` Andrew Morton
2010-12-23 2:00 ` Shaohui Zheng
2011-02-22 22:31 ` [0/7, v9] NUMA Hotplug Emulator (v9) David Rientjes
2011-02-23 3:29 ` Haicheng Li
2011-02-23 5:29 ` Zhang, Yang Z
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=alpine.DEB.2.00.1012272241200.23315@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=gregkh@suse.de \
--cc=haicheng.li@intel.com \
--cc=haicheng.li@linux.intel.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shaohui.zheng@intel.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