Nekotekina
8efc22bd45
atomic.hpp: simplify and unify bit test instructions
...
Also make them available on all platform.
Rename some rare methods.
2020-12-04 14:33:38 +03:00
Nekotekina
0892758994
Minor debugging enhancement
...
Use raise(SIGTRAP) in failed SIGSEGV handling and return.
2020-11-26 20:11:26 +03:00
Nekotekina
22a24446c1
Threads: fix minor race
...
Has already been in "fixed" state in past...
2020-11-26 20:11:26 +03:00
Nekotekina
b5d498ffda
Homebrew atomic_ptr rewritten (util/shared_ptr.hpp)
...
It's analogous to C++20 atomic std::shared_ptr
The following things brought into global namespace:
single_ptr
shared_ptr
atomic_ptr
make_single
2020-11-26 20:11:26 +03:00
Nekotekina
43952e18e2
Implement prefetch_write() and prefetch_exec() wrappers
...
Do some refactoring to prefetch_read() in util/asm.hpp as well.
Make all these function constexpr because they are no-ops.
2020-11-24 12:31:11 +03:00
Nekotekina
b954a41f2a
Threads: minor simplification
2020-11-24 01:09:04 +03:00
Nekotekina
d4c17ecda5
Simplify communication with thread pool
...
Add "entry_point" member to "thread_base".
Don't use "m_thread" to exchange values.
2020-11-23 11:32:34 +03:00
Nekotekina
a4458e2c8c
Clean thread pool at exit.
...
Execute TLS destructors.
Test atomic wait list.
2020-11-23 10:20:42 +03:00
Nekotekina
71f1021648
Fix thread pool entry point and get_cycles()
...
Fix possible race between thread handle availability.
Don't treat zero thread as invalid one.
Now entry point is full is assembly.
Attempt to fix #9282
Also fix some TLS.
2020-11-21 17:18:42 +03:00
Nekotekina
d789250976
Add thread_ctrl::get_thread_stack
...
Returns addr and size of current thread's stack.
2020-11-17 05:33:46 +03:00
Nekotekina
dfae7bd073
SPU: Fix some stat printing
2020-11-15 04:41:16 +03:00
Nekotekina
badb3dc2dd
atomic.cpp/threads: remove old wait callback
...
Add new wait callback which simply collects statistics.
Shift workarounds towards actual problem detection.
2020-11-14 18:16:27 +03:00
Nekotekina
0c7f9458c0
Fix thread pool resource management.
...
Make sure no tail call happens (change ret address to a trampoline).
Make sure thread handles don't leak if the pool is full.
2020-11-13 17:17:45 +03:00
Nekotekina
ab365fe494
Fixed thread pool a bit
...
Use 128-bit allocator instead of queue.
When pool is full (128), threads just terminate as before.
2020-11-13 13:32:44 +03:00
Nekotekina
67785a918c
Implement simple thread pool
2020-11-13 03:32:24 +03:00
RipleyTom
1378645413
Adds SIGPIPE to ignored exceptions(unix)
2020-11-12 07:08:59 +03:00
Eladash
829a697c39
Fix vm::check_addr calls in Thread.cpp
2020-11-11 17:40:46 +03:00
Nekotekina
1c99a2e7fb
vm: add map_self() method to utils::shm
...
Add complementary unmap_self() method.
Move VirtualMemory to util/vm.hpp
Minor associated include cleanup.
Move asm.h to util/asm.hpp
2020-11-08 16:43:15 +03:00
Nekotekina
557f0c5a8a
atomic.cpp: remove load() from notify functions
...
Only compare masks for overlap for second overload (with mask provided).
Explicit "new value" can be provided in new 3-arg overloads.
Also rename atomic_storage_futex -> atomic_wait_engine.
2020-11-06 04:44:31 +03:00
Nekotekina
34fa010601
Improve cond_var notifiers
...
But nobody uses it anyway, so clean up includes.
2020-11-06 00:10:16 +03:00
Nekotekina
5248240e10
atomic.cpp: improvements.
...
Reduced static memory amount for waitable atomics.
Allow notifier to skip notifications if wait/notify masks don't overlap.
Improve raw_notify to wake up the thread by its id, add thread_id arg.
Add optional mask argument to notify_one() and notify_all().
2020-11-05 05:51:43 +03:00
Nekotekina
ba5ed5f380
Fix vm::lock_range wrong check
...
Minor header refactoring.
2020-11-04 14:59:26 +03:00
Megamouse
2cee26c3e7
Cleanup some includes
2020-10-31 11:53:46 +01:00
Nekotekina
f972fa26a4
Derive RSX Replay thread from cpu_thread
...
Its id is set to 0, so fix some id_type() usages.
2020-10-30 17:36:11 +03:00
Nekotekina
6806e3d5c7
atomic.cpp: implement notify callback
...
Notification can be very heavy, especially if we need to wake many threads.
Callback is set for cpu_thread in order to set wait flag accordingly.
2020-10-27 17:56:19 +03:00
Nekotekina
10caa2981f
Improve raw_notify a bit
2020-10-24 14:16:32 +03:00
Eladash
3c935f7834
SPU: Fix minor segfaults ( #9015 )
...
SPU: Remove "RawSPU Not Found" exception.
Fix edge case in access violation handler.
2020-10-11 14:59:18 +03:00
Eladash
a029a94c73
SPU: Use waitable atomics for SPU channels interface
2020-07-23 13:45:58 +03:00
Eladash
c37bc3c55c
SPU: Make spu_thread::offset private
2020-07-19 17:58:49 +03:00
Eladash
d86c9a2549
sys_mmapper: rewrite page fault thread notifications
...
* Fix a corner case where SPU thread has the same ID as a PPU thread.
* Fix a potential deadlock on Emu.Stop() while sending event in EBUSY loop.
* Thread specific notifications.
2020-06-18 20:13:54 +03:00
Eladash
b8f86eb78d
SPU: Fix page faults notifications
2020-05-23 00:48:28 +03:00
Nekotekina
e1042bc631
Get rid of "module" keyword
...
Workaround some intellisense problems.
2020-05-06 18:20:11 +03:00
Nekotekina
a6f0b1b532
Fix get_thread_affinity_mask (Linux/BSD)
...
Uninitialized variable (facepalm).
2020-05-05 21:44:32 +03:00
Nekotekina
31035608ee
Use utils::get_cpu_brand when applicable
2020-05-01 22:00:57 +03:00
Nekotekina
f6200ba635
Implement thread_ctrl::get_process_affinity_mask()
2020-05-01 22:00:56 +03:00
Nekotekina
76294beae1
Implement thread_ctrl::get_thread_affinity_mask()
2020-04-29 00:09:40 +03:00
Nekotekina
d0c199d455
Replace utils::cnttz{32,64} with std::countr_{zero,one}
...
Make #include <bit> mandatory.
2020-04-14 16:05:58 +03:00
Eladash
c3a4e57efe
Reduce log level of page fault notifications
...
Log current hle function.
2020-04-12 10:30:38 +01:00
Nick Renieris
1231274e0f
CPUThread: Split dump() info to separate methods
2020-04-03 01:36:35 +01:00
Megamouse
a76a4d8136
change sig_log to SIG
2020-03-31 18:06:37 +02:00
Jan Beich
777f0a7c82
Implement IsDebuggerPresent on BSDs ( #7880 )
2020-03-28 01:57:41 +00:00
Nekotekina
7f5dd1dd62
Fix thread_base::join
2020-03-21 10:36:04 +03:00
Nekotekina
c577bd2111
Implement thread_state::errored
...
State after calling thread emergency_exit() function.
Also default-construct thread result in this case.
2020-03-20 21:31:27 +03:00
Eladash
cb4192bce9
vm: Log all guest memory bases at startup
2020-03-14 18:30:14 +02:00
Nekotekina
04dedb17eb
Disable exception handling.
...
Use -fno-exceptions in cmake.
On MSVC, enable _HAS_EXCEPTION=0.
Cleanup throw/catch from the source.
Create yaml.cpp enclave because it needs exception to work.
Disable thread_local optimizations in logs.cpp (TODO).
Implement cpu_counter for cpu_threads (moved globals).
2020-03-12 16:03:08 +03:00
Nekotekina
6bd96a4590
Fix thread_base::finalize (and emergency_exit, collaterally)
...
Forgot to reset futex callback. Could cause crashes.
2020-03-10 23:23:32 +03:00
Nekotekina
1678b37aa0
Use TRAP on segfault with debugger (Linux)
2020-03-10 14:06:06 +03:00
Nekotekina
adfd8ab43c
Break in the debugger in thread_ctrl::emergency_exit
...
Implement IsDebuggerPresent analog for non-Windows systems.
2020-03-10 13:28:24 +03:00
Nekotekina
87d4b14ca9
Pause only on fatal messages
...
Also make some access violation an error since we don't pause on it.
2020-03-10 11:26:42 +03:00
Nekotekina
07e1766a7c
Implement thread_ctrl::emergency_exit()
...
Replace exception throws with this.
2020-03-08 15:11:02 +03:00
Nekotekina
e4a81b1d13
Move Log.h to util/logs.hpp
2020-03-07 12:29:23 +03:00
Nekotekina
7a8772dafa
Replace std::string::npos with umax
2020-03-05 14:05:23 +03:00
Eladash
bb1b4bac9b
Update thread_base::notify_abort()
2020-03-04 14:39:41 +03:00
Nekotekina
8d847d6f1c
Thread: internal cleanup
...
Use different, simpler algorithm in wait_for.
Although the very idea of such notifications was rotten.
2020-03-03 20:26:37 +03:00
Nekotekina
6c66153372
Threads: move linux m_timer to static thread_local variable
...
Allows lazy allocation of the timer handle.
2020-03-03 18:33:02 +03:00
Nekotekina
cb252b1ce2
Partial revert of 5871c4e93f
2020-02-29 18:39:15 +03:00
Eladash
5871c4e93f
Segfault/exceptions reports: Get rid of unhandled exeption handler, log memory bases
...
* Getting rid of handled exception handler fixes 2 things:
- Visual Studio debugger won't force it's own handler on unhandled exception.
- SPU segfaults in recompiler can now be reported.
* Log vm memory bases.
2020-02-29 17:16:36 +03:00
Nekotekina
799c3f9708
Remove global thread counter (again)
...
Seems fine without it now.
2020-02-28 21:50:19 +03:00
Nekotekina
490f58ff3c
Try to purge thread_state::detached
...
It's rarely necessary, but can cause unexpected problems.
2020-02-28 21:11:13 +03:00
Nekotekina
65eeee0f4c
Remove cancerous lf_value<>
...
Replace thread names (generic, PPU, SPU) with new shared pointers.
Devirtualize cpu_thread::get_name (used in single case).
2020-02-28 18:54:46 +03:00
Nekotekina
7eebe06931
Restore thread counter (world may be not ready yet)
...
Remove dumb 1300ms timeout.
2020-02-25 11:51:19 +03:00
Nekotekina
e772dde3cc
Add more thread information (context switch, page faults).
...
Only implemented on Linux, possibly works on some BSD.
2020-02-23 16:21:26 +03:00
Eladash
6bb083a77c
Add more information for segfault reports ( #7538 )
2020-02-22 10:58:42 +00:00
Nekotekina
92e3eaf3ff
Fix signed-unsigned comparisons and mark warning as error (part 2).
2020-02-19 22:54:58 +03:00
Megamouse
fe75311be2
move config structs to own files and clean up some headers
2020-02-17 15:08:17 +03:00
Eladash
606693a9f7
Avoid closing the emulator after access violation
2020-02-13 14:14:28 +03:00
Eladash
639245c071
Make handle_access_violation noexcept
2020-02-10 17:27:34 +03:00
Nekotekina
1a78e0e80c
Make RPCS3 compile in C++2a mode
2020-02-04 23:43:55 +03:00
Nekotekina
327bb2d8f0
Modernize PPU logging (ppu_log variable)
2020-02-01 11:52:24 +03:00
Nekotekina
15391f45d0
Modernize RSX logging (rsx_log variable)
2020-02-01 11:52:22 +03:00
Nekotekina
3c0bd821c8
Give log channels fancier names
...
Improve LOG_CHANNEL macro to accept custom name.
2020-02-01 10:43:43 +03:00
Nekotekina
26cccead6e
logs: remove legacy MEMORY channel
...
Add channels vm_log, sig_log.
2020-01-31 16:44:48 +03:00
Nekotekina
69e81da57b
Fix some warnings
2019-12-13 02:08:52 +03:00
Eladash
5631382623
sys_spu: Fix SPU Thread Id
...
* Removed wrong code in sys_spu_thread_group_terminate.
* SPU Thread ID is accurate, including 5th thread id "rule".
* Fixed possible use-after-free access of spu_thread::group member.
* RawSPU ID management simplified.
2019-12-06 19:59:29 +03:00
Eladash
c3862b74b1
Compilation fix for NetBSD ( #7067 )
2019-12-05 11:28:00 +03:00
Nekotekina
835892aa51
C-style cast cleanup VII
2019-12-05 02:10:15 +03:00
Nekotekina
5b9df53c13
C-style cast cleanup (partial)
...
Replace C-style casts with C++ casts.
2019-11-29 00:35:23 +03:00
MSuih
f3ed26e9db
Small warnings cleanup ( #6671 )
...
* Ignore more warnings
These are intentional
* Signed/unsigned mismatch when comparing
* Explictly cast values
* Intentionally discard a nodiscard value
* Change ppu_tid to u32
* Do not use POSIX function name on Windows
* Qt: Use horizontalAdvance instead of width
* Change progress variables to u32
2019-10-25 13:32:21 +03:00
Nekotekina
8e21f4d5d4
Remove g_thread_count
...
Unnecessary global which is bad to reason about.
Possibly fix a but in SPRX loader.
2019-10-12 16:45:41 +03:00
plappermaul
925f2ce02f
Use Linux timers for sleeps up to 1ms ( #6697 )
...
* Use Linux timers for sleeps up to 1ms (v3)
The current sleep timer implementation basically offers two variants. Either
wait the specified time exactly with a condition variable (as host) or use a
combination of it with a thread yielding busy loop afterwards (usleep timer).
While the second one is very precise it consumes CPU loops for each wait call
below 50us. Games like Bomberman Ultra spam 30us waits and the emulator hogs
low power CPUs. Switching to host mode reduces CPU consumption but gives a
~50us penalty for each wait call. Thus extending all sleeps by a factor of
more than two.
The following bugfix tries to improve the system timer for Linux by using
Linux native timers for small wait calls below 1ms. This has two effects.
- Host wait setting has much less wait overhead
- usleep wait setting produces lower CPU overhead
2019-10-09 20:03:34 +03:00
Nekotekina
8031180373
Add dummy alert param to thread_ctrl::wait API
2019-10-06 16:03:10 +03:00
Nekotekina
c1b0934f72
Simplify thread_base::join()
...
Use waitable atomics
2019-09-10 19:25:39 +03:00
Nekotekina
d13ff285d1
Rewrite cond_variable
to use waitable atomics
...
Increase max_timeout and fix max_timeout usage
2019-09-10 19:25:39 +03:00
Nekotekina
faba366f89
named_thread: install atomic wait callback
2019-09-10 18:48:46 +03:00
Jan Beich
53e7f6c5a5
Thread: drop is_leaf_function after 5e3bacbd9b
2019-09-10 17:41:15 +03:00
Nekotekina
2740fafa64
Use g_fxo for page_fault_notification_entries
2019-08-22 02:13:39 +03:00
Nekotekina
a85a8796d3
Use g_fxo for page_fault_event_entries
2019-08-22 02:13:39 +03:00
Nekotekina
f8f3067deb
Always check page_allocated in vm::check_addr
2019-08-14 20:28:34 +03:00
Eladash
997e3046e3
vm/sys_overlay Improvements
...
- Implement sys_overlay_load_module_by_fd.
- Implement special segment allocation when ppc_seg flag is specified.
2019-07-28 14:23:58 +03:00
Zangetsu38
a98a2b79d0
thread scheduler: Add scheduler for zen2 and refactor for zen(+).
2019-07-21 23:02:11 +03:00
Nekotekina
4e4c896136
Expand thread affinity mask to u64
...
Also fix and note __APPLE__ path.
2019-07-20 15:58:28 +03:00
Eladash
c727760537
Fix g_exec_addr addres check for access violations
2019-07-13 16:59:58 +03:00
Eladash
537d3f2548
Log last function on debug pause or exception, dump cpu_thread state on access violation
2019-07-10 17:35:39 +03:00
eladash
0979207cc6
Log currently PPU HLE function executed after access violation
...
old functionality retrieved
2019-07-10 17:35:39 +03:00
JohnHolmesII
232a35b6fc
Various small warning fixes
...
-Indentation warnings
-prevent shift overflow
-This was declared extern in all contexts. Remove this for initialization
-Fix main return types. OH CANADA!
-Silence extraneos 'unused expression' warning
-Force use return value (warning)
-Remove tautological compare copy-pasta (char always < 256)
2019-06-28 01:45:29 +03:00
JohnHolmesII
be521ff0ab
Fix warnings related to parentheses
2019-06-25 20:36:32 -07:00
Nekotekina
5d45a3e47d
Implement cpu_thread::suspend_all
...
Remove Accurate PUTLLC option.
Implement fallback path for SPU transactions.
2019-06-19 20:36:12 +03:00
eladash
a3f65084df
Fix sys_process_exit2 when SPUs are at av handler
2019-03-31 14:57:21 +03:00
eladash
16f86b2458
Fix page fault area range check
...
Range end check was bugged (always true), also rewrite it so vm::get would be called only once
2019-03-31 14:57:21 +03:00
Jan Beich
1a13d3ae4e
OpenBSD doesn't have mcontext_t
...
`<signal.h>` provides `typedef struct sigcontext ucontext_t`
2019-03-19 22:24:49 +03:00