[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH 2/3] plat/kvm, build: Implement the profle-generate and profile-use phase for PGO.



Call the __gcov_exit() function in a conditional way (using ifdef guard) in
the function ukplat_terminate(). Thus, the data file (*.gcda) is generated
within the Unikraft filesystem. Use 9pfs to transfer the *.gcda file from 
Unikraft
to the host system.

Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx>
---
 Makefile.uk         |  6 ++++--
 plat/kvm/shutdown.c | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index abc5475..e201785 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -36,10 +36,12 @@ COMPFLAGS-$(CONFIG_OPTIMIZE_LTO)          += -flto
 LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO)         += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y)
 LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y)
 
-# PGO
-COMPFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)          += -fprofile-generate
+# PGO - profile-generate phase
 LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)            += $(COMPFLAGS) 
$(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate
 
+# PGO - profile-use phase
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE)            += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y) -O3 -fprofile-use=main.gcda
+
 # ASAN
 COMPFLAGS-$(CONFIG_OPTIMIZE_ASAN)          += -fsanitize=address
 LDFLAGS-$(CONFIG_OPTIMIZE_ASAN)            += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y) -fsanitize=address
diff --git a/plat/kvm/shutdown.c b/plat/kvm/shutdown.c
index cce26b7..9ca909f 100644
--- a/plat/kvm/shutdown.c
+++ b/plat/kvm/shutdown.c
@@ -27,11 +27,38 @@
 #include <uk/print.h>
 #include <uk/plat/bootstrap.h>
 
+#if CONFIG_OPTIMIZE_PGO_GENERATE
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define GCOV_GENERATE_FILE     
"/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld/main.gcda"
+
+void create_hierarchy()
+{
+       mkdir("/home", 0777);
+       mkdir("/home/alice", 0777);
+       mkdir("/home/alice/Documents", 0777);
+       mkdir("/home/alice/Documents/Diploma", 0777);
+       mkdir("/home/alice/Documents/Diploma/Comp-opt", 0777);
+       mkdir("/home/alice/Documents/Diploma/Comp-opt/apps", 0777);
+       mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld", 0777);
+       mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build", 
0777);
+       
mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld",
 0777);
+}
+
+#endif
+
 static void cpu_halt(void) __noreturn;
 
 /* TODO: implement CPU reset */
 void ukplat_terminate(enum ukplat_gstate request __unused)
 {
+
+#if CONFIG_OPTIMIZE_PGO_GENERATE
+       create_hierarchy();
+       __gcov_exit();
+#endif
+
        uk_pr_info("Unikraft halted\n");
 
        /* Try to make system off */
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.