Skip to content

RDKEMW-10467: Fix Invalid time values caused by drift #212

Open
shivabhaskar wants to merge 7 commits intodevelopfrom
topic/RDKEMW-10467
Open

RDKEMW-10467: Fix Invalid time values caused by drift #212
shivabhaskar wants to merge 7 commits intodevelopfrom
topic/RDKEMW-10467

Conversation

@shivabhaskar
Copy link
Contributor

Reason for Change: Changing CLOCK_REALTIME to CLOCK_MONOTONIC to avoid clock drifts impact in the calculations
Test Procedure: When Telemetry report generation is in progress change the time. The processing time should have a valid value
Risks: Low
Priority: P1

Copilot AI review requested due to automatic review settings November 19, 2025 11:46
@shivabhaskar shivabhaskar requested a review from a team as a code owner November 19, 2025 11:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes invalid time values in telemetry report generation caused by system clock drift by changing timing measurements from CLOCK_REALTIME to CLOCK_MONOTONIC.

  • Changed all elapsed time measurements from CLOCK_REALTIME to CLOCK_MONOTONIC to prevent clock drift from affecting duration calculations
  • Improved log messages in profilexconf.c for better clarity and consistency

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
source/bulkdata/profilexconf.c Updated three clock_gettime calls to use CLOCK_MONOTONIC for measuring start time, processing time, and elapsed time; improved log messages for execution count and processing time
source/bulkdata/profile.c Updated two clock_gettime calls to use CLOCK_MONOTONIC for measuring start and end times of report collection and generation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dharshini555
Copy link
Contributor

Code changes looks good to me.

@rdkcmf-jenkins
Copy link
Contributor

rdkcmf-jenkins commented Nov 19, 2025

Coverity Issue - Data race condition

Accessing "profile->grepSeekProfile->execCounter" without holding lock "plMutex". Elsewhere, "_GrepSeekProfile.execCounter" is written to with "plMutex" held 2 out of 2 times.

Medium Impact, CWE-366
MISSING_LOCK

Issue location

This issue was discovered outside the diff for this Pull Request. You can find it at:
source/bulkdata/profile.c:344

Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 19, 2025

Choose a reason for hiding this comment

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

Coverity issue no longer present as of: undefined

Show issue

Coverity Issue - Unchecked return value

Calling "clock_gettime" without checking return value (as is done elsewhere 1 out of 1 times).

Medium Impact, CWE-252
CHECKED_RETURN

@@ -451,7 +451,7 @@ static void* CollectAndReportXconf(void* data)
T2Warning("Failed to save grep config to file for profile: %s\n", profile->name);
}
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 19, 2025

Choose a reason for hiding this comment

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

Coverity issue no longer present as of: undefined

Show issue

Coverity Issue - Unchecked return value

Calling "clock_gettime" without checking return value (as is done elsewhere 1 out of 1 times).

Medium Impact, CWE-252
CHECKED_RETURN

Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 19, 2025

Choose a reason for hiding this comment

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

Coverity issue no longer present as of: undefined

Show issue

Coverity Issue - Unchecked return value

Calling "clock_gettime" without checking return value (as is done elsewhere 1 out of 1 times).

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 24, 2025 12:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

clockReturn |= clock_gettime(CLOCK_MONOTONIC, &endTime);
if(clockReturn)
{
T2Warning("Error in Fetching the time Elapsed");
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The error message "Error in Fetching the time Elapsed" is grammatically incorrect and unclear. Consider revising to "Error fetching elapsed time" or "Failed to get time from clock_gettime()" to be more concise and accurate.

Suggested change
T2Warning("Error in Fetching the time Elapsed");
T2Warning("Failed to get time from clock_gettime()");

Copilot uses AI. Check for mistakes.
clockReturn |= clock_gettime(CLOCK_MONOTONIC, &endTime);
if (clockReturn)
{
T2Warning("Error in Fetching the time Elapsed");
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The error message "Error in Fetching the time Elapsed" is grammatically incorrect and unclear. Consider revising to "Error fetching elapsed time" or "Failed to get time from clock_gettime()" to be more concise and accurate.

Suggested change
T2Warning("Error in Fetching the time Elapsed");
T2Warning("Failed to get time from clock_gettime()");

Copilot uses AI. Check for mistakes.
clockReturn |= clock_gettime(CLOCK_MONOTONIC, &endTime);
if(clockReturn)
{
T2Warning("Error in Fetching the time Elapsed");
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The error message "Error in Fetching the time Elapsed" is grammatically incorrect and unclear. Consider revising to "Error fetching elapsed time" or "Failed to get time from clock_gettime()" to be more concise and accurate.

Suggested change
T2Warning("Error in Fetching the time Elapsed");
T2Warning("Failed to get time from clock_gettime()");

Copilot uses AI. Check for mistakes.
shibu-kv
shibu-kv previously approved these changes Nov 26, 2025
…ONIC

Reason for Change: Changing CLOCK_REALTIME to CLOCK_MONOTONIC to avoid clock drifts impact in the calculations
Test Procedure: When Telemetry report generation is in progress change the time. The processing time should have a valid value
Risks: Low
Priority: P1
Copilot AI review requested due to automatic review settings December 17, 2025 21:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 19, 2026 07:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 5, 2026 10:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +757 to +760
if(clockReturn)
{
T2Warning("Failed to get time from clock_gettime()");
}
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The new warning log for clock_gettime() failures doesn’t include errno details, which makes diagnosing failures difficult. Since clock_gettime() sets errno, consider logging strerror(errno) (and ideally whether startTime or endTime capture failed).

Copilot uses AI. Check for mistakes.
@shibu-kv shibu-kv closed this Mar 6, 2026
@shibu-kv shibu-kv reopened this Mar 6, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants