Re: [go-nuts] Are M always detached from P when syscall?

2019-11-15 Thread Ian Lance Taylor
On Fri, Nov 15, 2019 at 7:27 PM Vincent Blanchon
 wrote:
>
> I was wondering about the behavior of syscalls. It looks like Go always wraps 
> syscall - whatever blocking or not - with calling entersyscallblock() and 
> exitsyscall() later. The first one automatically detaches M from the P  when 
> exit tries to acquire the same P or move the G to the global queue. In the 
> case of non-blocking syscall, why do we have to detach M from the P?
> Did I miss something?

For system calls that are absolutely known to never block, like
getuid, Go does not use entersyscall/exitsyscall.  It just makes the
syscall.

But most system calls can block.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXcdeJmBc5J7SJjxjQwYx%2BBVTe00-BeKkjstMCj2-iUZQ%40mail.gmail.com.


Re: [go-nuts] Are M always detached from P when syscall?

2019-11-15 Thread Robert Engels
I’m pretty sure that if you look deeper not every call ends in “blocking” at 
least at the os level. Go uses green threads and relies on os level “poll type” 
support. It has the overhead of its own scheduler but in most cases it is more 
efficient than the os one. 

> On Nov 15, 2019, at 9:52 PM, Kurtis Rader  wrote:
> 
> 
>> On Fri, Nov 15, 2019 at 7:27 PM Vincent Blanchon 
>>  wrote:
> 
>> I was wondering about the behavior of syscalls. It looks like Go always 
>> wraps syscall - whatever blocking or not - with calling entersyscallblock() 
>> and exitsyscall() later. The first one automatically detaches M from the P  
>> when exit tries to acquire the same P or move the G to the global queue. In 
>> the case of non-blocking syscall, why do we have to detach M from the P?
> 
> I can't speak to the rationale for Go's behavior. But whether a particular 
> syscall can ever block is a more difficult question than you seem to think. 
> And don't forget about CPU context switches.
> 
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-Asd562aLVDssQWvS9JsOK8q2Zd_2rGJ2PwLm1zG1hgQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/A4A94193-85C2-4960-AFED-246B207DA639%40ix.netcom.com.


Re: [go-nuts] Are M always detached from P when syscall?

2019-11-15 Thread Kurtis Rader
On Fri, Nov 15, 2019 at 7:27 PM Vincent Blanchon 
wrote:

> I was wondering about the behavior of syscalls. It looks like Go always
> wraps syscall - whatever blocking or not - with calling entersyscallblock()
> and exitsyscall() later. The first one automatically detaches M from the P
>  when exit tries to acquire the same P or move the G to the global queue.
> In the case of non-blocking syscall, why do we have to detach M from the P?
>

I can't speak to the rationale for Go's behavior. But whether a particular
syscall can ever block is a more difficult question than you seem to think.
And don't forget about CPU context switches.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-Asd562aLVDssQWvS9JsOK8q2Zd_2rGJ2PwLm1zG1hgQ%40mail.gmail.com.


[go-nuts] Are M always detached from P when syscall?

2019-11-15 Thread Vincent Blanchon
Hello,


I was wondering about the behavior of syscalls. It looks like Go always 
wraps syscall - whatever blocking or not - with calling entersyscallblock() 
and exitsyscall() later. The first one automatically detaches M from the P 
 when exit tries to acquire the same P or move the G to the global queue. 
In the case of non-blocking syscall, why do we have to detach M from the P?
Did I miss something?

Thanks in advance for anyone that could clarify that.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f88b2609-19d5-47a5-a2e4-f5900d265622%40googlegroups.com.