Skip to content

OS timer uses LPTICKER by default, then USTICKER #12988

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

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

jeromecoutant
Copy link
Collaborator

Summary of changes

Discussion started in #12663 (comment)

Idea is to use lpticker by preference if available, else usticker.

@kjbracey-arm
@LMESTM

Impact of changes

Avoid to define "tickless-from-us-ticker" for each target that doesn't support LPTICKER

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


kjbracey
kjbracey previously approved these changes May 18, 2020
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Seems like a good idea to me. No strong feelings on the error.

#else
MBED_ASSERT("OS timer not available - check MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER" && false);
return NULL;
error("OS timer not available - check MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should probably be MBED_ERROR these days, as unwieldy as it is. I suppose it makes sense to not be an assert though - this path can't produce a functioning image in any way, and it will be clearer than just a null pointer exception.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Advantage if this change is to see the error message in the console!

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like error is still valid, although would assume adding a new error would use MBED_ERROR

@mergify mergify bot added the needs: CI label May 18, 2020
@kjbracey
Copy link
Contributor

I did a search for the config option, and there's one more place to change - I can see a compile time error here that would need to be removed:

#if !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && !DEVICE_LPTICKER

The other error there would still be valid.

Not sure why you don't see that in testing. Non-RTOS build?

@jeromecoutant
Copy link
Collaborator Author

Issue comes with targets which don't support LPTICKER in baremetal.

@kjbracey
Copy link
Contributor

Issue comes with targets which don't support LPTICKER in baremetal.

And that don't have MBED_TICKLESS set?

Okay, I think I grasp the combinations now. That timer stuff is used either by RTOS builds with MBED_TICKLESS, or by bare metal builds if you use RTOS API timing functions.

Bare metal is inherently "tickless" - and that's why you see it tripping up without MBED_TICKLESS being set. That only controls the RTOS choice, and there is no bare metal choice.

In the RTOS case, that stuff needs to work, and not having it correct may as well be a compile error, which is what we see in mbed_rtx_idle. In the bare metal case, it should be fine up until you use a timing function, so the run-time error in os_timer_init seems reasonable.

@kjbracey
Copy link
Contributor

Thinking back, I seem to recall there was a school of thought that tickless-from-us-ticker should be explicit as it means lack of deep sleep, and tickless was meant to imply deep sleep. It should be the exception rather than the norm - people shouldn't be setting MBED_TICKLESS if they didn't have the lpticker and couldn't deep sleep.

That error I suggested be removed is enforcing that.

Don't think I buy the argument (if I'm recalling it correctly). Tickless RTOS without deep sleep is still a power optimisation, if a more minor one. No need to wake 1000 times a second.

@jeromecoutant
Copy link
Collaborator Author

What about a target without LPTICKER (so no TICKLESS)
Withh both supports: RTOS and non-RTOS mode ?

hugueskamba added a commit to ARMmbed/mbed-os-5-docs that referenced this pull request May 18, 2020
The following PR removes the need to override it:
ARMmbed/mbed-os#12988

Signed-off-by: Hugues Kamba <[email protected]>
@kjbracey
Copy link
Contributor

What about a target without LPTICKER (so no TICKLESS) Withh both supports: RTOS and non-RTOS mode ?

Not sure what you're asking.

This PR as it stands makes the bare-metal mode work automatically regardless of the tickless-from-us-ticker setting, and the RTOS non-tickless mode avoids the #error check.

If we want the RTOS tickless to not be automatic, leave the #error. If we want the RTOS tickless to be automatic like the bare metal, remove the error.

I think some of the flagging may not make total sense at this point. Originally MBED_TICKLESS required lpticker, and had to be set explicitly to state "we know lpticker works well enough for tickless to be viable on this target".

It might have made more sense for MBED_TICKLESS and tickless-from-us-ticker to be the defaults, and you turn tickless-from-us-ticker off on a target when you know lp-ticker is good enough for RTOS timing.

(I believe tickless-from-us-ticker should perform fine on all platforms).

