Skip to content
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_adjtime: use small lock to protect g_adjtime_ppb g_adjtime_wdog #15138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hujun260
Copy link
Contributor

Summary

clock_adjtime: use small lock to protect g_adjtime_ppb g_adjtime_wdog
reason:
We would like to replace the critical section with a small lock.

Impact

clock_adjtime

Testing

ci ostest

@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Dec 11, 2024
@@ -108,7 +109,7 @@ static int adjtime_start(long long adjust_usec)
ppb = -ppb_limit;
}

flags = enter_critical_section();
flags = spin_lock_irqsave(&g_adjtime_lock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 119/123

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up_adjtime up_rtc_adjtime are only called in this file and all have been protected by g_adjtime_lock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is, you're not entirely sure how each lower half will implement these interfaces, right? If the up_xxx API has access to global variables, local spinlock may not guarantee that the underlying implementation has exclusive access to variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing widely-used critical sections is not an easy task. now, we can analyze the issue case by case, considering that there is a limited number of up_xxx interfaces. We can examine the specific modifications or read operations of the up_xxx interfaces, as well as check whether the files they are located in use critical sections, to determine whether the modifications are safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must ensure that each branch is safe. If all codes and variables are within the visible range, such modification is acceptable. Otherwise, please cautious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, If we remove the critical section protection for up_xxx, we should examine all the logic related to up_xxx to ensure there are no issues.

reason:
We would like to replace the critical section with a small lock.

Signed-off-by: hujun5 <[email protected]>
@github-actions github-actions bot added Size: S The size of the change in this PR is small and removed Size: XS The size of the change in this PR is very small labels Dec 11, 2024
@nuttxpr
Copy link

nuttxpr commented Dec 11, 2024

[Experimental Bot, please feedback here]

No, this PR likely does not fully meet the NuttX requirements. While it provides some information, it's severely lacking in detail and completeness.

Here's a breakdown of the missing pieces:

  • Summary: The "what" is described poorly. While it mentions replacing a critical section with a small lock, it doesn't explain why this is necessary (performance improvement, deadlock avoidance, etc.). It also lacks detail on how the change is implemented (what lock is used, how it integrates with existing code). There's no mention of related issues.

  • Impact: This section is almost entirely empty. Simply stating "clock_adjtime" doesn't explain the impact. All the "NO/YES" questions need to be addressed with explanations if "YES". Consider things like: Will the change affect the accuracy of timekeeping? Will existing applications using clock_adjtime need to be modified? Are there any performance implications?

  • Testing: "ci ostest" is insufficient. The request needs specific details:

    • Build Host(s): E.g., "Linux, x86_64, GCC 12.2.0"
    • Target(s): E.g., "qemu-rv32ima, sim:nsh"
    • Testing logs: Actual logs demonstrating the problem before the change and the improved behavior after the change. Simply saying "ci ostest" doesn't prove anything without the actual log output showing the difference.

In short, the PR needs significantly more information to be considered complete. It needs to clearly explain the motivation, the implementation details, the potential impact on various aspects of the system, and provide concrete evidence that the change works as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OS Components OS Components issues Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants