Skip to contentSkip to conversation

sparc64: boot performance improvements

PATCH In review Eric Snowberg 3 participants 11 messages Oct 8, 2015 – Oct 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc64: boot performance improvements

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

---
 grub-core/kern/ieee1275/ieee1275.c |   39 ++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +39 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 
 int
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   }
   args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
   INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
   args.path = (grub_ieee1275_cell_t) path;
 
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   *result = args.result;
   if (args.result == IEEE1275_IHANDLE_INVALID)
     return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));
+  dev->path = grub_strdup(path);
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
   return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
   }
   args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+
   INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
   args.ihandle = ihandle;
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel? It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

Quoted 54 lines
---
 grub-core/kern/ieee1275/ieee1275.c |   39 ++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +25 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 
 int
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   }
   args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
   INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
   args.path = (grub_ieee1275_cell_t) path;
 

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 5 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   *result = args.result;
   if (args.result == IEEE1275_IHANDLE_INVALID)
     return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

Quoted 8 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
   return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
   }
   args;

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 10 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
   INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
   args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
  }
  args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
  INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
  args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
  *result = args.result;
  if (args.result == IEEE1275_IHANDLE_INVALID)
    return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
  return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
  }
  args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 16 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
  INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
  args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 13 lines · Eric Snowberg
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

Quoted 8 lines

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

Quoted 126 lines

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
  }
  args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
  INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
  args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
  *result = args.result;
  if (args.result == IEEE1275_IHANDLE_INVALID)
    return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
  return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
  }
  args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 12 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
  INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
  args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 24 lines · Andrei Borzenkov
Quoted 20 lines · Eric Snowberg
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

Quoted 9 lines
Quoted 1 line

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

That makes sense, I’ll restrict it to all sun4v equipment.

Quoted 132 lines
Quoted 123 lines

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
   return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 12 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw
In reply to Eric Snowberg
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Unfortunately on some systems (AFAIR old sparcs) hard-locks if the same device is opened twice. We tried to detect when 2 devices are named differently but it's not possible to do reliably on IEEE1275. Our only solution was to ensure that only 1 disk is open at a time. Do you use some kind of RAID? Can you try keeping last_handle open in ofdisk.c rather than closing it?

Quoted 82 lines
---
 grub-core/kern/ieee1275/ieee1275.c |   39 ++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +39 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 
 int
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   }
   args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
   INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
   args.path = (grub_ieee1275_cell_t) path;
 
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   *result = args.result;
   if (args.result == IEEE1275_IHANDLE_INVALID)
     return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));
+  dev->path = grub_strdup(path);
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
   return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
   }
   args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+
   INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
   args.ihandle = ihandle;
 
#5 lore raw
In reply to Eric Snowberg

Le 10 oct. 2015 3:31 AM, "Eric Snowberg" <[email protected]> a écrit :

Quoted 3 lines
Quoted 3 lines

On Oct 9, 2015, at 12:50 AM, Andrei Borzenkov <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

On Thu, Oct 8, 2015 at 2:20 AM, Eric Snowberg <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Oct 7, 2015, at 2:36 AM, Andrei Borzenkov <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 6, 2015 at 8:39 PM, Eric Snowberg <

Quoted 10 lines · [email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

On SPARC hardware it is not necessary. I would be interested to hear

if it is necessary on other IEEE1275 platforms.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the

additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

Quoted 11 lines
Quoted 8 lines

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

That makes sense, I’ll restrict it to all sun4v equipment.

Not good enough. Some of sun4v probably have the bug I told about in the other e-mail

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The path name sent into the grub_ieee1275_open function is not

consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39

++++++++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
1 files changed, 39 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/grub-core/kern/ieee1275/ieee1275.c

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

index 9821702..30f973b 100644

grub-core/kern/ieee1275/ieee1275.c +13 -0
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path,

Quoted 2 lines

int

grub-core/kern/ieee1275/ieee1275.c +0 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path,

grub_ieee1275_ihandle_t *result)

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
grub-core/kern/ieee1275/ieee1275.c +12 -0
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path,

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +0 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path,

grub_ieee1275_ihandle_t *result)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 5 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
   return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 2 lines
Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Ditto

I’ll resubmit V2 with this change

Quoted 2 lines
Quoted 2 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices),