It's possible the bare-metal is being excessively optimistic, compared to the RTOS, by wanting to use lpticker "by default". There's been a mixture of "use lpticker by default if available" and "use lpticker only if explicitly enabled" in various components in the past.

The "only if explictly enabled" was usually due to (a) latency compensation worries (which we can deal with) or (b) unhappiness at being regularly reprogrammed 1/1000 times a second. Neither of which is necessarily a problem for bare-metal use.

#else
MBED_ASSERT("OS timer not available - check MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER" && false);
return NULL;
error("OS timer not available - check MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER");
#endif
//os_timer->setup_irq();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also remove this commented out code?

@0xc0170
Copy link
Contributor

0xc0170 commented May 18, 2020

Me as well but looking at the goal in this PR, it wants to remove this "thought".

Only my suggested #error removal (which is inside an #ifdef MBED_TICKLESS in the RTOS) does that. Without that the code Jerome is changing is only reached in bare-metal, so there's no change for MBED_TICKLESS.

Should this PR do this, @jeromecoutant what do you think?

I'm not sure I'd advocate that now. Flipping default state of either option is likely to confuse apps - it's the sort of thing people do mess with trying to get platforms to work.

I'd limit the adjustment to removing that #error so that MBED_TICKLESS RTOS aligns with the "automatic use of us-ticker if no lp-ticker" change being done for bare-metal. Keep them consistent. If people think it's reasonable to let people turn on MBED_TICKLESS easily for lp-ticker-less platforms.

@jeromecoutant
Copy link
Collaborator Author

Should this PR do this, @jeromecoutant what do you think?

I think I will close my PR when I see Kevin's one :-)

@kjbracey
Copy link
Contributor

I think I will close my PR when I see Kevin's one :-)

Not planning one - I don't think significant changes to the way the whole thing works at this point are a good idea. Just that #error could be removed, if others agree.

@mergify mergify bot dismissed kjbracey’s stale review May 18, 2020 16:23

Pull request has been modified.

kjbracey
kjbracey previously approved these changes May 19, 2020
evedon
evedon previously approved these changes May 19, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented May 19, 2020

@jeromecoutant Changes look good. Can you add a reason for this change - details to the commit message? to cover what was discussed here?

This PR makes the bare-metal mode work automatically
regardless of the tickless-from-us-ticker setting
- in non RTOS mode
- and in RTOS tickless mode
@mergify mergify bot dismissed stale reviews from kjbracey and evedon May 19, 2020 10:35

Pull request has been modified.

@jeromecoutant
Copy link
Collaborator Author

Done

@jeromecoutant
Copy link
Collaborator Author

Could we start CI ?

@0xc0170
Copy link
Contributor

0xc0170 commented May 25, 2020

I'll start running CI soon for all PRs ready for CI

@0xc0170
Copy link
Contributor

0xc0170 commented May 25, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented May 25, 2020

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 1
Build artifacts

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

already approved by others as well

@0xc0170 0xc0170 added the release-type: patch Indentifies a PR as containing just a patch label Jun 4, 2020
@0xc0170 0xc0170 merged commit 7ae621e into ARMmbed:master Jun 4, 2020
@mergify mergify bot removed the ready for merge label Jun 4, 2020
@mergify
Copy link

mergify bot commented Jun 4, 2020

This PR does not contain release version label after merging.

@mergify mergify bot added the release version missing When PR does not contain release version, bot should label it and we fix it afterwards label Jun 4, 2020
@jeromecoutant jeromecoutant deleted the PR_OS_TIMER branch June 5, 2020 14:53
iriark01 pushed a commit to ARMmbed/mbed-os-5-docs that referenced this pull request Jun 10, 2020
The following PR removes the need to override it:
ARMmbed/mbed-os#12988

Signed-off-by: Hugues Kamba <[email protected]>
@adbridge adbridge added release-version: 6.1.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Jun 24, 2020
@0xc0170 0xc0170 removed the release version missing When PR does not contain release version, bot should label it and we fix it afterwards label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants