-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clock_timekeeping: remove enter_critical_section in sched/clock/clock_timekeeping.c #15136
Open
hujun260
wants to merge
1
commit into
apache:master
Choose a base branch
from
hujun260:apache_6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ static struct timespec g_clock_wall_time; | |
static uint64_t g_clock_last_counter; | ||
static uint64_t g_clock_mask; | ||
static long g_clock_adjust; | ||
static spinlock_t g_clock_lock = SP_UNLOCKED; | ||
|
||
/**************************************************************************** | ||
* Private Functions | ||
|
@@ -72,7 +73,7 @@ static int clock_get_current_time(FAR struct timespec *ts, | |
time_t sec; | ||
int ret; | ||
|
||
flags = enter_critical_section(); | ||
flags = spin_lock_irqsave(&g_clock_lock); | ||
|
||
ret = up_timer_gettick(&counter); | ||
if (ret < 0) | ||
|
@@ -96,7 +97,7 @@ static int clock_get_current_time(FAR struct timespec *ts, | |
ts->tv_sec = base->tv_sec + sec; | ||
|
||
errout_in_critical_section: | ||
leave_critical_section(flags); | ||
spin_unlock_irqrestore(&g_clock_lock, flags); | ||
return ret; | ||
} | ||
|
||
|
@@ -123,7 +124,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts) | |
uint64_t counter; | ||
int ret; | ||
|
||
flags = enter_critical_section(); | ||
flags = spin_lock_irqsave(&g_clock_lock); | ||
|
||
ret = up_timer_gettick(&counter); | ||
if (ret < 0) | ||
|
@@ -137,7 +138,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts) | |
g_clock_last_counter = counter; | ||
|
||
errout_in_critical_section: | ||
leave_critical_section(flags); | ||
spin_unlock_irqrestore(&g_clock_lock, flags); | ||
return ret; | ||
} | ||
|
||
|
@@ -188,7 +189,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta) | |
return -1; | ||
} | ||
|
||
flags = enter_critical_section(); | ||
flags = spin_lock_irqsave(&g_clock_lock); | ||
|
||
adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec; | ||
|
||
|
@@ -199,7 +200,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta) | |
|
||
g_clock_adjust = adjust_usec; | ||
|
||
leave_critical_section(flags); | ||
spin_unlock_irqrestore(&g_clock_lock, flags); | ||
|
||
return OK; | ||
} | ||
|
@@ -217,7 +218,7 @@ void clock_update_wall_time(void) | |
time_t sec; | ||
int ret; | ||
|
||
flags = enter_critical_section(); | ||
flags = spin_lock_irqsave(&g_clock_lock); | ||
|
||
ret = up_timer_gettick(&counter); | ||
if (ret < 0) | ||
|
@@ -271,7 +272,7 @@ void clock_update_wall_time(void) | |
g_clock_last_counter = counter; | ||
|
||
errout_in_critical_section: | ||
leave_critical_section(flags); | ||
spin_unlock_irqrestore(&g_clock_lock, flags); | ||
} | ||
|
||
/**************************************************************************** | ||
|
@@ -280,6 +281,9 @@ void clock_update_wall_time(void) | |
|
||
void clock_inittimekeeping(FAR const struct timespec *tp) | ||
{ | ||
irqstate_t flags; | ||
|
||
flags = spin_lock_irqsave(&g_clock_lock); | ||
up_timer_getmask(&g_clock_mask); | ||
|
||
if (tp) | ||
|
@@ -292,6 +296,7 @@ void clock_inittimekeeping(FAR const struct timespec *tp) | |
} | ||
|
||
up_timer_gettick(&g_clock_last_counter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
spin_unlock_irqrestore(&g_clock_lock, flags); | ||
} | ||
|
||
#endif /* CONFIG_CLOCK_TIMEKEEPING */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue with #15129, how to protect lower half data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is no clear specification that requires up_timer_gettick to be called within a critical_section. Currently, there are numerous calls to up_timer_gettick that are not within a critical section. For example, clock_systime_ticks calls up_timer_gettick, but clock_systime_ticks itself is not within a critical_section in many places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key issue is that the scope of impact of your code before and after modification is different. You cannot guarantee that the modification will not bring side effects within the visible range. If you insist on making changes, please ignore my comments,I will not spend time reviewing similar submissions in the future.