Re: Differences between FreeBSD and Linux system call mechanism

Linus Torvalds (torvalds@transmeta.com)
3 Sep 1998 23:34:02 GMT


In article <199809032240.PAA02629@usr09.primenet.com>,
Terry Lambert <tlambert@primenet.com> wrote:
>> > Linux uses a call-gate based kernel entry, which is TSS based, and
>> > therefore takes more CPU cycles on a contect switch than strictly
>> > required. The FreeBSD mechanism for kernel entry (and subsequet
>> > context switch) is threfore more efficient than that used by Linux.
>>
>> I'm starting to wonder. Terry normally knows what he is talking about,
>> but this posting seems to contain various mistakes:
>>
>> 1) Linux system calls are done using software interrupt 0x80 on ia32.
>> Does this qualify as a "call-gate based kernel entry"?
>
>"call-gate" should be "task-gate" here.

So? Linux doesn't use them. You're out to lunch, Terry.

>> 2) I don't see the connection between kernel entry and TSS based task
>> switch.
>
>The task switch is implemented by selecting a Tassk Gate descriptor in
>either the GDT or the LDT.

Yes. But it has absolutely _nothing_ to do with system calls.

Using a TSS is required on a x86 in protected mode. It's not optional.
You need at least one, to contain the %esp0 and %ss0 information that
any task will need. You also tend to need it whenever you do any
finegrained IO permission thing from user mode etc.

Linux happens to use one per process, which makes a ton of sense if you
actually know whhat they are used for.

>> Mingo already has patches that replace the current TSS method
>> with software based context switchs.
>
>Good. When these changes have been integrated into the mainstream
>releases, Linux will be as fast as FreeBSD in this regard.

Grow up, Terry. All the benchmarks show fairly clearly that Linux is not
"as fast", but noticeably faster.

The fastest way to enter kernel mode (not counting the new SYSENTER
instruction) is to use a trap gate. Which is what Linux did from day
one.

Linux uses the TSS for context switching of _processes_, not for system
calls. And Terry, if you had bothered to do any benchmarks instead of
just posting stuff that has no basis in reality, you would have seen
that Linux is doing very well indeed both for system calls and context
switches.

But you didn't want to taint your wild theories with anything remotely
resembling truth, now did you?

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html