prom_init: Fetch flatten device tree from the system firmware
PATCH 1/1 prom_init: Fetch flatten device tree from the system firmware
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides dt_struct_size which works as "fdt-fetch" only produces v17 blobs.
If "fdt-fetch" is not available, the old method of fetching the DT is used.
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80
--- arch/powerpc/kernel/prom_init.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
arch/powerpc/kernel/prom_init.c +43 -0
@@ -2457,6 +2457,48 @@ static void __init flatten_device_tree(void)prom_panic ("Can't allocate initial device-tree chunk\n" ); mem_end = mem_start + room; + hdr = (void *) mem_start; +if (!call_prom_ret ("fdt-fetch" ,2 ,1 ,NULL , mem_start, + room -sizeof (mem_reserve_map)) && + hdr->version >=17 ) { +u32 size; +struct mem_map_entry *fwrmap; + +/* Fixup the boot cpuid */ + hdr->boot_cpuid_phys =cpu_to_be32 (prom.cpu); + +/* +* Store the struct and strings addresses, mostly +* for consistency, only dt_header_start actually matters later. +*/ + dt_header_start = mem_start; + dt_string_start = mem_start +be32_to_cpu (hdr->off_dt_strings); + dt_string_end = dt_string_start + +be32_to_cpu (hdr->dt_strings_size); + dt_struct_start = mem_start +be32_to_cpu (hdr->off_dt_struct); + dt_struct_end = dt_struct_start + +be32_to_cpu (hdr->dt_struct_size); + +/* +* Calculate the reserved map location (which we put +* at the blob end) and update total size. +*/ + fwrmap = (void *)(mem_start +be32_to_cpu (hdr->off_mem_rsvmap)); + hdr->off_mem_rsvmap = hdr->totalsize; + size =be32_to_cpu (hdr->totalsize); + hdr->totalsize =cpu_to_be32 (size +sizeof (mem_reserve_map)); + +/* Merge reserved map from firmware to ours */ +for ( ; fwrmap->size; ++fwrmap) +reserve_mem (be64_to_cpu (fwrmap->base), +be64_to_cpu (fwrmap->size)); + + rsvmap = (u64 *)(mem_start + size); + +prom_debug ("Fetched DTB: %d bytes to @%lx\n" , size, mem_start); + goto finalize_exit; + } +/* Get root of tree */ root =call_prom ("peer" ,1 ,1 , (phandle )0 );if (root == (phandle )0 )
@@ -2504,6 +2546,7 @@ static void __init flatten_device_tree(void)/* Version 16 is not backward compatible */ hdr->last_comp_version =cpu_to_be32 (0x10 ); +finalize_exit:/* Copy the reserve map in */ memcpy (rsvmap, mem_reserve_map,sizeof (mem_reserve_map));
Signature · 1 line
2.17.1
Quoted 26 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.
Quoted 6 lines
If "fdt-fetch" is not available, the old method of fetching the DT is used.
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80Signed-off-by Alexey Kardashevskiy <[email protected]>
Hrm. I've gotta say I'm not terribly convinced that it's worth adding a new interface we'll need to maintain to save 8s on a somewhat contrived testcase.
Quoted 65 lines
--- arch/powerpc/kernel/prom_init.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)arch/powerpc/kernel/prom_init.c +43
-0@@ -2457,6 +2457,48 @@ static void __init flatten_device_tree(void)prom_panic ("Can't allocate initial device-tree chunk\n" ); mem_end = mem_start + room; + hdr = (void *) mem_start; +if (!call_prom_ret ("fdt-fetch" ,2 ,1 ,NULL , mem_start, + room -sizeof (mem_reserve_map)) && + hdr->version >=17 ) { +u32 size; +struct mem_map_entry *fwrmap; + +/* Fixup the boot cpuid */ + hdr->boot_cpuid_phys =cpu_to_be32 (prom.cpu); + +/* +* Store the struct and strings addresses, mostly +* for consistency, only dt_header_start actually matters later. +*/ + dt_header_start = mem_start; + dt_string_start = mem_start +be32_to_cpu (hdr->off_dt_strings); + dt_string_end = dt_string_start + +be32_to_cpu (hdr->dt_strings_size); + dt_struct_start = mem_start +be32_to_cpu (hdr->off_dt_struct); + dt_struct_end = dt_struct_start + +be32_to_cpu (hdr->dt_struct_size); + +/* +* Calculate the reserved map location (which we put +* at the blob end) and update total size. +*/ + fwrmap = (void *)(mem_start +be32_to_cpu (hdr->off_mem_rsvmap)); + hdr->off_mem_rsvmap = hdr->totalsize; + size =be32_to_cpu (hdr->totalsize); + hdr->totalsize =cpu_to_be32 (size +sizeof (mem_reserve_map)); + +/* Merge reserved map from firmware to ours */ +for ( ; fwrmap->size; ++fwrmap) +reserve_mem (be64_to_cpu (fwrmap->base), +be64_to_cpu (fwrmap->size)); + + rsvmap = (u64 *)(mem_start + size); + +prom_debug ("Fetched DTB: %d bytes to @%lx\n" , size, mem_start); + goto finalize_exit; + } +/* Get root of tree */ root =call_prom ("peer" ,1 ,1 , (phandle )0 );if (root == (phandle )0 )@@ -2504,6 +2546,7 @@ static void __init flatten_device_tree(void)/* Version 16 is not backward compatible */ hdr->last_comp_version =cpu_to_be32 (0x10 ); +finalize_exit:/* Copy the reserve map in */ memcpy (rsvmap, mem_reserve_map,sizeof (mem_reserve_map));
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 29 lines · David Gibson
Quoted 28 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.If "fdt-fetch" is not available, the old method of fetching the DT is used.
Quoted 8 lines
Quoted 4 lines
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80Signed-off-by Alexey Kardashevskiy <[email protected]>Hrm. I've gotta say I'm not terribly convinced that it's worth adding a new interface we'll need to maintain to save 8s on a somewhat contrived testcase.
256CPUs aren't that many anymore though. Although I guess that many PCI devices is still a little uncommon.
A 4 socket POWER8 or POWER9 can easily be that large, and a small test kernel/userspace will boot in ~2.5-4 seconds. So it's possible that the device tree fetch could be surprisingly non-trivial percentage of boot time at least on some machines.
Signature · 2 lines
Stewart Smith OPAL Architect, IBM.
Quoted 33 lines · Stewart Smith
Quoted 32 lines · David Gibson
Quoted 31 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.If "fdt-fetch" is not available, the old method of fetching the DT is used.
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Alexey Kardashevskiy <[email protected]>Hrm. I've gotta say I'm not terribly convinced that it's worth adding a new interface we'll need to maintain to save 8s on a somewhat contrived testcase.
256CPUs aren't that many anymore though. Although I guess that many PCI devices is still a little uncommon.
Yeah, it was the PCI devices I was meaning, not the cpus.
Quoted 6 lines
A 4 socket POWER8 or POWER9 can easily be that large, and a small test kernel/userspace will boot in ~2.5-4 seconds. So it's possible that the device tree fetch could be surprisingly non-trivial percentage of boot time at least on some machines.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 36 lines · David Gibson
Quoted 35 lines · Stewart Smith
Quoted 34 lines · David Gibson
Quoted 32 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.If "fdt-fetch" is not available, the old method of fetching the DT is used.
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80Signed-off-by Alexey Kardashevskiy <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Hrm. I've gotta say I'm not terribly convinced that it's worth adding a new interface we'll need to maintain to save 8s on a somewhat contrived testcase.
256CPUs aren't that many anymore though. Although I guess that many PCI devices is still a little uncommon.
Yeah, it was the PCI devices I was meaning, not the cpus.
Each node (device, cpu, memory/numa) has a dozen of properties, so any 500 nodes will slow booting down more or less equally.
Quoted 8 lines
Quoted 7 lines
A 4 socket POWER8 or POWER9 can easily be that large, and a small test kernel/userspace will boot in ~2.5-4 seconds. So it's possible that the device tree fetch could be surprisingly non-trivial percentage of boot time at least on some machines.
Signature · 1 line
Alexey
Quoted 39 lines · Stewart Smith
Quoted 29 lines · David Gibson
Quoted 28 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.If "fdt-fetch" is not available, the old method of fetching the DT is used.
Quoted 8 lines
Quoted 4 lines
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80Signed-off-by Alexey Kardashevskiy <[email protected]>Hrm. I've gotta say I'm not terribly convinced that it's worth adding a new interface we'll need to maintain to save 8s on a somewhat contrived testcase.
Quoted 7 lines
256CPUs aren't that many anymore though. Although I guess that many PCI devices is still a little uncommon.
A 4 socket POWER8 or POWER9 can easily be that large, and a small test kernel/userspace will boot in ~2.5-4 seconds. So it's possible that the device tree fetch could be surprisingly non-trivial percentage of boot time at least on some machines.
All client interface calls are really heavy, and you need to do a lot of them if you have a big device tree. This takes time, even if the linked list stuff does not kill you :-)
Segher
Quoted 5 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
Most OF implementations do it that way. An optimisation that can help a lot is to cache the last accessed node / prop. This of course then requires you to invalidate that cache at many places you did not think about :-/
Quoted 3 lines
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
Since Linux does not do much more with the device tree, this should work great for it.
Segher
so, it is sort-of nack from David and sort-of ack from Segher, what happens now?
Quoted 98 lines · Alexey Kardashevskiy
At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to fetch the entire device tree via the client interface as the DT is traversed twice - for strings blob and for struct blob. Also, "getprop" is quite slow too as SLOF stores properties in a linked list.
However, since [1] SLOF builds flattened device tree (FDT) for another purpose. [2] adds a new "fdt-fetch" client interface for the OS to fetch the FDT.
This tries the new method; if not supported, this falls back to the old method.
There is a change in the FDT layout - the old method produced (reserved map, strings, structs), the new one receives only strings and structs from the firmware and adds the final reserved map to the end, so it is (fw reserved map, strings, structs, reserved map). This still produces the same unflattened device tree.
This merges the reserved map from the firmware into the kernel's reserved map. At the moment SLOF generates an empty reserved map so this does not change the existing behaviour in regard of reservations.
This supports only v17 onward as only that version provides
dt_struct_sizewhich works as "fdt-fetch" only produces v17 blobs.If "fdt-fetch" is not available, the old method of fetching the DT is used.
[1] https://git.qemu.org/?p=SLOF.git;a=commitdiff;h=e6fc84652c9c00
[2] https://git.qemu.org/?p=SLOF.git;a=commit;h=ecda95906930b80Signed-off-by Alexey Kardashevskiy <[email protected]>--- arch/powerpc/kernel/prom_init.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)arch/powerpc/kernel/prom_init.c +43
-0@@ -2457,6 +2457,48 @@ static void __init flatten_device_tree(void)prom_panic ("Can't allocate initial device-tree chunk\n" ); mem_end = mem_start + room; + hdr = (void *) mem_start; +if (!call_prom_ret ("fdt-fetch" ,2 ,1 ,NULL , mem_start, + room -sizeof (mem_reserve_map)) && + hdr->version >=17 ) { +u32 size; +struct mem_map_entry *fwrmap; + +/* Fixup the boot cpuid */ + hdr->boot_cpuid_phys =cpu_to_be32 (prom.cpu); + +/* +* Store the struct and strings addresses, mostly +* for consistency, only dt_header_start actually matters later. +*/ + dt_header_start = mem_start; + dt_string_start = mem_start +be32_to_cpu (hdr->off_dt_strings); + dt_string_end = dt_string_start + +be32_to_cpu (hdr->dt_strings_size); + dt_struct_start = mem_start +be32_to_cpu (hdr->off_dt_struct); + dt_struct_end = dt_struct_start + +be32_to_cpu (hdr->dt_struct_size); + +/* +* Calculate the reserved map location (which we put +* at the blob end) and update total size. +*/ + fwrmap = (void *)(mem_start +be32_to_cpu (hdr->off_mem_rsvmap)); + hdr->off_mem_rsvmap = hdr->totalsize; + size =be32_to_cpu (hdr->totalsize); + hdr->totalsize =cpu_to_be32 (size +sizeof (mem_reserve_map)); + +/* Merge reserved map from firmware to ours */ +for ( ; fwrmap->size; ++fwrmap) +reserve_mem (be64_to_cpu (fwrmap->base), +be64_to_cpu (fwrmap->size)); + + rsvmap = (u64 *)(mem_start + size); + +prom_debug ("Fetched DTB: %d bytes to @%lx\n" , size, mem_start); + goto finalize_exit; + } +/* Get root of tree */ root =call_prom ("peer" ,1 ,1 , (phandle )0 );if (root == (phandle )0 )@@ -2504,6 +2546,7 @@ static void __init flatten_device_tree(void)/* Version 16 is not backward compatible */ hdr->last_comp_version =cpu_to_be32 (0x10 ); +finalize_exit:/* Copy the reserve map in */ memcpy (rsvmap, mem_reserve_map,sizeof (mem_reserve_map));
Signature · 1 line
Alexey
Quoted 2 lines · Alexey Kardashevskiy
so, it is sort-of nack from David and sort-of ack from Segher, what happens now?
Maybe what we really need just a CI call to get all properties of a node at once? Will that speed up things enough?
That way you need no change at all in lifetime of properties and how they are used, etc.; just a client getting the properties is a lot faster.
Segher
Quoted 9 lines · Segher Boessenkool
Quoted 2 lines · Alexey Kardashevskiy
so, it is sort-of nack from David and sort-of ack from Segher, what happens now?
Maybe what we really need just a CI call to get all properties of a node at once? Will that speed up things enough?
That way you need no change at all in lifetime of properties and how they are used, etc.; just a client getting the properties is a lot faster.
Hrm... if we're going to create a new interface, let's go for what we need.
What we need is the FDT. It's a rather ubiquitous thing these days, it makes sense to have a way to fetch an FDT directly from FW.
There is no use for the "fetch all properties" cases other than building an FDT that any of us can think of, and it would create a more complicated interface than just "fetch an FDT".
So I go for the simple one and agree with Alexey's idea.
Cheers,
Ben.
Hi!
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 7 lines · Segher Boessenkool
Quoted 2 lines · Alexey Kardashevskiy
so, it is sort-of nack from David and sort-of ack from Segher, what happens now?
Maybe what we really need just a CI call to get all properties of a node at once? Will that speed up things enough?
Quoted 8 lines
Quoted 2 lines
That way you need no change at all in lifetime of properties and how they are used, etc.; just a client getting the properties is a lot faster.
Hrm... if we're going to create a new interface, let's go for what we need.
What we need is the FDT. It's a rather ubiquitous thing these days, it makes sense to have a way to fetch an FDT directly from FW.
That is all you need if you do not want to use OF at all.
If you *do* want to keep having an Open Firmware, what we want or need is a faster way to walk huge device trees.
Quoted 3 lines
There is no use for the "fetch all properties" cases other than building an FDT that any of us can think of, and it would create a more complicated interface than just "fetch an FDT".
It is a simple way to speed up fetching the device tree enormously, without needing big changes to either OF or the clients using it -- not in the code, but importantly also not conceptually: everything works just as before, just a lot faster.
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
When dealing with a whole device tree you have to know about the various dynamically generated nodes and props, and handle each appropriately.
Segher
Quoted 14 lines · Segher Boessenkool
Hi!
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 9 lines · Segher Boessenkool
Quoted 2 lines · Alexey Kardashevskiy
so, it is sort-of nack from David and sort-of ack from Segher, what happens now?
Maybe what we really need just a CI call to get all properties of a node at once? Will that speed up things enough?
That way you need no change at all in lifetime of properties and how they are used, etc.; just a client getting the properties is a lot faster.
Quoted 7 lines
Quoted 5 lines
Hrm... if we're going to create a new interface, let's go for what we need.
What we need is the FDT. It's a rather ubiquitous thing these days, it makes sense to have a way to fetch an FDT directly from FW.
That is all you need if you do not want to use OF at all.
? We also need OF drivers to boot grub and the system, and a default console for early booting, but yes, we do not want to keep using slof that much.
Quoted 2 lines
If you *do* want to keep having an Open Firmware, what we want or need is a faster way to walk huge device trees.
Why? We do not need to _walk_ the tree at all (we _have_ to now and while walking we do nothing but pack everything together into the fdt blob) as slof can easily do this already.
Quoted 8 lines
Quoted 3 lines
There is no use for the "fetch all properties" cases other than building an FDT that any of us can think of, and it would create a more complicated interface than just "fetch an FDT".
It is a simple way to speed up fetching the device tree enormously, without needing big changes to either OF or the clients using it -- not in the code, but importantly also not conceptually: everything works just as before, just a lot faster.
I can safely presume though that this will never ever be used in practice. And it will be still slower, a tiny bit. And require new code in both slof and linux.
I can rather see us getting rid of SLOF in the future which in turn will require the fdt blob pointer in r5 (or whatever it is, forgot) when the guest starts; so "fetch-all-props" won't be used there either.
Quoted 4 lines
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
When dealing with a whole device tree you have to know about the various dynamically generated nodes and props, and handle each appropriately.
The code I am changing fetches the device tree and build an fdt. What is that special knowledge in this context you are talking about?
Signature · 1 line
Alexey
Quoted 7 lines · Alexey Kardashevskiy
Quoted 2 lines
That is all you need if you do not want to use OF at all.
? We also need OF drivers to boot grub and the system, and a default console for early booting, but yes, we do not want to keep using slof that much.
Quoted 6 lines
Quoted 2 lines
If you *do* want to keep having an Open Firmware, what we want or need is a faster way to walk huge device trees.
Why? We do not need to _walk_ the tree at all (we _have_ to now and while walking we do nothing but pack everything together into the fdt blob) as slof can easily do this already.
I agree with Alexey. In a sense this can be thought as an extension of "quiesce", which effectively kills OF.
Yes we could make property fetching faster but mostly by creating a new bulk interface which is quite a bit of work, a new API, and will in practice not be used for anything other than creating the FDT. In that case, nothing will beat in performance having OF create the FDT itself based on its current tree.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
There is no use for the "fetch all properties" cases other than building an FDT that any of us can think of, and it would create a more complicated interface than just "fetch an FDT".
Quoted 8 lines
Quoted 4 lines
It is a simple way to speed up fetching the device tree enormously, without needing big changes to either OF or the clients using it -- not in the code, but importantly also not conceptually: everything works just as before, just a lot faster.
I can safely presume though that this will never ever be used in practice. And it will be still slower, a tiny bit. And require new code in both slof and linux.
Correct.
Quoted 11 lines
I can rather see us getting rid of SLOF in the future which in turn will require the fdt blob pointer in r5 (or whatever it is, forgot) when the guest starts; so "fetch-all-props" won't be used there either.
Quoted 4 lines
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
When dealing with a whole device tree you have to know about the various dynamically generated nodes and props, and handle each appropriately.
The code I am changing fetches the device tree and build an fdt. What is that special knowledge in this context you are talking about?
Ben.
Quoted 5 lines · Benjamin Herrenschmidt
Yes we could make property fetching faster but mostly by creating a new bulk interface which is quite a bit of work, a new API, and will in practice not be used for anything other than creating the FDT. In that case, nothing will beat in performance having OF create the FDT itself based on its current tree.
And that will change the whole boot protocol, the interaction between OF and its client, which is a much bigger change, not conceptually trivial at all. Copying all properties at once is, which is why I suggested it.
It would take away the opposition to your patch.
Segher
Quoted 10 lines · Segher Boessenkool
Quoted 5 lines · Benjamin Herrenschmidt
Yes we could make property fetching faster but mostly by creating a new bulk interface which is quite a bit of work, a new API, and will in practice not be used for anything other than creating the FDT. In that case, nothing will beat in performance having OF create the FDT itself based on its current tree.
And that will change the whole boot protocol, the interaction between OF and its client, which is a much bigger change, not conceptually trivial at all. Copying all properties at once is, which is why I suggested it.
Much as I wasn't terribly convinced by the original idea, I agree with Ben and Alexey here. Your approach has slightly more complexity for slightly less benefit. If it's worth doing yours it's better to do theirs.
Quoted 1 line
It would take away the opposition to your patch.
Only from you, AFAICT...
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Hi!
Quoted 8 lines · Alexey Kardashevskiy
Quoted 4 lines · Segher Boessenkool
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
When dealing with a whole device tree you have to know about the various dynamically generated nodes and props, and handle each appropriately.
The code I am changing fetches the device tree and build an fdt. What is that special knowledge in this context you are talking about?
Things like /options are dynamically generated.
I thought you would just be able to reuse some FDT parsing code to implement my suggested new interface. Maybe that was too optimistic.
Segher
Quoted 11 lines · Segher Boessenkool
Hi!
Quoted 8 lines · Alexey Kardashevskiy
Quoted 6 lines · Segher Boessenkool
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
When dealing with a whole device tree you have to know about the various
dynamically generated nodes and props, and handle each appropriately.
Quoted 5 lines
Quoted 3 lines
The code I am changing fetches the device tree and build an fdt. What is
that special knowledge in this context you are talking about?Things like /options are dynamically generated.
They are generated before we do the call to extract the fdt, what's the problem there ?
Quoted 2 lines
I thought you would just be able to reuse some FDT parsing code to implement my suggested new interface. Maybe that was too optimistic.
No, the idea is to have SLOF re-flatten it's live tree and hand us a blob. At least that's my understanding.
Ben.
Quoted 6 lines · Segher Boessenkool
Hi!
Quoted 3 lines · Alexey Kardashevskiy
Quoted 2 lines · Segher Boessenkool
Quoted 1 line
So I go for the simple one and agree with Alexey's idea.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
When dealing with a whole device tree you have to know about the various dynamically generated nodes and props, and handle each appropriately.
The code I am changing fetches the device tree and build an fdt. What is that special knowledge in this context you are talking about?
Things like /options are dynamically generated.
Generated by the guest kernel, after walking the tree and before making the fdt blob? I cannot see it, what do I miss? Otherwise it is all in slof and the same result is fetched one way or another.
Quoted 2 lines
I thought you would just be able to reuse some FDT parsing code to implement my suggested new interface. Maybe that was too optimistic.
Signature · 1 line
Alexey