Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
a433c908
Commit
a433c908
authored
5 years ago
by
Ben Gamari
Browse files
Options
Downloads
Patches
Plain Diff
Fix #17289
parent
25b9c7f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rts/Capability.c
+17
-9
17 additions, 9 deletions
rts/Capability.c
rts/Timer.c
+2
-2
2 additions, 2 deletions
rts/Timer.c
with
19 additions
and
11 deletions
rts/Capability.c
+
17
−
9
View file @
a433c908
...
@@ -418,36 +418,44 @@ void
...
@@ -418,36 +418,44 @@ void
moreCapabilities
(
uint32_t
from
USED_IF_THREADS
,
uint32_t
to
USED_IF_THREADS
)
moreCapabilities
(
uint32_t
from
USED_IF_THREADS
,
uint32_t
to
USED_IF_THREADS
)
{
{
#if defined(THREADED_RTS)
#if defined(THREADED_RTS)
uint32_t
i
;
Capability
**
new_capabilities
=
stgMallocBytes
(
to
*
sizeof
(
Capability
*
),
"moreCapabilities"
);
Capability
**
old_capabilities
=
capabilities
;
capabilities
=
stgMallocBytes
(
to
*
sizeof
(
Capability
*
),
"moreCapabilities"
);
// We must disable the timer while we do this since the tick handler may
// call contextSwitchAllCapabilities, which may see the capabilities array
// as we free it. The alternative would be to protect the capabilities
// array with a lock but this seems more expensive than necessary.
// See #17289.
stopTimer
();
if
(
to
==
1
)
{
if
(
to
==
1
)
{
// THREADED_RTS must work on builds that don't have a mutable
// THREADED_RTS must work on builds that don't have a mutable
// BaseReg (eg. unregisterised), so in this case
// BaseReg (eg. unregisterised), so in this case
// capabilities[0] must coincide with &MainCapability.
// capabilities[0] must coincide with &MainCapability.
capabilities
[
0
]
=
&
MainCapability
;
new_
capabilities
[
0
]
=
&
MainCapability
;
initCapability
(
&
MainCapability
,
0
);
initCapability
(
&
MainCapability
,
0
);
}
}
else
else
{
{
for
(
i
=
0
;
i
<
to
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
to
;
i
++
)
{
if
(
i
<
from
)
{
if
(
i
<
from
)
{
capabilities
[
i
]
=
old_
capabilities
[
i
];
new_
capabilities
[
i
]
=
capabilities
[
i
];
}
else
{
}
else
{
capabilities
[
i
]
=
stgMallocBytes
(
sizeof
(
Capability
),
new_
capabilities
[
i
]
=
stgMallocBytes
(
sizeof
(
Capability
),
"moreCapabilities"
);
"moreCapabilities"
);
initCapability
(
capabilities
[
i
],
i
);
initCapability
(
new_
capabilities
[
i
],
i
);
}
}
}
}
}
}
debugTrace
(
DEBUG_sched
,
"allocated %d more capabilities"
,
to
-
from
);
debugTrace
(
DEBUG_sched
,
"allocated %d more capabilities"
,
to
-
from
);
Capability
**
old_capabilities
=
ACQUIRE_LOAD
(
&
capabilities
);
RELEASE_STORE
(
&
capabilities
,
new_capabilities
);
if
(
old_capabilities
!=
NULL
)
{
if
(
old_capabilities
!=
NULL
)
{
stgFree
(
old_capabilities
);
stgFree
(
old_capabilities
);
}
}
startTimer
();
#endif
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
rts/Timer.c
+
2
−
2
View file @
a433c908
...
@@ -55,7 +55,7 @@ handle_tick(int unused STG_UNUSED)
...
@@ -55,7 +55,7 @@ handle_tick(int unused STG_UNUSED)
{
{
handleProfTick
();
handleProfTick
();
if
(
RtsFlags
.
ConcFlags
.
ctxtSwitchTicks
>
0
if
(
RtsFlags
.
ConcFlags
.
ctxtSwitchTicks
>
0
&&
RELAXED
_LOAD
(
&
timer_disabled
)
==
0
)
&&
SEQ_CST
_LOAD
(
&
timer_disabled
)
==
0
)
{
{
ticks_to_ctxt_switch
--
;
ticks_to_ctxt_switch
--
;
if
(
ticks_to_ctxt_switch
<=
0
)
{
if
(
ticks_to_ctxt_switch
<=
0
)
{
...
@@ -119,7 +119,7 @@ initTimer(void)
...
@@ -119,7 +119,7 @@ initTimer(void)
if
(
RtsFlags
.
MiscFlags
.
tickInterval
!=
0
)
{
if
(
RtsFlags
.
MiscFlags
.
tickInterval
!=
0
)
{
initTicker
(
RtsFlags
.
MiscFlags
.
tickInterval
,
handle_tick
);
initTicker
(
RtsFlags
.
MiscFlags
.
tickInterval
,
handle_tick
);
}
}
RELAXED
_STORE
(
&
timer_disabled
,
1
);
SEQ_CST
_STORE
(
&
timer_disabled
,
1
);
}
}
void
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment