timekeeping: use proper ktime_add when adding nsecs in coarse offset
Subsystems (21)
PATCH v5 1/3 timekeeping: use proper ktime_add when adding nsecs in coarse offset
While this doesn't actually amount to a real difference, since the macro evaluates to the same thing, every place else operates on ktime_t using these functions, so let's not break the pattern.
--- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timekeeping.c +1 -1
@@ -819,7 +819,7 @@ ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs) }while (read_seqcount_retry (&tk_core.seq, seq)); -return base + nsecs; +return ktime_add_ns (base, nsecs); }EXPORT_SYMBOL_GPL (ktime_get_coarse_with_offset);
Signature · 1 line
2.21.0
PATCH v5 2/3 timekeeping: use proper clock specifier names in functions
This makes boot uniformly boottime and tai uniformly clocktai, to address the remaining oversights.
--- Documentation/core-api/timekeeping.rst | 2 +- arch/x86/kvm/pmu.c | 4 ++-- arch/x86/kvm/x86.c | 12 ++++++------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/iio/humidity/dht11.c | 8 ++++---- drivers/iio/industrialio-core.c | 4 ++-- drivers/infiniband/hw/mlx4/alias_GUID.c | 6 +++--- drivers/leds/trigger/ledtrig-activity.c | 2 +- .../net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 2 +- drivers/net/wireless/mac80211_hwsim.c | 2 +- drivers/net/wireless/ti/wlcore/main.c | 2 +- drivers/net/wireless/ti/wlcore/rx.c | 2 +- drivers/net/wireless/ti/wlcore/tx.c | 2 +- drivers/net/wireless/virt_wifi.c | 2 +- include/linux/timekeeping.h | 4 ++-- include/net/cfg80211.h | 2 +- kernel/bpf/syscall.c | 2 +- kernel/events/core.c | 4 ++-- kernel/fork.c | 2 +- 22 files changed, 36 insertions(+), 36 deletions(-)
Documentation/core-api/timekeeping.rst +1 -1
@@ -65,7 +65,7 @@ different format depending on what is required by the user: .. c:function:: u64 ktime_get_ns( void ) u64 ktime_get_boottime_ns( void ) u64 ktime_get_real_ns( void ) - u64 ktime_get_tai_ns( void ) + u64 ktime_get_clocktai_ns( void ) u64 ktime_get_raw_ns( void ) Same as the plain ktime_get functions, but returning a u64 number
arch/x86/kvm/pmu.c +2 -2
@@ -264,10 +264,10 @@ static int kvm_pmu_rdpmc_vmware(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) ctr_val =rdtsc ();break ;case VMWARE_BACKDOOR_PMC_REAL_TIME : - ctr_val =ktime_get_boot_ns (); + ctr_val =ktime_get_boottime_ns ();break ;case VMWARE_BACKDOOR_PMC_APPARENT_TIME : - ctr_val =ktime_get_boot_ns () + + ctr_val =ktime_get_boottime_ns () + vcpu->kvm->arch.kvmclock_offset;break ;default :
arch/x86/kvm/x86.c +6 -6
@@ -1731,7 +1731,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)raw_spin_lock_irqsave (&kvm->arch.tsc_write_lock, flags); offset =kvm_compute_tsc_offset (vcpu, data); - ns =ktime_get_boot_ns (); + ns =ktime_get_boottime_ns (); elapsed = ns - kvm->arch.last_tsc_nsec;if (vcpu->arch.virtual_tsc_khz) {
@@ -2073,7 +2073,7 @@ u64 get_kvmclock_ns(struct kvm *kvm)spin_lock (&ka->pvclock_gtod_sync_lock);if (!ka->use_master_clock) {spin_unlock (&ka->pvclock_gtod_sync_lock); -return ktime_get_boot_ns () + ka->kvmclock_offset; +return ktime_get_boottime_ns () + ka->kvmclock_offset; } hv_clock.tsc_timestamp = ka->master_cycle_now;
@@ -2089,7 +2089,7 @@ u64 get_kvmclock_ns(struct kvm *kvm) &hv_clock.tsc_to_system_mul); ret =__pvclock_read_cycles (&hv_clock,rdtsc ()); }else - ret =ktime_get_boot_ns () + ka->kvmclock_offset; + ret =ktime_get_boottime_ns () + ka->kvmclock_offset;put_cpu ();
@@ -2188,7 +2188,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) }if (!use_master_clock) { host_tsc =rdtsc (); - kernel_ns =ktime_get_boot_ns (); + kernel_ns =ktime_get_boottime_ns (); } tsc_timestamp =kvm_read_l1_tsc (v, host_tsc);
@@ -9018,7 +9018,7 @@ int kvm_arch_hardware_enable(void)* before any KVM threads can be running. Unfortunately, we can't * bring the TSCs fully up to date with real time, as we aren't yet far * enough into CPU bringup that we know how much real time has actually -* elapsed; our helper function, ktime_get_boot_ns() will be using boot +* elapsed; our helper function, ktime_get_boottime_ns() will be using boot * variables that haven't been updated yet. * * So we simply find the maximum observed TSC above, then record the
@@ -9246,7 +9246,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)mutex_init (&kvm->arch.apic_map_lock);spin_lock_init (&kvm->arch.pvclock_gtod_sync_lock); - kvm->arch.kvmclock_offset = -ktime_get_boot_ns (); + kvm->arch.kvmclock_offset = -ktime_get_boottime_ns ();pvclock_update_vm_gtod_copy (kvm); kvm->arch.guest_can_read_msr_platform_info = true;
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
@@ -837,7 +837,7 @@ static int kfd_ioctl_get_clock_counters(struct file *filep,/* No access to rdtsc. Using raw monotonic time */ args->cpu_clock_counter =ktime_get_raw_ns (); - args->system_clock_counter =ktime_get_boot_ns (); + args->system_clock_counter =ktime_get_boottime_ns ();/* Since the counter is in nano-seconds we use 1GHz frequency */ args->system_clock_freq =1000000000 ;
drivers/iio/humidity/dht11.c +4 -4
@@ -149,7 +149,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)return -EIO ; } - dht11->timestamp =ktime_get_boot_ns (); + dht11->timestamp =ktime_get_boottime_ns ();if (hum_int <4 ) {/* DHT22: 100000 = (3*256+232)*100 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec) * ((temp_int &0x80 ) ?-100 :100 );
@@ -177,7 +177,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges <DHT11_EDGES_PER_READ && dht11->num_edges >=0 ) { - dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boottime_ns (); dht11->edges[dht11->num_edges++].value =gpio_get_value (dht11->gpio);
@@ -196,7 +196,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres, offset;mutex_lock (&dht11->lock); -if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boot_ns ()) { +if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boottime_ns ()) { timeres =ktime_get_resolution_ns ();dev_dbg (dht11->dev,"current timeresolution: %dns\n" , timeres);if (timeres >DHT11_MIN_TIMERES ) {
@@ -322,7 +322,7 @@ static int dht11_probe(struct platform_device *pdev)return -EINVAL ; } - dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boottime_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);
drivers/iio/industrialio-core.c +2 -2
@@ -231,9 +231,9 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev)ktime_get_coarse_ts64 (&tp);return timespec64_to_ns (&tp);case CLOCK_BOOTTIME : -return ktime_get_boot_ns (); +return ktime_get_boottime_ns ();case CLOCK_TAI : -return ktime_get_tai_ns (); +return ktime_get_clocktai_ns ();default :BUG (); }
drivers/infiniband/hw/mlx4/alias_GUID.c +3 -3
@@ -310,7 +310,7 @@ static void aliasguid_query_handler(int status,if (status) {pr_debug ("(port: %d) failed: status = %d\n" , cb_ctx->port, status); - rec->time_to_run =ktime_get_boot_ns () +1 *NSEC_PER_SEC ; + rec->time_to_run =ktime_get_boottime_ns () +1 *NSEC_PER_SEC ; goto out; }
@@ -416,7 +416,7 @@ static void aliasguid_query_handler(int status,be64_to_cpu ((__force __be64 )rec->guid_indexes),be64_to_cpu ((__force __be64 )applied_guid_indexes), be64_to_cpu((__force __be64)declined_guid_indexes)); - rec->time_to_run =ktime_get_boot_ns () + + rec->time_to_run =ktime_get_boottime_ns () + resched_delay_sec *NSEC_PER_SEC ; }else { rec->status =MLX4_GUID_INFO_STATUS_SET ;
@@ -709,7 +709,7 @@ static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port, } }if (resched_delay_sec) { -u64 curr_time =ktime_get_boot_ns (); +u64 curr_time =ktime_get_boottime_ns (); *resched_delay_sec = (low_record_time < curr_time) ?0 :div_u64 ((low_record_time - curr_time),NSEC_PER_SEC );
drivers/leds/trigger/ledtrig-activity.c +1 -1
@@ -73,7 +73,7 @@ static void led_activity_function(struct timer_list *t)* down to 16us, ensuring we won't overflow 32-bit computations below * even up to 3k CPUs, while keeping divides cheap on smaller systems. */ - curr_boot =ktime_get_boot_ns () * cpus; + curr_boot =ktime_get_boottime_ns () * cpus; diff_boot = (curr_boot - activity_data->last_boot) >>16 ; diff_used = (curr_used - activity_data->last_used) >>16 ; activity_data->last_boot = curr_boot;
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +1 -1
@@ -93,7 +93,7 @@ void iwl_mvm_ftm_restart(struct iwl_mvm *mvm)struct cfg80211_pmsr_result result = { .status =NL80211_PMSR_STATUS_FAILURE , .final =1 , - .host_time =ktime_get_boot_ns (), + .host_time =ktime_get_boottime_ns (), .type =NL80211_PMSR_TYPE_FTM , };int i;
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +1 -1
@@ -555,7 +555,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,if (unlikely (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control))) - rx_status->boottime_ns =ktime_get_boot_ns (); + rx_status->boottime_ns =ktime_get_boottime_ns ();/* Take a reference briefly to kick off a d0i3 entry delay so * we can handle bursts of RX packets without toggling the
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +1 -1
@@ -1684,7 +1684,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,if (unlikely (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control))) - rx_status->boottime_ns =ktime_get_boot_ns (); + rx_status->boottime_ns =ktime_get_boottime_ns (); }if (iwl_mvm_create_skb (mvm, skb, hdr, len, crypt_len, rxb)) {
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +1 -1
@@ -1445,7 +1445,7 @@ void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime) } *gp2 =iwl_mvm_get_systime (mvm); - *boottime =ktime_get_boot_ns (); + *boottime =ktime_get_boottime_ns ();if (!ps_disabled) { mvm->ps_disabled = ps_disabled;
drivers/net/wireless/mac80211_hwsim.c +1 -1
@@ -1274,7 +1274,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,*/ if (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control)) { - rx_status.boottime_ns =ktime_get_boot_ns (); + rx_status.boottime_ns =ktime_get_boottime_ns (); now = data->abs_bcn_ts; }else { now =mac80211_hwsim_get_tsf_raw ();
drivers/net/wireless/ti/wlcore/main.c +1 -1
@@ -483,7 +483,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) }/* update the host-chipset time offset */ - wl->time_offset = (ktime_get_boot_ns () >>10 ) - + wl->time_offset = (ktime_get_boottime_ns () >>10 ) - (s64)(status->fw_localtime); wl->fw_fast_lnk_map = status->link_fast_bitmap;
drivers/net/wireless/ti/wlcore/rx.c +1 -1
@@ -93,7 +93,7 @@ static void wl1271_rx_status(struct wl1271 *wl, }if (beacon || probe_rsp) - status->boottime_ns =ktime_get_boot_ns (); + status->boottime_ns =ktime_get_boottime_ns ();if (beacon) wlcore_set_pending_regdomain_ch(wl, (u16)desc->channel,
drivers/net/wireless/ti/wlcore/tx.c +1 -1
@@ -273,7 +273,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, }/* configure packet life time */ - hosttime = (ktime_get_boot_ns () >>10 ); + hosttime = (ktime_get_boottime_ns () >>10 ); desc->start_time =cpu_to_le32 (hosttime - wl->time_offset); is_dummy =wl12xx_is_dummy_packet (wl, skb);
drivers/net/wireless/virt_wifi.c +1 -1
@@ -172,7 +172,7 @@ static void virt_wifi_scan_result(struct work_struct *work) informed_bss =cfg80211_inform_bss (wiphy, &channel_5ghz,CFG80211_BSS_FTYPE_PRESP , fake_router_bssid, -ktime_get_boot_ns (), +ktime_get_boottime_ns (),WLAN_CAPABILITY_ESS ,0 , (void *)&ssid,sizeof (ssid),DBM_TO_MBM (-50 ),GFP_KERNEL );
include/linux/timekeeping.h +2 -2
@@ -131,12 +131,12 @@ static inline u64 ktime_get_real_ns(void)return ktime_to_ns (ktime_get_real ()); } -static inline u64 ktime_get_boot_ns (void ) +static inline u64 ktime_get_boottime_ns (void ) {return ktime_to_ns (ktime_get_boottime ()); } -static inline u64 ktime_get_tai_ns (void ) +static inline u64 ktime_get_clocktai_ns (void ) {return ktime_to_ns (ktime_get_clocktai ()); }
include/net/cfg80211.h +1 -1
@@ -2010,7 +2010,7 @@ enum cfg80211_signal_type {* received by the device (not just by the host, in case it was * buffered on the device) and be accurate to about 10ms. * If the frame isn't buffered, just passing the return value of -* ktime_get_boot_ns() is likely appropriate. +* ktime_get_boottime_ns() is likely appropriate. * @parent_tsf: the time at the start of reception of the first octet of the * timestamp field of the frame. The time is the TSF of the BSS specified * by %parent_bssid.
kernel/bpf/syscall.c +1 -1
@@ -1668,7 +1668,7 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)if (err <0 ) goto free_prog; - prog->aux->load_time =ktime_get_boot_ns (); + prog->aux->load_time =ktime_get_boottime_ns (); err =bpf_obj_name_cpy (prog->aux->name, attr->prog_name);if (err) goto free_prog;
kernel/events/core.c +2 -2
@@ -10680,11 +10680,11 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)break ;case CLOCK_BOOTTIME : - event->clock = &ktime_get_boot_ns; + event->clock = &ktime_get_boottime_ns;break ;case CLOCK_TAI : - event->clock = &ktime_get_tai_ns; + event->clock = &ktime_get_clocktai_ns;break ;default :
kernel/fork.c +1 -1
@@ -2139,7 +2139,7 @@ static __latent_entropy struct task_struct *copy_process(*/ p->start_time =ktime_get_ns (); - p->real_start_time =ktime_get_boot_ns (); + p->real_start_time =ktime_get_boottime_ns ();/* * Make it visible to the rest of the system, but dont wake it up yet.
Signature · 1 line
2.21.0
tip-bot for Jason A. Donenfeld
merge bot[tip:timers/core] timekeeping: Use proper clock specifier names in functions
timekeeping: Use proper clock specifier names in functions
Commit-ID: 9285ec4c8b61d4930a575081abeba2cd4f449a74 Gitweb: https://git.kernel.org/tip/9285ec4c8b61d4930a575081abeba2cd4f449a74 Author: Jason A. Donenfeld <[email protected]> AuthorDate: Fri, 21 Jun 2019 22:32:48 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 22 Jun 2019 12:11:27 +0200
timekeeping: Use proper clock specifier names in functions
This makes boot uniformly boottime and tai uniformly clocktai, to address the remaining oversights.
--- Documentation/core-api/timekeeping.rst | 2 +- arch/x86/kvm/pmu.c | 4 ++-- arch/x86/kvm/x86.c | 12 ++++++------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/iio/humidity/dht11.c | 8 ++++---- drivers/iio/industrialio-core.c | 4 ++-- drivers/infiniband/hw/mlx4/alias_GUID.c | 6 +++--- drivers/leds/trigger/ledtrig-activity.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 2 +- drivers/net/wireless/mac80211_hwsim.c | 2 +- drivers/net/wireless/ti/wlcore/main.c | 2 +- drivers/net/wireless/ti/wlcore/rx.c | 2 +- drivers/net/wireless/ti/wlcore/tx.c | 2 +- drivers/net/wireless/virt_wifi.c | 2 +- include/linux/timekeeping.h | 4 ++-- include/net/cfg80211.h | 2 +- kernel/bpf/syscall.c | 2 +- kernel/events/core.c | 4 ++-- kernel/fork.c | 2 +- 22 files changed, 36 insertions(+), 36 deletions(-)
Documentation/core-api/timekeeping.rst +1 -1
@@ -65,7 +65,7 @@ different format depending on what is required by the user: .. c:function:: u64 ktime_get_ns( void ) u64 ktime_get_boottime_ns( void ) u64 ktime_get_real_ns( void ) - u64 ktime_get_tai_ns( void ) + u64 ktime_get_clocktai_ns( void ) u64 ktime_get_raw_ns( void ) Same as the plain ktime_get functions, but returning a u64 number
arch/x86/kvm/pmu.c +2 -2
@@ -264,10 +264,10 @@ static int kvm_pmu_rdpmc_vmware(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) ctr_val =rdtsc ();break ;case VMWARE_BACKDOOR_PMC_REAL_TIME : - ctr_val =ktime_get_boot_ns (); + ctr_val =ktime_get_boottime_ns ();break ;case VMWARE_BACKDOOR_PMC_APPARENT_TIME : - ctr_val =ktime_get_boot_ns () + + ctr_val =ktime_get_boottime_ns () + vcpu->kvm->arch.kvmclock_offset;break ;default :
arch/x86/kvm/x86.c +6 -6
@@ -1731,7 +1731,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)raw_spin_lock_irqsave (&kvm->arch.tsc_write_lock, flags); offset =kvm_compute_tsc_offset (vcpu, data); - ns =ktime_get_boot_ns (); + ns =ktime_get_boottime_ns (); elapsed = ns - kvm->arch.last_tsc_nsec;if (vcpu->arch.virtual_tsc_khz) {
@@ -2073,7 +2073,7 @@ u64 get_kvmclock_ns(struct kvm *kvm)spin_lock (&ka->pvclock_gtod_sync_lock);if (!ka->use_master_clock) {spin_unlock (&ka->pvclock_gtod_sync_lock); -return ktime_get_boot_ns () + ka->kvmclock_offset; +return ktime_get_boottime_ns () + ka->kvmclock_offset; } hv_clock.tsc_timestamp = ka->master_cycle_now;
@@ -2089,7 +2089,7 @@ u64 get_kvmclock_ns(struct kvm *kvm) &hv_clock.tsc_to_system_mul); ret =__pvclock_read_cycles (&hv_clock,rdtsc ()); }else - ret =ktime_get_boot_ns () + ka->kvmclock_offset; + ret =ktime_get_boottime_ns () + ka->kvmclock_offset;put_cpu ();
@@ -2188,7 +2188,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) }if (!use_master_clock) { host_tsc =rdtsc (); - kernel_ns =ktime_get_boot_ns (); + kernel_ns =ktime_get_boottime_ns (); } tsc_timestamp =kvm_read_l1_tsc (v, host_tsc);
@@ -9018,7 +9018,7 @@ int kvm_arch_hardware_enable(void)* before any KVM threads can be running. Unfortunately, we can't * bring the TSCs fully up to date with real time, as we aren't yet far * enough into CPU bringup that we know how much real time has actually -* elapsed; our helper function, ktime_get_boot_ns() will be using boot +* elapsed; our helper function, ktime_get_boottime_ns() will be using boot * variables that haven't been updated yet. * * So we simply find the maximum observed TSC above, then record the
@@ -9246,7 +9246,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)mutex_init (&kvm->arch.apic_map_lock);spin_lock_init (&kvm->arch.pvclock_gtod_sync_lock); - kvm->arch.kvmclock_offset = -ktime_get_boot_ns (); + kvm->arch.kvmclock_offset = -ktime_get_boottime_ns ();pvclock_update_vm_gtod_copy (kvm); kvm->arch.guest_can_read_msr_platform_info = true;
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
@@ -837,7 +837,7 @@ static int kfd_ioctl_get_clock_counters(struct file *filep,/* No access to rdtsc. Using raw monotonic time */ args->cpu_clock_counter =ktime_get_raw_ns (); - args->system_clock_counter =ktime_get_boot_ns (); + args->system_clock_counter =ktime_get_boottime_ns ();/* Since the counter is in nano-seconds we use 1GHz frequency */ args->system_clock_freq =1000000000 ;
drivers/iio/humidity/dht11.c +4 -4
@@ -149,7 +149,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)return -EIO ; } - dht11->timestamp =ktime_get_boot_ns (); + dht11->timestamp =ktime_get_boottime_ns ();if (hum_int <4 ) {/* DHT22: 100000 = (3*256+232)*100 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec) * ((temp_int &0x80 ) ?-100 :100 );
@@ -177,7 +177,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges <DHT11_EDGES_PER_READ && dht11->num_edges >=0 ) { - dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boottime_ns (); dht11->edges[dht11->num_edges++].value =gpio_get_value (dht11->gpio);
@@ -196,7 +196,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres, offset;mutex_lock (&dht11->lock); -if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boot_ns ()) { +if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boottime_ns ()) { timeres =ktime_get_resolution_ns ();dev_dbg (dht11->dev,"current timeresolution: %dns\n" , timeres);if (timeres >DHT11_MIN_TIMERES ) {
@@ -322,7 +322,7 @@ static int dht11_probe(struct platform_device *pdev)return -EINVAL ; } - dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boottime_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);
drivers/iio/industrialio-core.c +2 -2
@@ -231,9 +231,9 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev)ktime_get_coarse_ts64 (&tp);return timespec64_to_ns (&tp);case CLOCK_BOOTTIME : -return ktime_get_boot_ns (); +return ktime_get_boottime_ns ();case CLOCK_TAI : -return ktime_get_tai_ns (); +return ktime_get_clocktai_ns ();default :BUG (); }
drivers/infiniband/hw/mlx4/alias_GUID.c +3 -3
@@ -310,7 +310,7 @@ static void aliasguid_query_handler(int status,if (status) {pr_debug ("(port: %d) failed: status = %d\n" , cb_ctx->port, status); - rec->time_to_run =ktime_get_boot_ns () +1 *NSEC_PER_SEC ; + rec->time_to_run =ktime_get_boottime_ns () +1 *NSEC_PER_SEC ; goto out; }
@@ -416,7 +416,7 @@ next_entry:be64_to_cpu ((__force __be64 )rec->guid_indexes),be64_to_cpu ((__force __be64 )applied_guid_indexes), be64_to_cpu((__force __be64)declined_guid_indexes)); - rec->time_to_run =ktime_get_boot_ns () + + rec->time_to_run =ktime_get_boottime_ns () + resched_delay_sec *NSEC_PER_SEC ; }else { rec->status =MLX4_GUID_INFO_STATUS_SET ;
@@ -709,7 +709,7 @@ static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port, } }if (resched_delay_sec) { -u64 curr_time =ktime_get_boot_ns (); +u64 curr_time =ktime_get_boottime_ns (); *resched_delay_sec = (low_record_time < curr_time) ?0 :div_u64 ((low_record_time - curr_time),NSEC_PER_SEC );
drivers/leds/trigger/ledtrig-activity.c +1 -1
@@ -73,7 +73,7 @@ static void led_activity_function(struct timer_list *t)* down to 16us, ensuring we won't overflow 32-bit computations below * even up to 3k CPUs, while keeping divides cheap on smaller systems. */ - curr_boot =ktime_get_boot_ns () * cpus; + curr_boot =ktime_get_boottime_ns () * cpus; diff_boot = (curr_boot - activity_data->last_boot) >>16 ; diff_used = (curr_used - activity_data->last_used) >>16 ; activity_data->last_boot = curr_boot;
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +1 -1
@@ -93,7 +93,7 @@ void iwl_mvm_ftm_restart(struct iwl_mvm *mvm)struct cfg80211_pmsr_result result = { .status =NL80211_PMSR_STATUS_FAILURE , .final =1 , - .host_time =ktime_get_boot_ns (), + .host_time =ktime_get_boottime_ns (), .type =NL80211_PMSR_TYPE_FTM , };int i;
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +1 -1
@@ -555,7 +555,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,if (unlikely (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control))) - rx_status->boottime_ns =ktime_get_boot_ns (); + rx_status->boottime_ns =ktime_get_boottime_ns ();/* Take a reference briefly to kick off a d0i3 entry delay so * we can handle bursts of RX packets without toggling the
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +1 -1
@@ -1684,7 +1684,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,if (unlikely (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control))) - rx_status->boottime_ns =ktime_get_boot_ns (); + rx_status->boottime_ns =ktime_get_boottime_ns (); }if (iwl_mvm_create_skb (mvm, skb, hdr, len, crypt_len, rxb)) {
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +1 -1
@@ -1443,7 +1443,7 @@ void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime) } *gp2 =iwl_mvm_get_systime (mvm); - *boottime =ktime_get_boot_ns (); + *boottime =ktime_get_boottime_ns ();if (!ps_disabled) { mvm->ps_disabled = ps_disabled;
drivers/net/wireless/mac80211_hwsim.c +1 -1
@@ -1274,7 +1274,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,*/ if (ieee80211_is_beacon (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control)) { - rx_status.boottime_ns =ktime_get_boot_ns (); + rx_status.boottime_ns =ktime_get_boottime_ns (); now = data->abs_bcn_ts; }else { now =mac80211_hwsim_get_tsf_raw ();
drivers/net/wireless/ti/wlcore/main.c +1 -1
@@ -483,7 +483,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) }/* update the host-chipset time offset */ - wl->time_offset = (ktime_get_boot_ns () >>10 ) - + wl->time_offset = (ktime_get_boottime_ns () >>10 ) - (s64)(status->fw_localtime); wl->fw_fast_lnk_map = status->link_fast_bitmap;
drivers/net/wireless/ti/wlcore/rx.c +1 -1
@@ -93,7 +93,7 @@ static void wl1271_rx_status(struct wl1271 *wl, }if (beacon || probe_rsp) - status->boottime_ns =ktime_get_boot_ns (); + status->boottime_ns =ktime_get_boottime_ns ();if (beacon) wlcore_set_pending_regdomain_ch(wl, (u16)desc->channel,
drivers/net/wireless/ti/wlcore/tx.c +1 -1
@@ -273,7 +273,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, }/* configure packet life time */ - hosttime = (ktime_get_boot_ns () >>10 ); + hosttime = (ktime_get_boottime_ns () >>10 ); desc->start_time =cpu_to_le32 (hosttime - wl->time_offset); is_dummy =wl12xx_is_dummy_packet (wl, skb);
drivers/net/wireless/virt_wifi.c +1 -1
@@ -172,7 +172,7 @@ static void virt_wifi_scan_result(struct work_struct *work) informed_bss =cfg80211_inform_bss (wiphy, &channel_5ghz,CFG80211_BSS_FTYPE_PRESP , fake_router_bssid, -ktime_get_boot_ns (), +ktime_get_boottime_ns (),WLAN_CAPABILITY_ESS ,0 , (void *)&ssid,sizeof (ssid),DBM_TO_MBM (-50 ),GFP_KERNEL );
include/linux/timekeeping.h +2 -2
@@ -131,12 +131,12 @@ static inline u64 ktime_get_real_ns(void)return ktime_to_ns (ktime_get_real ()); } -static inline u64 ktime_get_boot_ns (void ) +static inline u64 ktime_get_boottime_ns (void ) {return ktime_to_ns (ktime_get_boottime ()); } -static inline u64 ktime_get_tai_ns (void ) +static inline u64 ktime_get_clocktai_ns (void ) {return ktime_to_ns (ktime_get_clocktai ()); }
include/net/cfg80211.h +1 -1
@@ -2010,7 +2010,7 @@ enum cfg80211_signal_type {* received by the device (not just by the host, in case it was * buffered on the device) and be accurate to about 10ms. * If the frame isn't buffered, just passing the return value of -* ktime_get_boot_ns() is likely appropriate. +* ktime_get_boottime_ns() is likely appropriate. * @parent_tsf: the time at the start of reception of the first octet of the * timestamp field of the frame. The time is the TSF of the BSS specified * by %parent_bssid.
kernel/bpf/syscall.c +1 -1
@@ -1666,7 +1666,7 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)if (err <0 ) goto free_prog; - prog->aux->load_time =ktime_get_boot_ns (); + prog->aux->load_time =ktime_get_boottime_ns (); err =bpf_obj_name_cpy (prog->aux->name, attr->prog_name);if (err) goto free_prog;
kernel/events/core.c +2 -2
@@ -10680,11 +10680,11 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)break ;case CLOCK_BOOTTIME : - event->clock = &ktime_get_boot_ns; + event->clock = &ktime_get_boottime_ns;break ;case CLOCK_TAI : - event->clock = &ktime_get_tai_ns; + event->clock = &ktime_get_clocktai_ns;break ;default :
kernel/fork.c +1 -1
@@ -2139,7 +2139,7 @@ static __latent_entropy struct task_struct *copy_process(*/ p->start_time =ktime_get_ns (); - p->real_start_time =ktime_get_boot_ns (); + p->real_start_time =ktime_get_boottime_ns ();/* * Make it visible to the rest of the system, but dont wake it up yet.
PATCH v5 3/3 timekeeping: add missing _ns functions for coarse accessors
In reply to Jason A. DonenfeldThis further unifies the accessors for the fast and coarse functions, so that the same types of functions are available for each. There was also a bit of confusion with the documentation, which prior advertised a function that has never existed. Finally, the vanilla ktime_get_coarse() was omitted from the API originally, so this fills this oversight.
--- Documentation/core-api/timekeeping.rst | 10 +++++++--- include/linux/timekeeping.h | 27 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-)
Documentation/core-api/timekeeping.rst +7 -3
@@ -99,16 +99,20 @@ Coarse and fast_ns access Some additional variants exist for more specialized cases: -.. c:function:: ktime_t ktime_get_coarse_boottime( void ) +.. c:function:: ktime_t ktime_get_coarse( void ) + ktime_t ktime_get_coarse_boottime( void ) ktime_t ktime_get_coarse_real( void ) ktime_t ktime_get_coarse_clocktai( void ) - ktime_t ktime_get_coarse_raw( void ) + +.. c:function:: u64 ktime_get_coarse_ns( void ) + u64 ktime_get_coarse_boot_ns( void ) + u64 ktime_get_coarse_real_ns( void ) + u64 ktime_get_coarse_clocktai_ns( void ) .. c:function:: void ktime_get_coarse_ts64( struct timespec64 * ) void ktime_get_coarse_boottime_ts64( struct timespec64 * ) void ktime_get_coarse_real_ts64( struct timespec64 * ) void ktime_get_coarse_clocktai_ts64( struct timespec64 * ) - void ktime_get_coarse_raw_ts64( struct timespec64 * ) These are quicker than the non-coarse versions, but less accurate, corresponding to CLOCK_MONONOTNIC_COARSE and CLOCK_REALTIME_COARSE
include/linux/timekeeping.h +27 -0
@@ -113,6 +113,33 @@ static inline ktime_t ktime_get_coarse_clocktai(void)return ktime_get_coarse_with_offset (TK_OFFS_TAI ); } +static inline ktime_t ktime_get_coarse (void ) +{ +struct timespec64 ts; +ktime_get_coarse_ts64 (&ts); +return timespec64_to_ktime (ts); +} + +static inline u64 ktime_get_coarse_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse ()); +} + +static inline u64 ktime_get_coarse_real_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_real ()); +} + +static inline u64 ktime_get_coarse_boot_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_boottime ()); +} + +static inline u64 ktime_get_coarse_clocktai_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_clocktai ()); +} +/** * ktime_mono_to_real - Convert monotonic time to clock realtime */
Signature · 1 line
2.21.0
Re: [PATCH v5 3/3] timekeeping: add missing _ns functions for coarse accessors
Quoted 9 lines · Jason A. Donenfeld
This further unifies the accessors for the fast and coarse functions, so that the same types of functions are available for each. There was also a bit of confusion with the documentation, which prior advertised a function that has never existed. Finally, the vanilla
ktime_get_coarse()was omitted from the API originally, so this fills this oversight.Signed-off-by Jason A. Donenfeld <[email protected]>Cc Arnd Bergmann <[email protected]>
All three patches
Thanks for the cleanup and your patience.
Arnd
tip-bot for Jason A. Donenfeld
merge bot[tip:timers/core] timekeeping: Add missing _ns functions for coarse accessors
In reply to Jason A. Donenfeldtimekeeping: Add missing _ns functions for coarse accessors
Commit-ID: 4c54294d01e605a9f992361b924c5d8b12822a6d Gitweb: https://git.kernel.org/tip/4c54294d01e605a9f992361b924c5d8b12822a6d Author: Jason A. Donenfeld <[email protected]> AuthorDate: Fri, 21 Jun 2019 22:32:49 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 22 Jun 2019 12:11:28 +0200
timekeeping: Add missing _ns functions for coarse accessors
This further unifies the accessors for the fast and coarse functions, so that the same types of functions are available for each. There was also a bit of confusion with the documentation, which prior advertised a function that has never existed. Finally, the vanilla ktime_get_coarse() was omitted from the API originally, so this fills this oversight.
--- Documentation/core-api/timekeeping.rst | 10 +++++++--- include/linux/timekeeping.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-)
Documentation/core-api/timekeeping.rst +7 -3
@@ -99,16 +99,20 @@ Coarse and fast_ns access Some additional variants exist for more specialized cases: -.. c:function:: ktime_t ktime_get_coarse_boottime( void ) +.. c:function:: ktime_t ktime_get_coarse( void ) + ktime_t ktime_get_coarse_boottime( void ) ktime_t ktime_get_coarse_real( void ) ktime_t ktime_get_coarse_clocktai( void ) - ktime_t ktime_get_coarse_raw( void ) + +.. c:function:: u64 ktime_get_coarse_ns( void ) + u64 ktime_get_coarse_boot_ns( void ) + u64 ktime_get_coarse_real_ns( void ) + u64 ktime_get_coarse_clocktai_ns( void ) .. c:function:: void ktime_get_coarse_ts64( struct timespec64 * ) void ktime_get_coarse_boottime_ts64( struct timespec64 * ) void ktime_get_coarse_real_ts64( struct timespec64 * ) void ktime_get_coarse_clocktai_ts64( struct timespec64 * ) - void ktime_get_coarse_raw_ts64( struct timespec64 * ) These are quicker than the non-coarse versions, but less accurate, corresponding to CLOCK_MONONOTNIC_COARSE and CLOCK_REALTIME_COARSE
include/linux/timekeeping.h +28 -0
@@ -113,6 +113,34 @@ static inline ktime_t ktime_get_coarse_clocktai(void)return ktime_get_coarse_with_offset (TK_OFFS_TAI ); } +static inline ktime_t ktime_get_coarse (void ) +{ +struct timespec64 ts; + +ktime_get_coarse_ts64 (&ts); +return timespec64_to_ktime (ts); +} + +static inline u64 ktime_get_coarse_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse ()); +} + +static inline u64 ktime_get_coarse_real_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_real ()); +} + +static inline u64 ktime_get_coarse_boot_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_boottime ()); +} + +static inline u64 ktime_get_coarse_clocktai_ns (void ) +{ +return ktime_to_ns (ktime_get_coarse_clocktai ()); +} +/** * ktime_mono_to_real - Convert monotonic time to clock realtime */
tip-bot for Jason A. Donenfeld
merge bot[tip:timers/core] timekeeping: Use proper ktime_add when adding nsecs in coarse offset
In reply to Jason A. Donenfeldtimekeeping: Use proper ktime_add when adding nsecs in coarse offset
Commit-ID: 0354c1a3cdf31f44b035cfad14d32282e815a572 Gitweb: https://git.kernel.org/tip/0354c1a3cdf31f44b035cfad14d32282e815a572 Author: Jason A. Donenfeld <[email protected]> AuthorDate: Fri, 21 Jun 2019 22:32:47 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 22 Jun 2019 12:11:27 +0200
timekeeping: Use proper ktime_add when adding nsecs in coarse offset
While this doesn't actually amount to a real difference, since the macro evaluates to the same thing, every place else operates on ktime_t using these functions, so let's not break the pattern.
--- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timekeeping.c +1 -1
@@ -819,7 +819,7 @@ ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs) }while (read_seqcount_retry (&tk_core.seq, seq)); -return base + nsecs; +return ktime_add_ns (base, nsecs); }EXPORT_SYMBOL_GPL (ktime_get_coarse_with_offset);