GRUB_AS_LIST (dev));

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t

Quoted 4 lines
grub-core/kern/ieee1275/ieee1275.c +0 -0
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t

ihandle)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 12 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without

grub_ieee1275_open)?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I don’t see it being possible with SPARC and would assume other

platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 36 lines
Quoted 26 lines
Quoted 21 lines
Quoted 15 lines
Quoted 10 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw
Quoted 40 lines · Vladimir 'phcoder' Serbinenko
Quoted 35 lines · Eric Snowberg
Quoted 34 lines · Andrei Borzenkov
Quoted 13 lines · Eric Snowberg
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

Quoted 8 lines

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

Quoted 3 lines
Quoted 2 lines

That makes sense, I’ll restrict it to all sun4v equipment.

Not good enough. Some of sun4v probably have the bug I told about in the other e-mail

I can get access to every sun4v platform. Could you provide any additional information on which sun4v systems had this failure. If so, I’ll try to submit a fix for that problem as well. It seems like there could be a better way to handle this than resetting the SAS or SATA HBA before each read operation.

There are many problems with the upstream grub2 implementation for sun4v. I will be submitting additional follow on patches, since it currently will not even boot to the grub menu. My intention is to get grub2 working on every sun4v platform.

Quoted 142 lines
Quoted 134 lines
Quoted 128 lines
Quoted 123 lines

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
   return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 12 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 40 lines · Eric Snowberg
Quoted 40 lines · Vladimir 'phcoder' Serbinenko
Quoted 35 lines · Eric Snowberg
Quoted 34 lines · Andrei Borzenkov
Quoted 13 lines · Eric Snowberg
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

Quoted 8 lines

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

That makes sense, I’ll restrict it to all sun4v equipment.

Not good enough. Some of sun4v probably have the bug I told about in the other e-mail

I can get access to every sun4v platform. Could you provide any additional information on which sun4v systems had this failure. If so, I’ll try to submit a fix for that problem as well. It seems like there could be a better way to handle this than resetting the SAS or SATA HBA before each read operation.

See http://permalink.gmane.org/gmane.comp.boot-loaders.grub.devel/10533
for holding open handle.
Do you readily have a scenario when you need multiple handles open? Can you try following naive optimisation:

(quoted diff) +0 -0

b/grub-core/disk/ieee1275/ofdisk.c
index 331769b..34237f9 100644

grub-core/disk/ieee1275/ofdisk.c +0 -7
@@ -448,13 +448,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
 static void
 grub_ofdisk_close (grub_disk_t disk)
 {
-  if (disk->data == last_devpath)
-    {
-      if (last_ihandle)
-       grub_ieee1275_close (last_ihandle);
-      last_ihandle = 0;
-      last_devpath = NULL;
-    }
   disk->data = 0;
 }
 
Quoted 2 lines

There are many problems with the upstream grub2 implementation for sun4v. I will be submitting additional follow on patches, since it currently will not even boot to the grub menu. My intention is to get grub2 working on every sun4v platform.

Could you start with

Quoted 150 lines
Quoted 135 lines
Quoted 135 lines
Quoted 133 lines
Quoted 124 lines

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
   return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 12 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 8 lines
Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw
Quoted 46 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 42 lines · Eric Snowberg
Quoted 42 lines · Vladimir 'phcoder' Serbinenko
Quoted 37 lines · Eric Snowberg
Quoted 25 lines · Andrei Borzenkov
Quoted 20 lines · Eric Snowberg
Quoted 12 lines · Andrei Borzenkov
Quoted 6 lines · Eric Snowberg

Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

On SPARC hardware it is not necessary. I would be interested to hear if it is necessary on other IEEE1275 platforms.

Quoted 4 lines

It sounds like it can accumulate quite a lot of them - are there any memory limits/restrictions? Also your patch is rather generic and so applies to any IEEE1275 platform, I think some of them may have less resources. Just trying to understand what run-time cost is.

Quoted 9 lines
Quoted 1 line

The most I have seen are two entries in the linked list. So the additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

That makes sense, I’ll restrict it to all sun4v equipment.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Not good enough. Some of sun4v probably have the bug I told about in the other e-mail

I can get access to every sun4v platform. Could you provide any additional information on which sun4v systems had this failure. If so, I’ll try to submit a fix for that problem as well. It seems like there could be a better way to handle this than resetting the SAS or SATA HBA before each read operation.

See http://permalink.gmane.org/gmane.comp.boot-loaders.grub.devel/10533
for holding open handle.

The patch I submitted will prevent the same device from being opened multiple times concurrently. Just as the link above describes. The only time this will not be the case is when grub references the same device name differently. For example I have seen on one system where it alternates between the SAS WWN and the typical OpenBoot alias for the drive name. I intend on fixing this problem. But so far with this system OpenBoot has been able to handle it.

The problem with the last_ihandle caching within ofdisk.c is that the last_devpath pointer changes with each file open call. So there really isn’t much benefit, since the device will always be closed and reopened, since the disk->data pointer changes, even though it contains the same string. So on a typical boot, there are around 33 open and close calls taking place. This causes the SAS controller to be restarted 33 times. With the patch I submitted, all the last_ihandle caching, could be removed.

Quoted 1 line

Do you readily have a scenario when you need multiple handles open?

The other problem my patch solves is where on some systems, grub will walk the entire device tree and open every single device, multiple times. I do not understand why it does this on some systems, but when it does, it takes 20+ minutes before the grub menu appears. With the patch I submitted, the menu will appear in under 29 seconds on all sun4v systems.

I have made a V2 patch with the changes Andrei recommended, where the code will only be used on sun4v platforms. I have tested it on almost every generation of the sun4v platform. I still have a few platforms to go. Please let me know how you want me to proceed with this V2 patch if this testing looks promising.

Quoted 18 lines

Can you try following naive optimisation:

grub-core/disk/ieee1275/ofdisk.c +0 -0
index 331769b..34237f9 100644
@@ -448,13 +448,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)

static void
grub_ofdisk_close (grub_disk_t disk)
{

grub-core/disk/ieee1275/ofdisk.c +0 -7
-  if (disk->data == last_devpath)
-    {
-      if (last_ihandle)
-       grub_ieee1275_close (last_ihandle);
-      last_ihandle = 0;
-      last_devpath = NULL;
-    }
  disk->data = 0;
Quoted 1 line

}

This optimization will not work. It will cause the same device node to be opened multiple times concurrently, which can lead to problems on some sun4v systems.

Quoted 4 lines
Quoted 3 lines

There are many problems with the upstream grub2 implementation for sun4v. I will be submitting additional follow on patches, since it currently will not even boot to the grub menu. My intention is to get grub2 working on every sun4v platform.

Could you start with

I think something got cut off here.

Quoted 156 lines
Quoted 145 lines
Quoted 135 lines
Quoted 135 lines
Quoted 133 lines
Quoted 124 lines

The path name sent into the grub_ieee1275_open function is not consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 54 lines
Quoted 54 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++

1 files changed, 39 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +13 -0
index 9821702..30f973b 100644
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 

int

grub-core/kern/ieee1275/ieee1275.c +12 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 8 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 489

Quoted 6 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
  return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) · line 490

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);

Ditto

I’ll resubmit V2 with this change

Quoted 9 lines
Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev));
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 args;
 
Quoted 12 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) · line 514

Quoted 9 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without grub_ieee1275_open)?

I don’t see it being possible with SPARC and would assume other platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 12 lines
Quoted 11 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 8 lines
Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw

Le 27 oct. 2015 5:34 PM, "Eric Snowberg" <[email protected]> a écrit :

Quoted 3 lines
Quoted 3 lines

On Oct 25, 2015, at 9:20 AM, Vladimir 'φ-coder/phcoder' Serbinenko <

Quoted 4 lines · [email protected]> wrote:
Quoted 4 lines · Eric Snowberg
Quoted 2 lines
Quoted 2 lines

On Oct 10, 2015, at 1:35 AM, Vladimir 'phcoder' Serbinenko <

Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Le 10 oct. 2015 3:31 AM, "Eric Snowberg" <[email protected]> a

écrit :

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

On Oct 9, 2015, at 12:50 AM, Andrei Borzenkov <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Thu, Oct 8, 2015 at 2:20 AM, Eric Snowberg <

Quoted 2 lines · [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Oct 7, 2015, at 2:36 AM, Andrei Borzenkov <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 6, 2015 at 8:39 PM, Eric Snowberg <

Quoted 1 line · [email protected]> wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Keep of devices open. This can save 6 - 7 seconds per open call

and

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

can decrease boot times from over 10 minutes to 29 seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.

Is it necessary to close these handles before launching kernel?

On SPARC hardware it is not necessary. I would be interested to

hear if it is necessary on other IEEE1275 platforms.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

It sounds like it can accumulate quite a lot of them - are there

any

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

memory limits/restrictions? Also your patch is rather generic and

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

applies to any IEEE1275 platform, I think some of them may have

less

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

resources. Just trying to understand what run-time cost is.

The most I have seen are two entries in the linked list. So the

additional memory requirements are very small. I have tried this on a T2000, T4, and T5.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

I thought you were speaking about *larger* SPARC servers :)

Anyway I'd still prefer if this would be explicitly restricted to Oracle servers. Please look at grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() if new quirk can be added to detect your platform(s).

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

That makes sense, I’ll restrict it to all sun4v equipment.

Not good enough. Some of sun4v probably have the bug I told about in

the other e-mail

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I can get access to every sun4v platform. Could you provide any

additional information on which sun4v systems had this failure. If so, I’ll try to submit a fix for that problem as well. It seems like there could be a better way to handle this than resetting the SAS or SATA HBA before each read operation.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

See http://permalink.gmane.org/gmane.comp.boot-loaders.grub.devel/10533
for holding open handle.

The patch I submitted will prevent the same device from being opened

multiple times concurrently. Just as the link above describes. The only
time this will not be the case is when grub references the same device name differently. For example I have seen on one system where it alternates between the SAS WWN and the typical OpenBoot alias for the drive name. I intend on fixing this problem. But so far with this system OpenBoot has been able to handle it.

Quoted 1 line

I tried to fix this some time ago. Unfortunately I didn't find a way to reliably determine if 2 disks are the same. Canon doesn't add part after @ if they are not there. Comparing phandle considers devices on the same bus as same device. How are you going to fix it?
Another question: can we have ihandle caching logic in ofdisk rather than deep in open logic?

Quoted 1 line

The problem with the last_ihandle caching within ofdisk.c is that the

last_devpath pointer changes with each file open call. So there really isn’t much benefit, since the device will always be closed and reopened, since the disk->data pointer changes, even though it contains the same string. So on a typical boot, there are around 33 open and close calls taking place. This causes the SAS controller to be restarted 33 times. With the patch I submitted, all the last_ihandle caching, could be removed.

Quoted 1 line

Sounds like we can just replace comparing pointers with strcmp

Quoted 3 lines
Quoted 1 line

Do you readily have a scenario when you need multiple handles open?

The other problem my patch solves is where on some systems, grub will

walk the entire device tree and open every single device, multiple times. I do not understand why it does this on some systems, but when it does, it takes 20+ minutes before the grub menu appears. With the patch I submitted, the menu will appear in under 29 seconds on all sun4v systems.

Quoted 1 line

It does so to resolve UUID. It usually means that hints have failed or disks changed after last grub-install/mkconfig

Quoted 1 line

I have made a V2 patch with the changes Andrei recommended, where the

code will only be used on sun4v platforms. I have tested it on almost every generation of the sun4v platform. I still have a few platforms to
go. Please let me know how you want me to proceed with this V2 patch if
this testing looks promising.

Quoted 1 line

Yes, definitely.

Quoted 7 lines

grub-core/disk/ieee1275/ofdisk.c grub_ofdisk_open (const char *name, grub_disk_t

Quoted 7 lines

Can you try following naive optimisation:

grub-core/disk/ieee1275/ofdisk.c +0 -0
index 331769b..34237f9 100644
@@ -448,13 +448,6 @@ grub_ofdisk_open (const char *name, grub_disk_t

disk)

Quoted 13 lines
Quoted 11 lines

static void
grub_ofdisk_close (grub_disk_t disk)
{

grub-core/disk/ieee1275/ofdisk.c +0 -7
-  if (disk->data == last_devpath)
-    {
-      if (last_ihandle)
-       grub_ieee1275_close (last_ihandle);
-      last_ihandle = 0;
-      last_devpath = NULL;
-    }
  disk->data = 0;
Quoted 1 line

}

Quoted 1 line

This optimization will not work. It will cause the same device node to

be opened multiple times concurrently, which can lead to problems on some sun4v systems.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

There are many problems with the upstream grub2 implementation for

sun4v. I will be submitting additional follow on patches, since it currently will not even boot to the grub menu. My intention is to get grub2 working on every sun4v platform.

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Could you start with

I think something got cut off here.

I meant bug fixes can go in without waiting for this

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

The path name sent into the grub_ieee1275_open function is not

consistent throughout the code, even though it is referencing the same device. Originally I tried having a global containing the path sent into grub_ieee1275_open, but this failed due to the various ways of referencing the same device name. That is why I added the linked list just to be safe. Caching the grub_ieee1275_ihandle_t this way saves a significant amount of time, since OF calls are expensive. We were seeing the same device opened 50+ times in the process of displaying the grub menu and then launching the kernel.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

---
grub-core/kern/ieee1275/ieee1275.c | 39

++++++++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
1 files changed, 39 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/grub-core/kern/ieee1275/ieee1275.c

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

index 9821702..30f973b 100644

grub-core/kern/ieee1275/ieee1275.c +13 -0
@@ -19,11 +19,24 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/mm.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
 #define IEEE1275_CELL_INVALID     ((grub_ieee1275_cell_t) -1)
 
+struct grub_of_opened_device
+{
+  struct grub_of_opened_device *next;
+  struct grub_of_opened_device **prev;
+  grub_ieee1275_ihandle_t ihandle;
+  char *path;
+};
+
+static struct grub_of_opened_device *grub_of_opened_devices;
+
 
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path,

Quoted 2 lines

int

grub-core/kern/ieee1275/ieee1275.c +0 -0
@@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path,

grub_ieee1275_ihandle_t *result)

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
grub-core/kern/ieee1275/ieee1275.c +12 -0
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (grub_strcmp(dev->path, path) == 0)
+      break;
+
+  if (dev)
+  {
+    *result = dev->ihandle;
+    return 0;
+  }
+
 INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
 args.path = (grub_ieee1275_cell_t) path;
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path,

Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +0 -0
@@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path,

grub_ieee1275_ihandle_t *result)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_open (const char *path, · line 489

Quoted 5 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
 *result = args.result;
 if (args.result == IEEE1275_IHANDLE_INVALID)
  return -1;
+
+  dev = grub_zalloc(sizeof(struct grub_of_opened_device));

Error check

I’ll resubmit V2 with this change

Quoted 2 lines
Quoted 1 line
grub-core/kern/ieee1275/ieee1275.c +1 -0
+  dev->path = grub_strdup(path);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Ditto

I’ll resubmit V2 with this change

Quoted 2 lines
Quoted 2 lines
grub-core/kern/ieee1275/ieee1275.c +2 -0
+  dev->ihandle = args.result;
+  grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices),

GRUB_AS_LIST (dev));

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close

Quoted 4 lines
grub-core/kern/ieee1275/ieee1275.c +0 -0
 return 0;
 }
 
@@ -473,6 +503,15 @@ grub_ieee1275_close

(grub_ieee1275_ihandle_t ihandle)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

grub-core/kern/ieee1275/ieee1275.c grub_ieee1275_close · line 514

Quoted 12 lines
grub-core/kern/ieee1275/ieee1275.c +9 -0
 }
 args;
 
+  struct grub_of_opened_device *dev;
+
+  FOR_LIST_ELEMENTS(dev, grub_of_opened_devices)
+    if (dev->ihandle == ihandle)
+      break;
+
+  if (dev)
+    return 0;
+

How can we come here (i.e. can we get open handle without

grub_ieee1275_open)?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I don’t see it being possible with SPARC and would assume other

platforms could not get there either. I’m not familiar with the other IEEE1275 platforms to know if this would be appropriate, but If there isn’t a platform that needs this close function, could the function be changed to do nothing but return 0?

Quoted 59 lines
Quoted 49 lines
Quoted 42 lines
Quoted 32 lines
Quoted 32 lines
Quoted 30 lines
Quoted 21 lines
Quoted 15 lines
Quoted 10 lines
grub-core/kern/ieee1275/ieee1275.c +0 -1
 INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
 args.ihandle = ihandle;
 
--

1.7.1

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 8 lines
Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel