summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-09-20 11:33:33 -0500
committerDerek Foreman <derekf@osg.samsung.com>2016-09-20 11:38:57 -0500
commite2875cefc49768f919919fbfa478f81570168688 (patch)
treee67252283f4c8bc2c34c81cd40c75ed32437bbf3 /src
parent58d3328d80aec2249b681e0d791e562a2b399c47 (diff)
eina_cpu, evas: Remove _eina_cpu_fast_core_get, don't set render thread affinity
We've decided it would be best to just let the scheduler do its job.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Eina.am1
-rw-r--r--src/lib/eina/eina_cpu.c117
-rw-r--r--src/lib/eina/eina_cpu_private.h42
-rw-r--r--src/lib/evas/common/evas_thread_render.c13
4 files changed, 2 insertions, 171 deletions
diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index 96ff37657f..22ade8feba 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -58,7 +58,6 @@ lib/eina/eina_trash.h \
58lib/eina/eina_iterator.h \ 58lib/eina/eina_iterator.h \
59lib/eina/eina_main.h \ 59lib/eina/eina_main.h \
60lib/eina/eina_cpu.h \ 60lib/eina/eina_cpu.h \
61lib/eina/eina_cpu_private.h \
62lib/eina/eina_inline_cpu.x \ 61lib/eina/eina_inline_cpu.x \
63lib/eina/eina_sched.h \ 62lib/eina/eina_sched.h \
64lib/eina/eina_tiler.h \ 63lib/eina/eina_tiler.h \
diff --git a/src/lib/eina/eina_cpu.c b/src/lib/eina/eina_cpu.c
index 9f4ab4b0be..3ec92046d4 100644
--- a/src/lib/eina/eina_cpu.c
+++ b/src/lib/eina/eina_cpu.c
@@ -49,25 +49,12 @@
49#include "eina_log.h" 49#include "eina_log.h"
50#include "eina_cpu.h" 50#include "eina_cpu.h"
51 51
52#include <Eina.h>
53
54#include "eina_cpu_private.h"
55
56#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
57# include <sys/auxv.h>
58# include <asm/hwcap.h>
59#endif
60
61/*============================================================================* 52/*============================================================================*
62* Local * 53* Local *
63*============================================================================*/ 54*============================================================================*/
64 55
65static void _eina_page_size(void); 56static void _eina_page_size(void);
66 57
67static int fastest_core_speed = 0;
68static int slowest_core_speed = INT_MAX;
69static Eina_Hash *cpu_hash = NULL;
70
71/* FIXME this ifdefs should be replaced */ 58/* FIXME this ifdefs should be replaced */
72#if defined(__i386__) || defined(__x86_64__) 59#if defined(__i386__) || defined(__x86_64__)
73/* We save ebx and restore it to be PIC compatible */ 60/* We save ebx and restore it to be PIC compatible */
@@ -178,9 +165,6 @@ eina_cpu_init(void)
178Eina_Bool 165Eina_Bool
179eina_cpu_shutdown(void) 166eina_cpu_shutdown(void)
180{ 167{
181 eina_hash_free(cpu_hash);
182 cpu_hash = NULL;
183 fastest_core_speed = 0;
184 return EINA_TRUE; 168 return EINA_TRUE;
185} 169}
186 170
@@ -316,104 +300,3 @@ void eina_cpu_count_internal(void)
316 else 300 else
317 _cpu_count = _eina_cpu_count_internal(); 301 _cpu_count = _eina_cpu_count_internal();
318} 302}
319
320static void
321eina_cpu_map_init(void)
322{
323 fastest_core_speed = -1;
324
325#if defined (__linux__) || defined(__GLIBC__)
326 FILE *f = NULL;
327 Eina_Iterator *it;
328 Eina_Strbuf *fname;
329 const Eina_File_Direct_Info *f_info;
330
331 it = eina_file_stat_ls("/sys/devices/system/cpu/cpufreq");
332 if (!it) return;
333
334 cpu_hash = eina_hash_int32_new(free);
335
336 fname = eina_strbuf_new();
337 EINA_ITERATOR_FOREACH(it, f_info)
338 {
339 if ((f_info->type == EINA_FILE_DIR) &&
340 eina_str_has_prefix(f_info->path,
341 "/sys/devices/system/cpu/cpufreq/policy"))
342 {
343 int num, speed;
344
345 eina_strbuf_append_printf(fname, "%s%s", f_info->path, "/cpuinfo_max_freq");
346 f = fopen(eina_strbuf_string_get(fname), "r");
347 eina_strbuf_reset(fname);
348 if (!f) goto err;
349 speed = -1;
350 num = fscanf(f, "%d", &speed);
351 fclose(f);
352 f = NULL;
353 if ((num != 1) || (speed == -1)) goto err;
354
355 slowest_core_speed = MIN(speed, slowest_core_speed);
356 fastest_core_speed = MAX(speed, fastest_core_speed);
357
358 eina_strbuf_append_printf(fname, "%s%s", f_info->path, "/affected_cpus");
359 f = fopen(eina_strbuf_string_get(fname), "r");
360 eina_strbuf_reset(fname);
361 if (!f) goto err;
362 do
363 {
364 int core;
365 uint64_t *corelist;
366 num = fscanf(f, "%d", &core);
367 if ((num == EOF) || (core > 63)) break;
368
369 corelist = eina_hash_find(cpu_hash, &speed);
370 if (!corelist)
371 {
372 corelist = malloc(sizeof(*corelist));
373 if (!corelist) goto err;
374 *corelist = 1LL << core;
375 eina_hash_add(cpu_hash, &speed, corelist);
376 }
377 *corelist |= 1LL << core;
378 } while (num != EOF);
379 fclose(f);
380 f = NULL;
381 }
382 }
383err:
384 if (f) fclose(f);
385 eina_strbuf_free(fname);
386 eina_iterator_free(it);
387#endif
388}
389
390EAPI int
391_eina_cpu_fast_core_get(void)
392{
393#if defined (__linux__) || defined(__GLIBC__)
394 uint64_t *corelist;
395 uint64_t cores;
396 int bit, place = 0;
397
398 if (fastest_core_speed == -1) return -1;
399
400 if (fastest_core_speed == 0) eina_cpu_map_init();
401
402 /* Check again now that it's actually set up */
403 if (fastest_core_speed == -1) return -1;
404
405 corelist = eina_hash_find(cpu_hash, &fastest_core_speed);
406 cores = *corelist;
407 bit = rand() % __builtin_popcount(cores);
408 while (bit || !(cores & 1))
409 {
410 if (cores & 1) bit--;
411 cores = cores >> 1;
412 place++;
413 }
414
415 return place;
416#else
417 return 0;
418#endif
419}
diff --git a/src/lib/eina/eina_cpu_private.h b/src/lib/eina/eina_cpu_private.h
deleted file mode 100644
index e114b01b95..0000000000
--- a/src/lib/eina/eina_cpu_private.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef EINA_CPU_PRIVATE_H_
2#define EINA_CPU_PRIVATE_H_
3
4#ifdef EAPI
5# undef EAPI
6#endif
7
8#ifdef _WIN32
9# ifdef EFL_EINA_BUILD
10# ifdef DLL_EXPORT
11# define EAPI __declspec(dllexport)
12# else
13# define EAPI
14# endif /* ! DLL_EXPORT */
15# else
16# define EAPI __declspec(dllimport)
17# endif /* ! EFL_EINA_BUILD */
18# define EAPI_WEAK
19#else
20# ifdef __GNUC__
21# if __GNUC__ >= 4
22# define EAPI __attribute__ ((visibility("default")))
23# define EAPI_WEAK __attribute__ ((weak))
24# else
25# define EAPI
26# define EAPI_WEAK
27# endif
28# else
29/**
30 * @def EAPI
31 * @brief Used to export functions(by changing visibility).
32 */
33# define EAPI
34# endif
35#endif
36
37EAPI int _eina_cpu_fast_core_get(void);
38
39#undef EAPI
40#define EAPI
41
42#endif
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c
index 3489c5ad08..99c6b95c3c 100644
--- a/src/lib/evas/common/evas_thread_render.c
+++ b/src/lib/evas/common/evas_thread_render.c
@@ -1,5 +1,4 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "eina_cpu_private.h"
3 2
4#include <assert.h> 3#include <assert.h>
5 4
@@ -126,7 +125,6 @@ out:
126void 125void
127evas_thread_init(void) 126evas_thread_init(void)
128{ 127{
129 int core;
130 if (init_count++) return; 128 if (init_count++) return;
131 129
132 eina_threads_init(); 130 eina_threads_init();
@@ -138,16 +136,9 @@ evas_thread_init(void)
138 if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock)) 136 if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock))
139 CRI("Could not create draw thread condition"); 137 CRI("Could not create draw thread condition");
140 138
141 core = _eina_cpu_fast_core_get(); 139 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1,
142 /* Keep previous behaviour of pinning to core 0 if finding a fast
143 * core fails.
144 */
145 if (core < 0) core = 0;
146 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, core,
147 evas_thread_worker_func, NULL)) 140 evas_thread_worker_func, NULL))
148 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1, 141 CRI("Could not create draw thread");
149 evas_thread_worker_func, NULL))
150 CRI("Could not create draw thread");
151} 142}
152 143
153void 144void