Page MenuHomeFreeBSD

Add a way to distinguish between forking and thread creation in schedtail.
ClosedPublic

Authored by ed on Oct 22 2015, 8:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 15 2024, 11:17 PM
Unknown Object (File)
Feb 15 2024, 11:17 PM
Unknown Object (File)
Feb 15 2024, 11:17 PM
Unknown Object (File)
Feb 15 2024, 11:05 PM
Unknown Object (File)
Feb 15 2024, 10:48 PM
Unknown Object (File)
Nov 7 2023, 6:20 PM
Unknown Object (File)
Nov 7 2023, 1:07 AM
Unknown Object (File)
Oct 6 2023, 5:15 PM
Subscribers

Details

Summary

For CloudABI we need to initialize the registers of new threads
differently based on whether the thread got created through a fork or
through simple thread creation.

Add a flag, TDP_FORKING, that is set by do_fork() and cleared by
fork_exit(). This can be tested against in schedtail.

Test Plan

This seems to work all right for CloudABI.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ed retitled this revision from to Add a way to distinguish between forking and thread creation in schedtail..
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added reviewers: kib, andrew.
kib edited edge metadata.

You might conisder adding assert to the syscallret() that TDP_FORKING is not seen there. The assert cannot be added to userret(), unfortunately.

sys/kern/kern_fork.c
474 ↗(On Diff #9601)

td2->td_pflags is modified at line 589, you may or TDP_FORKING there as well.

This revision is now accepted and ready to land.Oct 22 2015, 9:03 AM
In D3973#82745, @kib wrote:

You might conisder adding assert to the syscallret() that TDP_FORKING is not seen there. The assert cannot be added to userret(), unfortunately.

That sounds like a good idea!

Out of curiosity, why isn't this possible to do in userret()? Is it because traps may occur while the process is being forked?

ed edited edge metadata.
ed marked an inline comment as done.

Add an assertion to make sure TDP_FORKING is never left set.

This revision now requires review to proceed.Oct 22 2015, 9:23 AM
kib edited edge metadata.
In D3973#82755, @ed wrote:

Out of curiosity, why isn't this possible to do in userret()? Is it because traps may occur while the process is being forked?

The call chain is fork_exit()->callout == fork_return()->userret(), with the TDP_FORKING flag still set.

This revision is now accepted and ready to land.Oct 22 2015, 9:32 AM
This revision was automatically updated to reflect the committed changes.