* [PATCH] Show memory section to node relationship in sysfs
@ 2008-09-04 20:22 Gary Hade
2008-09-04 22:14 ` Nish Aravamudan
2008-09-04 22:15 ` Dave Hansen
0 siblings, 2 replies; 13+ messages in thread
From: Gary Hade @ 2008-09-04 20:22 UTC (permalink / raw)
To: linux-mm
Cc: Andrew Morton, Yasunori Goto, Badari Pulavarty, Mel Gorman,
Chris McDermott, Gary Hade
Show memory section to node relationship in sysfs
Add /sys/devices/system/memory/memoryX/node files to show
the node on which each memory section resides.
Signed-off-by: Gary Hade <garyhade@us.ibm.com>
---
Documentation/memory-hotplug.txt | 1 -
drivers/base/memory.c | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
Index: linux-2.6.27-rc5/drivers/base/memory.c
===================================================================
--- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
+++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
@@ -150,6 +150,22 @@
return len;
}
+/*
+ * node on which memory section resides
+ */
+static ssize_t show_mem_node(struct sys_device *dev,
+ struct sysdev_attribute *attr, char *buf)
+{
+ unsigned long start_pfn;
+ int ret;
+ struct memory_block *mem =
+ container_of(dev, struct memory_block, sysdev);
+
+ start_pfn = section_nr_to_pfn(mem->phys_index);
+ ret = pfn_to_nid(start_pfn);
+ return sprintf(buf, "%d\n", ret);
+}
+
int memory_notify(unsigned long val, void *v)
{
return blocking_notifier_call_chain(&memory_chain, val, v);
@@ -278,6 +294,7 @@
static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state);
static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL);
static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL);
+static SYSDEV_ATTR(node, 0444, show_mem_node, NULL);
#define mem_create_simple_file(mem, attr_name) \
sysdev_create_file(&mem->sysdev, &attr_##attr_name)
@@ -368,6 +385,8 @@
ret = mem_create_simple_file(mem, phys_device);
if (!ret)
ret = mem_create_simple_file(mem, removable);
+ if (!ret)
+ ret = mem_create_simple_file(mem, node);
return ret;
}
@@ -413,6 +432,7 @@
mem_remove_simple_file(mem, state);
mem_remove_simple_file(mem, phys_device);
mem_remove_simple_file(mem, removable);
+ mem_remove_simple_file(mem, node);
unregister_memory(mem, section);
return 0;
Index: linux-2.6.27-rc5/Documentation/memory-hotplug.txt
===================================================================
--- linux-2.6.27-rc5.orig/Documentation/memory-hotplug.txt 2008-09-03 14:25:54.000000000 -0700
+++ linux-2.6.27-rc5/Documentation/memory-hotplug.txt 2008-09-03 14:26:15.000000000 -0700
@@ -365,7 +365,6 @@
- allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like
sysctl or new control file.
- showing memory section and physical device relationship.
- - showing memory section and node relationship (maybe good for NUMA)
- showing memory section is under ZONE_MOVABLE or not
- test and make it better memory offlining.
- support HugeTLB page migration and offlining.
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 20:22 [PATCH] Show memory section to node relationship in sysfs Gary Hade
@ 2008-09-04 22:14 ` Nish Aravamudan
2008-09-04 23:31 ` Badari Pulavarty
2008-09-04 22:15 ` Dave Hansen
1 sibling, 1 reply; 13+ messages in thread
From: Nish Aravamudan @ 2008-09-04 22:14 UTC (permalink / raw)
To: Gary Hade
Cc: linux-mm, Andrew Morton, Yasunori Goto, Badari Pulavarty,
Mel Gorman, Chris McDermott
On 9/4/08, Gary Hade <garyhade@us.ibm.com> wrote:
> Show memory section to node relationship in sysfs
>
> Add /sys/devices/system/memory/memoryX/node files to show
> the node on which each memory section resides.
I think this patch needs an additional bit for Documentation/ABI
(might be other parts of /sys/devices/system/memory missing from
there).
Also, I wonder if it might not make more sense to use a symlink here? That is
/sys/devices/system/memory/memoryX/node -> /sys/devices/system/node/nodeY ?
And then we could, potentially, have symlinks returning from the node
side to indicate all memory sections on that node (might be handy for
node offline?):
/sys/devices/system/node/nodeX/memory1 -> /sys/devices/system/memory/memoryY
/sys/devices/system/node/nodeX/memory2 -> /sys/devices/system/memory/memoryZ
Dunno, the latter probably should be a separate patch, but does seem
more like the sysfs behavior (and the number (node or memory section)
should be easily obtained from the symlinks via readlink, as opposed
to cat with the current patch?).
Thanks,
Nish
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 22:14 ` Nish Aravamudan
@ 2008-09-04 23:31 ` Badari Pulavarty
2008-09-05 2:07 ` Gary Hade
0 siblings, 1 reply; 13+ messages in thread
From: Badari Pulavarty @ 2008-09-04 23:31 UTC (permalink / raw)
To: Nish Aravamudan
Cc: Gary Hade, linux-mm, Andrew Morton, Yasunori Goto, Mel Gorman,
Chris McDermott
Nish Aravamudan wrote:
> On 9/4/08, Gary Hade <garyhade@us.ibm.com> wrote:
>
>> Show memory section to node relationship in sysfs
>>
>> Add /sys/devices/system/memory/memoryX/node files to show
>> the node on which each memory section resides.
>>
>
> I think this patch needs an additional bit for Documentation/ABI
> (might be other parts of /sys/devices/system/memory missing from
> there).
>
>
Yes. I added Documentation/ABI for "removable". We should update it for
this too.
> Also, I wonder if it might not make more sense to use a symlink here? That is
>
> /sys/devices/system/memory/memoryX/node -> /sys/devices/system/node/nodeY ?
>
>
Makes sense. Since we already have "node/nodeY", we might as well make
use of it
instead of duplicating it.
> And then we could, potentially, have symlinks returning from the node
> side to indicate all memory sections on that node (might be handy for
> node offline?):
>
> /sys/devices/system/node/nodeX/memory1 -> /sys/devices/system/memory/memoryY
> /sys/devices/system/node/nodeX/memory2 -> /sys/devices/system/memory/memoryZ
>
>
I don't think we need both. Gary wants to do "node removal/offline" and
wants
to find out all the memory sections that belong to nodeX. May be this is a
a better interface. This way, we can quickly get through all the memory
sections
without looking at all the sections. Gary ?
> Dunno, the latter probably should be a separate patch, but does seem
> more like the sysfs behavior (and the number (node or memory section)
> should be easily obtained from the symlinks via readlink, as opposed
> to cat with the current patch?).
>
> Thanks,
> Nish
>
Thanks,
Badari
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 23:31 ` Badari Pulavarty
@ 2008-09-05 2:07 ` Gary Hade
2008-09-05 2:29 ` Yasunori Goto
0 siblings, 1 reply; 13+ messages in thread
From: Gary Hade @ 2008-09-05 2:07 UTC (permalink / raw)
To: Badari Pulavarty
Cc: Nish Aravamudan, Gary Hade, linux-mm, Andrew Morton,
Yasunori Goto, Mel Gorman, Chris McDermott
On Thu, Sep 04, 2008 at 04:31:00PM -0700, Badari Pulavarty wrote:
> Nish Aravamudan wrote:
>> On 9/4/08, Gary Hade <garyhade@us.ibm.com> wrote:
>>
>>> Show memory section to node relationship in sysfs
>>>
>>> Add /sys/devices/system/memory/memoryX/node files to show
>>> the node on which each memory section resides.
>>>
>>
>> I think this patch needs an additional bit for Documentation/ABI
>> (might be other parts of /sys/devices/system/memory missing from
>> there).
>>
>>
> Yes. I added Documentation/ABI for "removable". We should update it for
> this too.
>> Also, I wonder if it might not make more sense to use a symlink here? That is
>>
>> /sys/devices/system/memory/memoryX/node -> /sys/devices/system/node/nodeY ?
>>
>>
> Makes sense. Since we already have "node/nodeY", we might as well make
> use of it
> instead of duplicating it.
>> And then we could, potentially, have symlinks returning from the node
>> side to indicate all memory sections on that node (might be handy for
>> node offline?):
>>
>> /sys/devices/system/node/nodeX/memory1 -> /sys/devices/system/memory/memoryY
>> /sys/devices/system/node/nodeX/memory2 -> /sys/devices/system/memory/memoryZ
>>
>>
> I don't think we need both. Gary wants to do "node removal/offline" and
> wants
> to find out all the memory sections that belong to nodeX. May be this is a
> a better interface. This way, we can quickly get through all the memory
> sections without looking at all the sections. Gary ?
Yes, either way would work fine but I think symlinks in the
/sys/devices/system/node/nodeX directories would make the
script or program driven memory section offlining complete
a little more quickly. However, if we do this we might want to
make the symlink names to match the memory section directory names.
/sys/devices/system/node/nodeX/memoryY -> /sys/devices/system/memory/memoryY
/sys/devices/system/node/nodeX/memoryZ -> /sys/devices/system/memory/memoryZ
Do you or others have a preference?
Thanks,
Gary
--
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503 IBM T/L: 775-4503
garyhade@us.ibm.com
http://www.ibm.com/linux/ltc
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 2:07 ` Gary Hade
@ 2008-09-05 2:29 ` Yasunori Goto
0 siblings, 0 replies; 13+ messages in thread
From: Yasunori Goto @ 2008-09-05 2:29 UTC (permalink / raw)
To: Gary Hade
Cc: Badari Pulavarty, Nish Aravamudan, linux-mm, Andrew Morton,
Mel Gorman, Chris McDermott
> On Thu, Sep 04, 2008 at 04:31:00PM -0700, Badari Pulavarty wrote:
> > Nish Aravamudan wrote:
> >> On 9/4/08, Gary Hade <garyhade@us.ibm.com> wrote:
> >>
> >>> Show memory section to node relationship in sysfs
> >>>
> >>> Add /sys/devices/system/memory/memoryX/node files to show
> >>> the node on which each memory section resides.
> >>>
> >>
> >> I think this patch needs an additional bit for Documentation/ABI
> >> (might be other parts of /sys/devices/system/memory missing from
> >> there).
> >>
> >>
> > Yes. I added Documentation/ABI for "removable". We should update it for
> > this too.
> >> Also, I wonder if it might not make more sense to use a symlink here? That is
> >>
> >> /sys/devices/system/memory/memoryX/node -> /sys/devices/system/node/nodeY ?
> >>
> >>
> > Makes sense. Since we already have "node/nodeY", we might as well make
> > use of it
> > instead of duplicating it.
> >> And then we could, potentially, have symlinks returning from the node
> >> side to indicate all memory sections on that node (might be handy for
> >> node offline?):
> >>
> >> /sys/devices/system/node/nodeX/memory1 -> /sys/devices/system/memory/memoryY
> >> /sys/devices/system/node/nodeX/memory2 -> /sys/devices/system/memory/memoryZ
> >>
> >>
> > I don't think we need both. Gary wants to do "node removal/offline" and
> > wants
> > to find out all the memory sections that belong to nodeX. May be this is a
> > a better interface. This way, we can quickly get through all the memory
> > sections without looking at all the sections. Gary ?
>
> Yes, either way would work fine but I think symlinks in the
> /sys/devices/system/node/nodeX directories would make the
> script or program driven memory section offlining complete
> a little more quickly. However, if we do this we might want to
> make the symlink names to match the memory section directory names.
> /sys/devices/system/node/nodeX/memoryY -> /sys/devices/system/memory/memoryY
> /sys/devices/system/node/nodeX/memoryZ -> /sys/devices/system/memory/memoryZ
Agree. I think this is better way.
Thanks.
--
Yasunori Goto
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 20:22 [PATCH] Show memory section to node relationship in sysfs Gary Hade
2008-09-04 22:14 ` Nish Aravamudan
@ 2008-09-04 22:15 ` Dave Hansen
2008-09-05 0:40 ` Greg KH
2008-09-05 1:00 ` Gary Hade
1 sibling, 2 replies; 13+ messages in thread
From: Dave Hansen @ 2008-09-04 22:15 UTC (permalink / raw)
To: Gary Hade
Cc: linux-mm, Andrew Morton, Yasunori Goto, Badari Pulavarty,
Mel Gorman, Chris McDermott, Greg KH
On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
>
> --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> @@ -150,6 +150,22 @@
> return len;
> }
>
> +/*
> + * node on which memory section resides
> + */
> +static ssize_t show_mem_node(struct sys_device *dev,
> + struct sysdev_attribute *attr, char *buf)
> +{
> + unsigned long start_pfn;
> + int ret;
> + struct memory_block *mem =
> + container_of(dev, struct memory_block, sysdev);
> +
> + start_pfn = section_nr_to_pfn(mem->phys_index);
> + ret = pfn_to_nid(start_pfn);
> + return sprintf(buf, "%d\n", ret);
> +}
I only wonder if this is the "sysfs" way to do it.
I mean, we don't put a file with the PCI id of a device in the device's
sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there,
so we might as well use it.
-- 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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 22:15 ` Dave Hansen
@ 2008-09-05 0:40 ` Greg KH
2008-09-05 1:15 ` Gary Hade
2008-09-05 1:00 ` Gary Hade
1 sibling, 1 reply; 13+ messages in thread
From: Greg KH @ 2008-09-05 0:40 UTC (permalink / raw)
To: Dave Hansen
Cc: Gary Hade, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott
On Thu, Sep 04, 2008 at 03:15:46PM -0700, Dave Hansen wrote:
> On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
> >
> > --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> > +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> > @@ -150,6 +150,22 @@
> > return len;
> > }
> >
> > +/*
> > + * node on which memory section resides
> > + */
> > +static ssize_t show_mem_node(struct sys_device *dev,
> > + struct sysdev_attribute *attr, char *buf)
> > +{
> > + unsigned long start_pfn;
> > + int ret;
> > + struct memory_block *mem =
> > + container_of(dev, struct memory_block, sysdev);
> > +
> > + start_pfn = section_nr_to_pfn(mem->phys_index);
> > + ret = pfn_to_nid(start_pfn);
> > + return sprintf(buf, "%d\n", ret);
> > +}
>
> I only wonder if this is the "sysfs" way to do it.
>
> I mean, we don't put a file with the PCI id of a device in the device's
> sysfs directory. We put a symlink to its place in the bus tree.
>
> Should we just link over to the NUMA node directory? We have it there,
> so we might as well use it.
That sounds reasonable to me. Someone is documenting this new addition
with an entry in Documentation/ABI/, right?
thanks,
greg k-h
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 0:40 ` Greg KH
@ 2008-09-05 1:15 ` Gary Hade
2008-09-05 1:21 ` Greg KH
0 siblings, 1 reply; 13+ messages in thread
From: Gary Hade @ 2008-09-05 1:15 UTC (permalink / raw)
To: Greg KH
Cc: Dave Hansen, Gary Hade, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott
On Thu, Sep 04, 2008 at 05:40:44PM -0700, Greg KH wrote:
> On Thu, Sep 04, 2008 at 03:15:46PM -0700, Dave Hansen wrote:
> > On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
> > >
> > > --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> > > +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> > > @@ -150,6 +150,22 @@
> > > return len;
> > > }
> > >
> > > +/*
> > > + * node on which memory section resides
> > > + */
> > > +static ssize_t show_mem_node(struct sys_device *dev,
> > > + struct sysdev_attribute *attr, char *buf)
> > > +{
> > > + unsigned long start_pfn;
> > > + int ret;
> > > + struct memory_block *mem =
> > > + container_of(dev, struct memory_block, sysdev);
> > > +
> > > + start_pfn = section_nr_to_pfn(mem->phys_index);
> > > + ret = pfn_to_nid(start_pfn);
> > > + return sprintf(buf, "%d\n", ret);
> > > +}
> >
> > I only wonder if this is the "sysfs" way to do it.
> >
> > I mean, we don't put a file with the PCI id of a device in the device's
> > sysfs directory. We put a symlink to its place in the bus tree.
> >
> > Should we just link over to the NUMA node directory? We have it there,
> > so we might as well use it.
>
> That sounds reasonable to me. Someone is documenting this new addition
> with an entry in Documentation/ABI/, right?
Yes, my bad. Revision will add that to Documentation/memory-hotplug.txt
as well as a description of the 'removable' file that Badari mentioned,
if OK to include both in the same patch.
Gary
--
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503 IBM T/L: 775-4503
garyhade@us.ibm.com
http://www.ibm.com/linux/ltc
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 1:15 ` Gary Hade
@ 2008-09-05 1:21 ` Greg KH
2008-09-05 3:18 ` Gary Hade
0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2008-09-05 1:21 UTC (permalink / raw)
To: Gary Hade
Cc: Dave Hansen, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott
On Thu, Sep 04, 2008 at 06:15:00PM -0700, Gary Hade wrote:
> On Thu, Sep 04, 2008 at 05:40:44PM -0700, Greg KH wrote:
> > On Thu, Sep 04, 2008 at 03:15:46PM -0700, Dave Hansen wrote:
> > > On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
> > > >
> > > > --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> > > > +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> > > > @@ -150,6 +150,22 @@
> > > > return len;
> > > > }
> > > >
> > > > +/*
> > > > + * node on which memory section resides
> > > > + */
> > > > +static ssize_t show_mem_node(struct sys_device *dev,
> > > > + struct sysdev_attribute *attr, char *buf)
> > > > +{
> > > > + unsigned long start_pfn;
> > > > + int ret;
> > > > + struct memory_block *mem =
> > > > + container_of(dev, struct memory_block, sysdev);
> > > > +
> > > > + start_pfn = section_nr_to_pfn(mem->phys_index);
> > > > + ret = pfn_to_nid(start_pfn);
> > > > + return sprintf(buf, "%d\n", ret);
> > > > +}
> > >
> > > I only wonder if this is the "sysfs" way to do it.
> > >
> > > I mean, we don't put a file with the PCI id of a device in the device's
> > > sysfs directory. We put a symlink to its place in the bus tree.
> > >
> > > Should we just link over to the NUMA node directory? We have it there,
> > > so we might as well use it.
> >
> > That sounds reasonable to me. Someone is documenting this new addition
> > with an entry in Documentation/ABI/, right?
>
> Yes, my bad. Revision will add that to Documentation/memory-hotplug.txt
> as well as a description of the 'removable' file that Badari mentioned,
> if OK to include both in the same patch.
Care to move the information from memory-hotplug.txt into the proper
place for this kind of stuff (Documentation/ABI for all external kernel
ABIs).
thanks,
greg k-h
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 1:21 ` Greg KH
@ 2008-09-05 3:18 ` Gary Hade
0 siblings, 0 replies; 13+ messages in thread
From: Gary Hade @ 2008-09-05 3:18 UTC (permalink / raw)
To: Greg KH
Cc: Gary Hade, Dave Hansen, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott
On Thu, Sep 04, 2008 at 06:21:10PM -0700, Greg KH wrote:
> On Thu, Sep 04, 2008 at 06:15:00PM -0700, Gary Hade wrote:
> > On Thu, Sep 04, 2008 at 05:40:44PM -0700, Greg KH wrote:
> > > On Thu, Sep 04, 2008 at 03:15:46PM -0700, Dave Hansen wrote:
> > > > On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
> > > > >
> > > > > --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> > > > > +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> > > > > @@ -150,6 +150,22 @@
> > > > > return len;
> > > > > }
> > > > >
> > > > > +/*
> > > > > + * node on which memory section resides
> > > > > + */
> > > > > +static ssize_t show_mem_node(struct sys_device *dev,
> > > > > + struct sysdev_attribute *attr, char *buf)
> > > > > +{
> > > > > + unsigned long start_pfn;
> > > > > + int ret;
> > > > > + struct memory_block *mem =
> > > > > + container_of(dev, struct memory_block, sysdev);
> > > > > +
> > > > > + start_pfn = section_nr_to_pfn(mem->phys_index);
> > > > > + ret = pfn_to_nid(start_pfn);
> > > > > + return sprintf(buf, "%d\n", ret);
> > > > > +}
> > > >
> > > > I only wonder if this is the "sysfs" way to do it.
> > > >
> > > > I mean, we don't put a file with the PCI id of a device in the device's
> > > > sysfs directory. We put a symlink to its place in the bus tree.
> > > >
> > > > Should we just link over to the NUMA node directory? We have it there,
> > > > so we might as well use it.
> > >
> > > That sounds reasonable to me. Someone is documenting this new addition
> > > with an entry in Documentation/ABI/, right?
> >
> > Yes, my bad. Revision will add that to Documentation/memory-hotplug.txt
> > as well as a description of the 'removable' file that Badari mentioned,
> > if OK to include both in the same patch.
>
> Care to move the information from memory-hotplug.txt into the proper
> place for this kind of stuff (Documentation/ABI for all external kernel
> ABIs).
Sorry, I think I got it now. Badari has already documented the
memory section 'removable' file in
Documentation/ABI/testing/sysfs-devices-memory
but descriptions for the other memory section files are not yet
included there. I will make sure this gets fixed.
Gary
--
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503 IBM T/L: 775-4503
garyhade@us.ibm.com
http://www.ibm.com/linux/ltc
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-04 22:15 ` Dave Hansen
2008-09-05 0:40 ` Greg KH
@ 2008-09-05 1:00 ` Gary Hade
2008-09-05 17:42 ` Dave Hansen
1 sibling, 1 reply; 13+ messages in thread
From: Gary Hade @ 2008-09-05 1:00 UTC (permalink / raw)
To: Dave Hansen
Cc: Gary Hade, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott, Greg KH
On Thu, Sep 04, 2008 at 03:15:46PM -0700, Dave Hansen wrote:
> On Thu, 2008-09-04 at 13:22 -0700, Gary Hade wrote:
> >
> > --- linux-2.6.27-rc5.orig/drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700
> > +++ linux-2.6.27-rc5/drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700
> > @@ -150,6 +150,22 @@
> > return len;
> > }
> >
> > +/*
> > + * node on which memory section resides
> > + */
> > +static ssize_t show_mem_node(struct sys_device *dev,
> > + struct sysdev_attribute *attr, char *buf)
> > +{
> > + unsigned long start_pfn;
> > + int ret;
> > + struct memory_block *mem =
> > + container_of(dev, struct memory_block, sysdev);
> > +
> > + start_pfn = section_nr_to_pfn(mem->phys_index);
> > + ret = pfn_to_nid(start_pfn);
> > + return sprintf(buf, "%d\n", ret);
> > +}
>
> I only wonder if this is the "sysfs" way to do it.
>
> I mean, we don't put a file with the PCI id of a device in the device's
> sysfs directory. We put a symlink to its place in the bus tree.
>
> Should we just link over to the NUMA node directory? We have it there,
> so we might as well use it.
Dave, Good comment from both you and Nish.
The "sysfs" way appears to be a bit inconsistent. :)
w/2.6.27-rc5:
elm3a153:~ # ls -ld /sys/devices/pci0000:0f/0000:0f:00.0/numa_node
-r--r--r-- 1 root root 4096 2008-09-04 15:14 /sys/devices/pci0000:0f/0000:0f:00.0/numa_node
elm3a153:~ # cat /sys/devices/pci0000:0f/0000:0f:00.0/numa_node
1
I think this may have been the model I was trying to follow.
Also, Using your PCI id example there are already instances of
PCI address containing files in the sysfs tree which I believe could
have been symlinks. When the 'pci_slot' or 'acpiphp' drivers are loaded
/sys/bus/pci/slots/<slot num>/address files are created. I believe
these PCI address containing files could have been symlinks. Alex Chiang
recently posted a change that adds /sys/bus/pci/slots/<slot_num>/device
symlinks pointing to the approproate place in /sys/devices which will be
quite useful but I think the PCI address containing files are also useful.
In any case, the symlink sounds like a good idea and would be
sufficient by itself but I'm wondering if it would be overkill to
provide both? e.g. a 'node' symlink and a 'node_num' file.
Gary
--
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503 IBM T/L: 775-4503
garyhade@us.ibm.com
http://www.ibm.com/linux/ltc
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 1:00 ` Gary Hade
@ 2008-09-05 17:42 ` Dave Hansen
2008-09-05 17:46 ` Gary Hade
0 siblings, 1 reply; 13+ messages in thread
From: Dave Hansen @ 2008-09-05 17:42 UTC (permalink / raw)
To: Gary Hade
Cc: linux-mm, Andrew Morton, Yasunori Goto, Badari Pulavarty,
Mel Gorman, Chris McDermott, Greg KH
On Thu, 2008-09-04 at 18:00 -0700, Gary Hade wrote:
>
> In any case, the symlink sounds like a good idea and would be
> sufficient by itself but I'm wondering if it would be overkill to
> provide both? e.g. a 'node' symlink and a 'node_num' file.
Yep, that's overkill. I'd just do the symlink.
-- 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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Show memory section to node relationship in sysfs
2008-09-05 17:42 ` Dave Hansen
@ 2008-09-05 17:46 ` Gary Hade
0 siblings, 0 replies; 13+ messages in thread
From: Gary Hade @ 2008-09-05 17:46 UTC (permalink / raw)
To: Dave Hansen
Cc: Gary Hade, linux-mm, Andrew Morton, Yasunori Goto,
Badari Pulavarty, Mel Gorman, Chris McDermott, Greg KH
On Fri, Sep 05, 2008 at 10:42:18AM -0700, Dave Hansen wrote:
> On Thu, 2008-09-04 at 18:00 -0700, Gary Hade wrote:
> >
> > In any case, the symlink sounds like a good idea and would be
> > sufficient by itself but I'm wondering if it would be overkill to
> > provide both? e.g. a 'node' symlink and a 'node_num' file.
>
> Yep, that's overkill. I'd just do the symlink.
My later conclusion as well. Thanks.
Gary
--
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503 IBM T/L: 775-4503
garyhade@us.ibm.com
http://www.ibm.com/linux/ltc
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-09-05 17:42 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-04 20:22 [PATCH] Show memory section to node relationship in sysfs Gary Hade
2008-09-04 22:14 ` Nish Aravamudan
2008-09-04 23:31 ` Badari Pulavarty
2008-09-05 2:07 ` Gary Hade
2008-09-05 2:29 ` Yasunori Goto
2008-09-04 22:15 ` Dave Hansen
2008-09-05 0:40 ` Greg KH
2008-09-05 1:15 ` Gary Hade
2008-09-05 1:21 ` Greg KH
2008-09-05 3:18 ` Gary Hade
2008-09-05 1:00 ` Gary Hade
2008-09-05 17:42 ` Dave Hansen
2008-09-05 17:46 ` Gary Hade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox