linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06  8:52 Sourav Sen
  2004-05-06 10:44 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Sourav Sen @ 2004-05-06  8:52 UTC (permalink / raw)
  To: Matt_Domsch, matthew.e.tolentino, linux-ia64, linux-kernel

Hi,

The following simple patch creates a read-only file
"memmap" under <mount point>/firmware/efi/ in sysfs
and exposes the efi memory map thru it.

Thanks
Sourav


The patch is w.r.t 2.6.6-rc3
----------------------------
===========================================================================
--- a/drivers/firmware/efivars.c        2004-05-05 13:55:40.000000000 +0530
+++ b/drivers/firmware/efivars.c        2004-05-06 11:43:40.000000000 +0530
@@ -580,10 +580,42 @@ systab_read(struct subsystem *entry, cha
        return str - buf;
 }

+/*
+ * Expose the efi memory map as kernel keeps it. Note, it may be a little
+ * different from what gets actually passed in at loader handoff time as a
+ * call to efi_memmap_walk modifies that.
+ */
+
+static ssize_t
+efi_memmap_read(struct subsystem *entry, char * buf)
+{
+       void * efi_map_start, *efi_map_end, *p;
+       efi_memory_desc_t *md;
+       u64 efi_desc_size;
+       char * str = buf;
+
+       if (!entry || !buf)
+               return -EINVAL;
+
+       efi_map_start = __va(ia64_boot_param->efi_memmap);
+       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+       efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+               md = (efi_memory_desc_t *)p;
+               str += sprintf(str, "%2u     %-#18lx    %#016lx %#016lx\n",
\
+                       md->type, md->attribute, md->phys_addr, \
+                       md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT));
+       }
+       return (str - buf);
+}
+
 static EFI_ATTR(systab, 0400, systab_read, NULL);
+static EFI_ATTR(memmap, 0400, efi_memmap_read, NULL);

 static struct subsys_attribute *efi_subsys_attrs[] = {
        &efi_attr_systab,
+       &efi_attr_memmap,       /* Here comes one */
        NULL,   /* maybe more in the future? */
 };


^ permalink raw reply	[flat|nested] 28+ messages in thread
* [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06  9:18 Sourav Sen
  0 siblings, 0 replies; 28+ messages in thread
From: Sourav Sen @ 2004-05-06  9:18 UTC (permalink / raw)
  To: Matt_Domsch, matthew.e.tolentino, linux-ia64, linux-kernel

Resending it as the last one line wrapped :-(

----------------------------------------------------
Hi,

The following simple patch creates a read-only file 
"memmap" under <mount point>/firmware/efi/ in sysfs 
and exposes the efi memory map thru it.
 
Thanks
Sourav
HP-STS, Bangalore

The patch is w.r.t 2.6.6-rc3
----------------------------
===========================================================================
--- a/drivers/firmware/efivars.c        2004-05-05 13:55:40.000000000 +0530
+++ b/drivers/firmware/efivars.c        2004-05-06 14:03:13.000000000 +0530
@@ -580,10 +580,42 @@ systab_read(struct subsystem *entry, cha
        return str - buf;
 }

+/*
+ * Expose the efi memory map as kernel keeps it. Note, it may be a little
+ * different from what gets actually passed in at loader handoff time as a
+ * call to efi_memmap_walk modifies that.
+ */
+
+static ssize_t
+efi_memmap_read(struct subsystem *entry, char * buf)
+{
+       void * efi_map_start, *efi_map_end, *p;
+       efi_memory_desc_t *md;
+       u64 efi_desc_size;
+       char * str = buf;
+
+       if (!entry || !buf)
+               return -EINVAL;
+
+       efi_map_start = __va(ia64_boot_param->efi_memmap);
+       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+       efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+               md = (efi_memory_desc_t *)p;
+               str += sprintf(str, "%2u  %-#18lx  %#016lx %#016lx\n", \
+                       md->type, md->attribute, md->phys_addr, \
+                       md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT));
+       }
+       return (str - buf);
+}
+
 static EFI_ATTR(systab, 0400, systab_read, NULL);
+static EFI_ATTR(memmap, 0400, efi_memmap_read, NULL);

 static struct subsys_attribute *efi_subsys_attrs[] = {
        &efi_attr_systab,
+       &efi_attr_memmap,       /* Here comes one */
        NULL,   /* maybe more in the future? */
 }; 

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06 13:23 Luck, Tony
  0 siblings, 0 replies; 28+ messages in thread
From: Luck, Tony @ 2004-05-06 13:23 UTC (permalink / raw)
  To: Matt Domsch, Sourav Sen; +Cc: Tolentino, Matthew E, linux-ia64, linux-kernel

>2) Can the memory map output ever be larger than PAGE_SIZE (lower
>limit is 4KB on x86)?  If not, what guarantees that?  If so, you need
>your own read mechanism rather than the generic sysfs one.

The output format of the sprintf() gives 58 characters per entry, which
with a 4k page allows for 70 entries before the page overflows, which
feels borderline for ccNUMA machines.  On ia64 the pagesize is usually
16k, which would allow 282 entries.  I think this will fail on a 128
node SGI sn2 (because there are 4 memory banks per node => min 512
entries
in the memory map).

-Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06 16:14 Tolentino, Matthew E
  0 siblings, 0 replies; 28+ messages in thread
From: Tolentino, Matthew E @ 2004-05-06 16:14 UTC (permalink / raw)
  To: Matt Domsch, Sourav Sen; +Cc: linux-ia64, linux-kernel

> 2) Can the memory map output ever be larger than PAGE_SIZE (lower
> limit is 4KB on x86)?  If not, what guarantees that?  If so, you need
> your own read mechanism rather than the generic sysfs one.

There are no size guarantees with the EFI memory map.  It could
be of various sizes...

matt


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06 18:47 Tolentino, Matthew E
  2004-05-06 18:57 ` Dave Hansen
  0 siblings, 1 reply; 28+ messages in thread
From: Tolentino, Matthew E @ 2004-05-06 18:47 UTC (permalink / raw)
  To: Dave Hansen, Sourav Sen
  Cc: HELGAAS,BJORN (HP-Ft. Collins), Matt Domsch, linux-ia64,
	Linux Kernel Mailing List, Luck, Tony

> On Thu, 2004-05-06 at 09:25, Sourav Sen wrote:
> > From: Bjorn Helgaas [mailto:bjorn.helgaas@hp.com]
> > + For this application, the EFI memory map isn't what you want.
> > + It's a pretty good approximation today, but the day when we'll
> > + be able to hot-add memory is fast approaching, and the EFI map
> > + won't mention anything added after boot.  We'll discover all
> > + that via ACPI (on ia64).
> >
> > 	Why not also update the efi memory table on a hotplug :-)
> 
> That's actually what ppc64 does.  But, they do it via /proc (not even
> from inside the kernel).  I'm not very fond of that solution :)

Interesting. What does ppc64 do with the memmap after that?  

> >  and there may be some truncation (just as efi_memmap_walk()
> > does today). And it isn't help us if we get to know about those
> > extents. Additionally we get to know about various mmio ranges and
> > other ranges thru that table -- may be useful opportunistically.
> 
> There can be some pretty generic (although asynchronous) events given
> via /sbin/hotplug.  I'm currently planning on having the 
> memory hotplug
> "drivers" get the hot-added memory ready, but keep it 
> offline.  It then
> creates some kobjects, which generate hotplug events, and *then* the
> decision can be made in the hotplug scripts about what to do with it.

So, allocate the page structs which constitute the new memmap, set up
the nonlinear sections, and then wait for hotplug events in order to 
clear the appropriate bits in the pages for a given range?  Is that 
what you're thinking?

matt

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: [2.6.6 PATCH] Exposing EFI memory map
@ 2004-05-06 20:54 Tolentino, Matthew E
  0 siblings, 0 replies; 28+ messages in thread
From: Tolentino, Matthew E @ 2004-05-06 20:54 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Sourav Sen, HELGAAS,BJORN (HP-Ft. Collins), Matt Domsch,
	linux-ia64, Linux Kernel Mailing List, Luck, Tony, lhms

> > Interesting. What does ppc64 do with the memmap after that?  
> 
> This doesn't even concern mem_map yet.  The userspace ppc64 hotplug
> tools actually write into the "OpenFirmware" tree from 
> userspace, after
> a hotplug happens.  This is partly because all of the ppc64 hotplug
> operations happen in userspace as it stands now.  

Umm..  my mistake, I meant the memory map passed up by the firmware,
not THE mem_map.  ;-)

> Actually, I was thinking that we'd just allocate the 
> kobjects, and note
> the presence of the memory in the nonlinear phys_section table.  Then,
> when we online it, we can decide where it's mapped, what zone 
> to put it
> in, and where to get the mem_map space from.  I think that approach
> gives the best flexibility. 

Yes, indeed. 

matt

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2004-05-13 15:39 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-06  8:52 [2.6.6 PATCH] Exposing EFI memory map Sourav Sen
2004-05-06 10:44 ` Christoph Hellwig
2004-05-06 11:59   ` Matthew Wilcox
2004-05-06 12:18     ` Arjan van de Ven
2004-05-06 13:27       ` Matthew Wilcox
2004-05-06 14:00         ` Dave Hansen
2004-05-06 14:09           ` Arjan van de Ven
2004-05-06 14:09     ` Christoph Hellwig
2004-05-06 12:46 ` Matt Domsch
2004-05-06 13:20   ` Sourav Sen
2004-05-06 15:08     ` Bjorn Helgaas
2004-05-06 16:25       ` Sourav Sen
2004-05-06 16:49         ` Dave Hansen
2004-05-06 16:40 ` Greg KH
2004-05-07  9:45   ` Sourav Sen
2004-05-07 21:49     ` Greg KH
2004-05-11 14:44       ` Sourav Sen
2004-05-11 15:42         ` Dave Hansen
2004-05-12 10:24           ` Sourav Sen
2004-05-12 16:15             ` Dave Hansen
2004-05-13 14:10               ` Sourav Sen
2004-05-13 15:32                 ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2004-05-06  9:18 Sourav Sen
2004-05-06 13:23 Luck, Tony
2004-05-06 16:14 Tolentino, Matthew E
2004-05-06 18:47 Tolentino, Matthew E
2004-05-06 18:57 ` Dave Hansen
2004-05-06 20:54 Tolentino, Matthew E

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).