Lines Matching +full:clock +full:- +full:duration +full:- +full:ns

1 // SPDX-License-Identifier: GPL-2.0+
39 #include <linux/sched/clock.h>
43 #define SCALE_FLAG "-ref-scale: "
79 // Number of seconds to extend warm-up and cool-down for multiple guest OSes
81 "Number of seconds to extend warm-up/cool-down for multiple guest OSes.");
89 // Number of readers, with -1 defaulting to about 75% of the CPUs.
90 torture_param(int, nreaders, -1, "Number of readers, -1 for 75% of CPUs.");
94 torture_param(int, readdelay, 0, "Read-side delay in nanoseconds.");
156 for (i = nloops; i >= 0; i--) {
166 for (i = nloops; i >= 0; i--) {
194 for (i = nloops; i >= 0; i--) {
205 for (i = nloops; i >= 0; i--) {
224 for (i = nloops; i >= 0; i--) {
235 for (i = nloops; i >= 0; i--) {
246 .name = "srcu-fast"
257 for (i = nloops; i >= 0; i--)
265 for (i = nloops; i >= 0; i--)
273 .name = "rcu-tasks"
291 for (i = nloops; i >= 0; i--) {
301 for (i = nloops; i >= 0; i--) {
312 .name = "rcu-trace"
330 for (i = nloops; i >= 0; i--) {
340 for (i = nloops; i >= 0; i--) {
367 for (i = nloops; i >= 0; i--) {
377 for (i = nloops; i >= 0; i--) {
404 for (i = nloops; i >= 0; i--) {
414 for (i = nloops; i >= 0; i--) {
436 for (i = nloops; i >= 0; i--) {
448 for (i = nloops; i >= 0; i--) {
462 // Definitions for global irq-save spinlock
470 for (i = nloops; i >= 0; i--) {
483 for (i = nloops; i >= 0; i--) {
494 .name = "lock-irq"
497 // Definitions acquire-release.
506 for (i = nloops; i >= 0; i--) {
519 for (i = nloops; i >= 0; i--) {
541 for (i = nloops; i >= 0; i--)
553 for (i = nloops; i >= 0; i--) {
564 .name = "sched-clock"
574 for (i = nloops; i >= 0; i--)
586 for (i = nloops; i >= 0; i--) {
597 .name = "clock"
606 for (i = nloops; i >= 0; i--)
618 for (i = nloops; i >= 0; i--) {
653 // Conditionally acquire an explicit in-structure reference count.
656 return atomic_inc_not_zero(&rtsp->rts_refctr);
659 // Unconditionally release an explicit in-structure reference count.
662 if (!atomic_dec_return(&rtsp->rts_refctr)) {
663 WRITE_ONCE(rtsp->a, rtsp->a + 1);
669 // Unconditionally acquire an explicit in-structure spinlock.
672 spin_lock(&rtsp->rts_lock);
676 // Unconditionally release an explicit in-structure spinlock.
679 spin_unlock(&rtsp->rts_lock);
683 // Unconditionally acquire an explicit in-structure sequence lock.
686 *start = read_seqbegin(&rtsp->rts_seqlock);
690 // Conditionally release an explicit in-structure sequence lock. Return
694 return !read_seqretry(&rtsp->rts_seqlock, start);
697 // Do a read-side critical section with the specified delay in
709 for (i = nloops; i >= 0; i--) {
716 a = READ_ONCE(rtsp->a);
721 if (a != READ_ONCE(rtsp->a)) {
727 b = READ_ONCE(rtsp->a);
728 // Remember, seqlock read-side release can fail.
733 WARN_ONCE(a != b, "Re-read of ->a changed from %u to %u.\n", a, b);
734 b = rtsp->b;
757 atomic_set(&rtsp->rts_refctr, 1);
758 WRITE_ONCE(rtsp->a, rtsp->a + 1);
759 WRITE_ONCE(rtsp->b, rtsp->a * rtsp->a);
763 // Slab-allocator constructor for refscale_typesafe structures created
769 spin_lock_init(&rtsp->rts_lock);
770 seqlock_init(&rtsp->rts_seqlock);
772 rtsp->a = torture_random(this_cpu_ptr(&refscale_rand));
792 si = -si * nr_cpu_ids;
866 cur_ops->readsection(loops);
868 cur_ops->delaysection(loops, readdelay / 1000, readdelay % 1000);
875 unsigned long jdone = jiffies + (guest_os_delay > 0 ? guest_os_delay * HZ : -1);
883 // Reader kthread. Repeatedly does empty RCU read-side
884 // critical section, minimizing update-side interference.
892 s64 duration;
904 wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
913 WRITE_ONCE(rt->start_reader, 0);
921 // To reduce noise, do an initial cache-warming invocation, check
934 duration = ktime_get_mono_fast_ns() - start;
937 rt->last_duration_ns = WARN_ON_ONCE(duration < 0) ? 0 : duration;
938 // To reduce runtime-skew noise, do maintain-load invocations until
965 rt->last_duration_ns = 0;
983 seq_buf_printf(&s, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)",
997 seq_buf_printf(&s, "%d: %llu\t", i, rt->last_duration_ns);
999 sum += rt->last_duration_ns;
1073 SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
1075 pr_alert("Runs\tTime(ns)\n");
1113 "--- %s: verbose=%d verbose_batched=%d shutdown=%d holdoff=%d lookup_instances=%ld loops=%d nreaders=%d nruns=%d readdelay=%d\n", scale_type, tag,
1140 // Do scale-type-specific cleanup operations.
1141 if (cur_ops->cleanup != NULL)
1142 cur_ops->cleanup();
1157 return -EINVAL;
1173 return -EBUSY;
1177 if (strcmp(scale_type, cur_ops->name) == 0)
1181 pr_alert("rcu-scale: invalid scale type: \"%s\"\n", scale_type);
1182 pr_alert("rcu-scale types:");
1184 pr_cont(" %s", scale_ops[i]->name);
1186 firsterr = -EINVAL;
1190 if (cur_ops->init)
1191 if (!cur_ops->init()) {
1192 firsterr = -EUCLEAN;
1225 firsterr = -ENOMEM;