Live data from Hacker News

Evolution of the x86 context switch in Linux (2018)

maizure.org

1–10 of 35 posts

Re: Evolution of the x86 context switch in Linux (2018)

#3

Enjoyed this article, anybody know the significance of adding the do..while(0) loop within the macro starting Linux 1.3? Was curious if it guards against some C pre-processor issues. /** include/asm-i386/system.h */ #define switch_to(tsk) do { [...] } while (0)

Good answer here: https://stackoverflow.com/questions/257418/do-while-0-what-i...

Re: Evolution of the x86 context switch in Linux (2018)

#4

Enjoyed this article, anybody know the significance of adding the do..while(0) loop within the macro starting Linux 1.3? Was curious if it guards against some C pre-processor issues. /** include/asm-i386/system.h */ #define switch_to(tsk) do { [...] } while (0)

It enables you to invoke the macro as if it were an expression statement consisting of a function call, regardless of where it appears.

For details, see http://c-faq.com/cpp/multistmt.html:

Re: Evolution of the x86 context switch in Linux (2018)

#5
I really like how good the article looks when printed. I enjoy reading long, in-depth articles much more when I can read them in print. Unfortunately many blog posts need a lot of tweaking until I can get an acceptable print result. This one looks good enough without any trickery.

Thanks to the author, for caring about the paper people. : )

Re: Evolution of the x86 context switch in Linux (2018)

#8
An addition to "Linux 2.2 (1999)" is: introduced meltdown vulnerability. That was the then-unknown cost of software context switching.

Later, with Red Hat's 4g4g kernels that Linus rejected, the problem would go away for people who installed Red Hat's version of the OS on systems with many gigabytes of memory.

Re: Evolution of the x86 context switch in Linux (2018)

#10

I really like how good the article looks when printed. I enjoy reading long, in-depth articles much more when I can read them in print. Unfortunately many blog posts need a lot of tweaking until I can get an acceptable print result. This one looks good enough without any trickery. Thanks to the author, for caring about the paper people. : )

out of curiosity, since it changes how the page prints and I haven't experimented much: have you tried printing while in the browser's "reading" mode? Or does that tend to be worse?
Post reply on HN