Skip to content

Commit

Permalink
Check the app and process name
Browse files Browse the repository at this point in the history
Check whether app have the prop to use dgpu render:
  persist.vendor.intel.dGPUwSys+app_process_name
  persist.vendor.intel.dGPUwLocal+app_name
Also hardcode the latest Antutu pid as the
Antutu fork pid to run test.

Tracked-On: OAM-127209
Signed-off-by: He, Yue <[email protected]>
  • Loading branch information
yhe39 committed Dec 30, 2024
1 parent e68f165 commit f1284ae
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/intel/common/intel_check.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cutils/log.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
Expand All @@ -7,6 +8,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <stdbool.h>
#include <string.h>
#include <cutils/properties.h>
#include "util/macros.h"
#include "util/log.h"
Expand All @@ -26,35 +28,48 @@ get_pid_name(pid_t pid, char *task_name)
char process_path[BUF_SIZE];
char name_buf[BUF_SIZE];

sprintf(process_path, "/proc/%d/status", pid);
snprintf(process_path, sizeof(process_path), "/proc/%d/status", pid);
FILE* fp = fopen(process_path, "r");
if(NULL != fp){
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
fclose(fp);
}
if (fp == NULL) {
mesa_loge("failed to open %s\n", process_path);
return;
}
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
mesa_loge("get pid name fail\n");
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
return;
}
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
}

static bool
use_dgpu_render(char *target)
{
char dGPU_prop[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(dGPU_prop, "persist.vendor.intel.dGPU.%s", target);
snprintf(dGPU_prop, sizeof(dGPU_prop), "persist.vendor.intel.dGPUwSys.%s", target);
if (property_get(dGPU_prop, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
}
}
char dGPU_prop1[BUF_SIZE];
char vendor_buf1[PROPERTY_VALUE_MAX];
snprintf(dGPU_prop1, sizeof(dGPU_prop1), "persist.vendor.intel.dGPUwLocal%s", target);
   if (property_get(dGPU_prop1, vendor_buf1, NULL) > 0) {
      if (vendor_buf1[0] == '1') {
         return true;
}
}

return false;
}

static bool
is_target_process(const char *target)
{
static const char *str_char[] = { "k.lite:refinery", "k.lite:transfer", NULL };
static const char *str_char[] = { "nchmark.full:ue", ".fisheye", NULL };
const char **ptr = str_char;

// Prefer dGPU for compositing in surfaceflinger since dGPU covers more
Expand All @@ -65,9 +80,12 @@ is_target_process(const char *target)
for (ptr = str_char; *ptr != NULL; ptr++) {
if (!strcmp(target, *ptr)) {
char vendor_buf[PROPERTY_VALUE_MAX];
if (property_get("persist.vendor.intel.dGPU.ABenchMark.lite",
vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
char vendor_buf1[PROPERTY_VALUE_MAX];
if ((property_get("persist.vendor.intel.dGPUwSys.tutu.ABenchMark",
vendor_buf, NULL) > 0) ||
(property_get("persist.vendor.intel.dGPUwLocal.ABenchMark",
vendor_buf1, NULL) > 0)) {
if ((vendor_buf[0] == '1') || (vendor_buf1[0] == '1')) {
return true;
}
}
Expand All @@ -82,7 +100,8 @@ bool intel_is_dgpu_render(void)
char process_name[BUF_SIZE];

get_pid_name(process_id, process_name);
return (use_dgpu_render(process_name) || is_target_process(process_name));
char *app_name = strrchr(process_name, '.');
return (use_dgpu_render(process_name) || is_target_process(process_name) || use_dgpu_render(app_name));
}

bool intel_lower_ctx_priority(void)
Expand All @@ -93,7 +112,7 @@ bool intel_lower_ctx_priority(void)

char lower_pri[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(lower_pri, "persist.vendor.intel.lowPir.%s",process_name);
snprintf(lower_pri, sizeof(lower_pri), "persist.vendor.intel.lowPir.%s", process_name);
if (property_get(lower_pri, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
Expand Down

0 comments on commit f1284ae

Please sign in to comment.