This reverts commit a3ab2d45b9887ee609cd3bea39f668236935774c. The userspace side for this code is not ready yet so revert for now.
Unified · Split
| @@ -42,7 +42,6 @@ struct kfd_smi_client { · 41 unmodified lines | |||
| 42 | struct rcu_head rcu; | 42 | struct rcu_head rcu; |
| 43 | pid_t pid; | 43 | pid_t pid; |
| 44 | bool suser; | 44 | bool suser; |
| 45 | u32 drop_count; | ||
| 46 | }; | 45 | }; |
| 47 | 46 | ||
| 48 | #define KFD_MAX_KFIFO_SIZE 8192 | 47 | #define KFD_MAX_KFIFO_SIZE 8192 |
| @@ -104,28 +103,12 @@ static ssize_t kfd_smi_ev_read(struct file *filep, char __user *user, · 55 unmodified lines | |||
| 104 | } | 103 | } |
| 105 | to_copy = min(size, to_copy); | 104 | to_copy = min(size, to_copy); |
| 106 | ret = kfifo_out(&client->fifo, buf, to_copy); | 105 | ret = kfifo_out(&client->fifo, buf, to_copy); |
| 106 | spin_unlock(&client->lock); | ||
| 107 | if (ret <= 0) { | 107 | if (ret <= 0) { |
| 108 | spin_unlock(&client->lock); | ||
| 109 | ret = -EAGAIN; | 108 | ret = -EAGAIN; |
| 110 | goto ret_err; | 109 | goto ret_err; |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | if (client->drop_count) { | ||
| 114 | char msg[KFD_SMI_EVENT_MSG_SIZE]; | ||
| 115 | int len; | ||
| 116 | |||
| 117 | len = snprintf(msg, sizeof(msg), "%x ", KFD_SMI_EVENT_DROPPED_EVENT); | ||
| 118 | len += snprintf(msg + len, sizeof(msg) - len, | ||
| 119 | KFD_EVENT_FMT_DROPPED_EVENT(ktime_get_boottime_ns(), | ||
| 120 | client->pid, client->drop_count)); | ||
| 121 | if (kfifo_avail(&client->fifo) >= len) { | ||
| 122 | kfifo_in(&client->fifo, msg, len); | ||
| 123 | client->drop_count = 0; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | spin_unlock(&client->lock); | ||
| 128 | |||
| 129 | ret = copy_to_user(user, buf, to_copy); | 112 | ret = copy_to_user(user, buf, to_copy); |
| 130 | if (ret) { | 113 | if (ret) { |
| 131 | ret = -EFAULT; | 114 | ret = -EFAULT; |
| @@ -199,15 +182,13 @@ static void add_event_to_kfifo(pid_t pid, struct kfd_node *dev, · 67 unmodified lines | |||
| 199 | list_for_each_entry_rcu(client, &dev->smi_clients, list) { | 182 | list_for_each_entry_rcu(client, &dev->smi_clients, list) { |
| 200 | if (!kfd_smi_ev_enabled(pid, client, smi_event)) | 183 | if (!kfd_smi_ev_enabled(pid, client, smi_event)) |
| 201 | continue; | 184 | continue; |
| 202 | |||
| 203 | spin_lock(&client->lock); | 185 | spin_lock(&client->lock); |
| 204 | if (!client->drop_count && kfifo_avail(&client->fifo) >= len) { | 186 | if (kfifo_avail(&client->fifo) >= len) { |
| 205 | kfifo_in(&client->fifo, event_msg, len); | 187 | kfifo_in(&client->fifo, event_msg, len); |
| 206 | wake_up_all(&client->wait_queue); | 188 | wake_up_all(&client->wait_queue); |
| 207 | } else { | 189 | } else { |
| 208 | client->drop_count++; | 190 | pr_debug("smi_event(EventID: %u): no space left\n", |
| 209 | pr_debug("smi_event(EventID: %u): no space left drop_count %d\n", | 191 | smi_event); |
| 210 | smi_event, client->drop_count); | ||
| 211 | } | 192 | } |
| 212 | spin_unlock(&client->lock); | 193 | spin_unlock(&client->lock); |
| 213 | } | 194 | } |
| @@ -530,7 +530,6 @@ enum kfd_smi_event { · 529 unmodified lines | |||
| 530 | KFD_SMI_EVENT_QUEUE_EVICTION = 9, | 530 | KFD_SMI_EVENT_QUEUE_EVICTION = 9, |
| 531 | KFD_SMI_EVENT_QUEUE_RESTORE = 10, | 531 | KFD_SMI_EVENT_QUEUE_RESTORE = 10, |
| 532 | KFD_SMI_EVENT_UNMAP_FROM_GPU = 11, | 532 | KFD_SMI_EVENT_UNMAP_FROM_GPU = 11, |
| 533 | KFD_SMI_EVENT_DROPPED_EVENT = 12, | ||
| 534 | 533 | ||
| 535 | /* | 534 | /* |
| 536 | * max event number, as a flag bit to get events from all processes, | 535 | * max event number, as a flag bit to get events from all processes, |
| @@ -611,7 +610,6 @@ struct kfd_ioctl_smi_events_args { · 74 unmodified lines | |||
| 611 | * rw: 'W' for write page fault, 'R' for read page fault | 610 | * rw: 'W' for write page fault, 'R' for read page fault |
| 612 | * rescheduled: 'R' if the queue restore failed and rescheduled to try again | 611 | * rescheduled: 'R' if the queue restore failed and rescheduled to try again |
| 613 | * error_code: migrate failure error code, 0 if no error | 612 | * error_code: migrate failure error code, 0 if no error |
| 614 | * drop_count: how many events dropped when fifo is full | ||
| 615 | */ | 613 | */ |
| 616 | #define KFD_EVENT_FMT_UPDATE_GPU_RESET(reset_seq_num, reset_cause)\ | 614 | #define KFD_EVENT_FMT_UPDATE_GPU_RESET(reset_seq_num, reset_cause)\ |
| 617 | "%x %s\n", (reset_seq_num), (reset_cause) | 615 | "%x %s\n", (reset_seq_num), (reset_cause) |
| @@ -647,10 +645,6 @@ struct kfd_ioctl_smi_events_args { · 29 unmodified lines | |||
| 647 | "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ | 645 | "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ |
| 648 | (node), (unmap_trigger) | 646 | (node), (unmap_trigger) |
| 649 | 647 | ||
| 650 | #define KFD_EVENT_FMT_DROPPED_EVENT(ns, pid, drop_count)\ | ||
| 651 | "%lld -%d %d\n", (ns), (pid), (drop_count) | ||
| 652 | |||
| 653 | |||
| 654 | /************************************************************************************************** | 648 | /************************************************************************************************** |
| 655 | * CRIU IOCTLs (Checkpoint Restore In Userspace) | 649 | * CRIU IOCTLs (Checkpoint Restore In Userspace) |
| 656 | * | 650 | * |