nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.59k stars 134 forks source link

AWS: add support for PTP hardware clock #1979

Closed francescolavra closed 9 months ago

francescolavra commented 9 months ago

This change set enhances the AWS ENA network interface driver to add support for retrieving the current time from a PTP hardware clock, when supported by the network interface. In addition, the NTP klib has been enhanced to be able to retrieve time from the PTP clock alternatively to using NTP; if the root tuple contains a "chrony" tuple that has a "refclock" attribute with "ptp" value, then the NTP klib uses the PTP clock for synchronizing the system time; if a PTP clock is not available, the klib falls back to NTP. These features can be used on selected AWS instances (currently, from the R7g (ARM Graviton3) instance family in the Asia Pacific (Tokyo) region) to synchronize the system time with the PTP clock. The first 5 commits fix a few issues encountered when running on AWS R7g instances, thus making the kernel able to run on ARM instances equipped with Graviton3 processors. Example Ops configuration to enable synchronization of system time with the PTP hardware clock:

{
  "Klibs": ["ntp"]
  },
  "CloudConfig" : {
    "ProjectID": "my-project",
    "Zone": "ap-northeast-1a",
    "BucketName": "my-bucket",
    "Flavor": "r7g.medium"
  },
  "ManifestPassthrough": {
    "chrony": {"refclock": "ptp"}
  }
}
ernestomedina17 commented 9 months ago

Then Graviton2-based instances like t4g.nano do not support this feature in AWS?

francescolavra commented 9 months ago

Then Graviton2-based instances like t4g.nano do not support this feature in AWS?

Correct, according to https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-time-sync-service-microsecond-accurate-time/ the PTP hardware clock is only available in the Asia Pacific (Tokyo) Region on R7g instances. Their statement says "we will be expanding support to additional AWS Regions and EC2 Instance types", but there are no further details as to what instance types will be covered.