summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorJay Azurin <jmazurin@us.ibm.com>2015-08-28 12:53:22 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-09-04 18:10:13 -0500
commitaaf724e9f06ac6013f97bb967aae6c4510b0a1da (patch)
tree58561d4ee3e7e715f453a7462c1aa8bfa1f4902d /src/include
parent63ffc550f12b78679e66813e73ea995ca84551b9 (diff)
downloadblackbird-hostboot-aaf724e9f06ac6013f97bb967aae6c4510b0a1da.tar.gz
blackbird-hostboot-aaf724e9f06ac6013f97bb967aae6c4510b0a1da.zip
Workaround for fapiMalloc fragmentation issue
Added a macro that returns the next highest power of 2 number of pages for a given buffer. Implemented fapiPlatMalloc() so that it calls the macro for buffers larger than 1 page size. This can prevent excessive fragmentation when allocating very large buffers. CQ:SW317751 Change-Id: I8eaef95ba4381026377a1eab0fe620b2954c8230 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20255 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: William H. Schwartz <whs@us.ibm.com> Reviewed-by: Michael Baiocchi <baiocchi@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/usr/hwpf/plat/fapiPlatUtil.H2
-rw-r--r--src/include/util/align.H14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/include/usr/hwpf/plat/fapiPlatUtil.H b/src/include/usr/hwpf/plat/fapiPlatUtil.H
index ff1464693..2d2d5fbb7 100644
--- a/src/include/usr/hwpf/plat/fapiPlatUtil.H
+++ b/src/include/usr/hwpf/plat/fapiPlatUtil.H
@@ -72,7 +72,7 @@ template <> inline uint32_t fapiPlatGenHash <fapi::hash::CRC32>
#define FAPI_PLAT_HTOBE64(x) htobe64(x)
#define FAPI_PLAT_HTOLE64(x) htole64(x)
-#define fapiPlatMalloc(s) malloc(s)
+void* fapiPlatMalloc(size_t);
#define fapiPlatFree(p) free(p)
#endif // FAPIPLATUTIL_H_
diff --git a/src/include/util/align.H b/src/include/util/align.H
index 0ffec92d1..e0132b2b7 100644
--- a/src/include/util/align.H
+++ b/src/include/util/align.H
@@ -51,4 +51,18 @@
#define ALIGN_MEGABYTE(u) (ALIGN_X(u,MEGABYTE))
#define ALIGN_MEGABYTE_DOWN(u) (ALIGN_DOWN_X(u,MEGABYTE))
+// Returns a number that is aligned to the next highest power of 2 number of
+// pages for the given buffer.
+#define ALIGN_TO_NEXT_POWER_OF_TWO_PAGES(b) ({\
+ unsigned int v = ALIGN_PAGE(b)/PAGE_SIZE;\
+ v--;\
+ v |= v >> 1;\
+ v |= v >> 2;\
+ v |= v >> 4;\
+ v |= v >> 8;\
+ v |= v >> 16;\
+ v++;\
+ v * PAGE_SIZE;\
+ })
+
#endif
OpenPOWER on IntegriCloud