Skip to contentSkip to conversation

binman: Increase default fitImage data section resize step from 1k to 64k

PATCH In review Marek Vasut 2 participants 3 messages Jul 12, 2022 – Jul 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binman: Increase default fitImage data section resize step from 1k to 64k

Currently the fitImage data area is resized in 1 kiB steps. This works when bundling smaller images below some 1 MiB, but when bundling large images into the fitImage, this make binman spend extreme amount of time and CPU just spinning in pylibfdt FdtSw.check_space() until the size grows enough for the large image to fit into the data area. Increase the default step to 64 kiB, which is a reasonable compromise -- the U-Boot blobs are somewhere in the 64kiB...1MiB range, DT blob are just short of 64 kiB, and so are the other blobs. This reduces binman runtime with 32 MiB blob from 2.3 minutes to 5 seconds.

The following can be used to trigger the problem if rand.bin is some 32 MiB. "
/ {

  itb {
    fit {
      images {
        test {
          compression = "none";
          description = "none";
          type = "flat_dt";

          blob {
            filename = "rand.bin";
            type = "blob-ext";
          };
        };
      };
    };

};

  configurations {
    binman_configuration: config {
      loadables = "test";
    };

};
};
"

Cc Alper Nebi Yasak <[email protected]>
Cc Simon Glass <[email protected]>
---
 tools/binman/etype/fit.py | 1 +
 1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -0
index 12306623af6..ad43fce18ec 100644
@@ -658,6 +658,7 @@ class Entry_fit(Entry_section):
         # Build a new tree with all nodes and properties starting from the
         # entry node
         fsw = libfdt.FdtSw()
+        fsw.INC_SIZE = 65536
         fsw.finish_reservemap()
         to_remove = []
         loadables = []
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 39 lines · Marek Vasut

Currently the fitImage data area is resized in 1 kiB steps. This works when bundling smaller images below some 1 MiB, but when bundling large images into the fitImage, this make binman spend extreme amount of time and CPU just spinning in pylibfdt FdtSw.check_space() until the size grows enough for the large image to fit into the data area. Increase the default step to 64 kiB, which is a reasonable compromise -- the U-Boot blobs are somewhere in the 64kiB...1MiB range, DT blob are just short of 64 kiB, and so are the other blobs. This reduces binman runtime with 32 MiB blob from 2.3 minutes to 5 seconds.

The following can be used to trigger the problem if rand.bin is some 32 MiB. "
/ {

  itb {
    fit {
      images {
        test {
          compression = "none";
          description = "none";
          type = "flat_dt";

          blob {
            filename = "rand.bin";
            type = "blob-ext";
          };
        };
      };
    };

};

  configurations {
    binman_configuration: config {
      loadables = "test";
    };

};
};
"

Quoted 6 lines
Cc Alper Nebi Yasak <[email protected]>
Cc Simon Glass <[email protected]>
---
 tools/binman/etype/fit.py | 1 +
 1 file changed, 1 insertion(+)

I wonder if pylibfdt should become a bit smarter and increase by the correct amount?

Quoted 16 lines
tools/binman/etype/fit.py +1 -1
index 12306623af6..ad43fce18ec 100644
@@ -658,6 +658,7 @@ class Entry_fit(Entry_section):
         # Build a new tree with all nodes and properties starting from the
         # entry node
         fsw = libfdt.FdtSw()
+        fsw.INC_SIZE = 65536
         fsw.finish_reservemap()
         to_remove = []
         loadables = []
--

2.35.1

Reviewed-by
#2 lore raw
Quoted 39 lines · Marek Vasut

Currently the fitImage data area is resized in 1 kiB steps. This works when bundling smaller images below some 1 MiB, but when bundling large images into the fitImage, this make binman spend extreme amount of time and CPU just spinning in pylibfdt FdtSw.check_space() until the size grows enough for the large image to fit into the data area. Increase the default step to 64 kiB, which is a reasonable compromise -- the U-Boot blobs are somewhere in the 64kiB...1MiB range, DT blob are just short of 64 kiB, and so are the other blobs. This reduces binman runtime with 32 MiB blob from 2.3 minutes to 5 seconds.

The following can be used to trigger the problem if rand.bin is some 32 MiB. "
/ {

  itb {
    fit {
      images {
        test {
          compression = "none";
          description = "none";
          type = "flat_dt";

          blob {
            filename = "rand.bin";
            type = "blob-ext";
          };
        };
      };
    };

};

  configurations {
    binman_configuration: config {
      loadables = "test";
    };

};
};
"

Quoted 6 lines
Cc Alper Nebi Yasak <[email protected]>
Cc Simon Glass <[email protected]>
---
 tools/binman/etype/fit.py | 1 +
 1 file changed, 1 insertion(+)

I wonder if pylibfdt should become a bit smarter and increase by the correct amount?

Quoted 1 line

Applied to u-boot-dm, thanks!