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

[RFE] systemd-timesyncd: Use UEFI variable for /usr/lib/systemd/systemd-timesyncd #15949

Open
ribalda opened this issue May 28, 2020 · 6 comments
Labels
RFE 🎁 Request for Enhancement, i.e. a feature request timesync

Comments

@ribalda
Copy link

ribalda commented May 28, 2020

systemd-timesysncd does not work on read-only filesystems.

With the almost ubiquity of uefi these days in both ARM and X86, it would be a great addition that systemd-timesyncd would save the last synchronised time on a uefi variable, as well as on /usr/lib/systemd/systemd-timesyncd.

This way we would have the assurance of a monotonic clock on the system even with the absence of a RTC and Internet connection.

@ribalda ribalda changed the title systemd-timesyncd: Use UEFI variable for /usr/lib/systemd/systemd-timesyncd [RFE] systemd-timesyncd: Use UEFI variable for /usr/lib/systemd/systemd-timesyncd May 28, 2020
@poettering
Copy link
Member

I am sorry, but I doubt that's a good idea. The memory chips that back efi vars are typically of not so great quality. They don't survive many write cycles. Hence we shouldn't write to it regularly. It's fine to write them when configuration changes, but change them otherwise (i.e. during every clean shutdown) sounds wrong.

Are you sure that the set of systems with UEFI but without RTC is particularly high? I'd guess it's the empty set...

@ribalda
Copy link
Author

ribalda commented May 28, 2020

Hi Lennard

The memory chips are not that bad. We are looking at around 100K cycles (>200 years if we reboot daily). https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_1_8v_65nm.pdf

The linux kernel, is writing the reboot/shutdown reason on every clean stop: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/efi/efibc.c

And yes, there are not many systems with UEFI, not rtc, no nework and no read-write rfs, at least on the commercial systems. But there are also industrial systems that cannot afford to have a battery due to corrosion, or because they are in accessible places that you do not want to maintain (think about the top of an aerogenerator in the sea).

So, probably this is very low priority for systemd ;). But would it be mergeable, if I work on it, and the code has the expected quality?

Thanks!

@boucman
Copy link
Contributor

boucman commented May 28, 2020

please try to not be too tied to EFI... there are lots of systems that are note UEFI at all

Despite all of ARM's claim, there are basically no such systems in the embedded world and we are the ones that are the most likely to need the feature (no RTC, read-only rootfs).

Our bootloaders usually store their environment on a dedicated sector on the NAND which is usually reliable enough... but is not UEFI. So a generic, overridable way to do that would be more usefull for us.

@poettering
Copy link
Member

well, if its configurable, sure, why not. but i figure it should be opt-in to set it. (but i'd always use it if it is already set)

@poettering poettering added RFE 🎁 Request for Enhancement, i.e. a feature request timesync labels May 29, 2020
@nolange
Copy link
Contributor

nolange commented Jun 8, 2020

Well, on x86 writing to EFI causes a metric ton of issues, those are SMI Handlers (at best the cpu has a counter for those, otherwise they are completely isolated from diagnosis after the Bios startup) which will typically block all cpu cores for up to a ms. If your embedded device is expected to run realtime, then this feature is a good way to cause random hickups.

I need to check this, but AFAIR I need to precreate the private state directory to allow systemd-timesync to work on an RO filesystem (service fails at creation of that dir, but works if it can't write to it) . That could be improved.

Otherwise you should use a custom solution like an F-Ram if you really need some bytes of nvram.

@ribalda
Copy link
Author

ribalda commented Jun 10, 2020

I am not very concerned abut the SMI handlers, as this would only run during poweroff. So even if the system is stalled for a second, it won't matter that much.

The F-ram is definitely an option, and whatever we implement to modify timesync should support any NV memory on a configurable way, not only EFI / filesystem, as @boucman requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFE 🎁 Request for Enhancement, i.e. a feature request timesync
Development

No branches or pull requests

4 participants