forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/md/dm-stats.c
....@@ -56,7 +56,7 @@
5656 size_t percpu_alloc_size;
5757 size_t histogram_alloc_size;
5858 struct dm_stat_percpu *stat_percpu[NR_CPUS];
59
- struct dm_stat_shared stat_shared[0];
59
+ struct dm_stat_shared stat_shared[];
6060 };
6161
6262 #define STAT_PRECISE_TIMESTAMPS 1
....@@ -85,7 +85,7 @@
8585 a = shared_memory_amount + alloc_size;
8686 if (a < shared_memory_amount)
8787 return false;
88
- if (a >> PAGE_SHIFT > totalram_pages / DM_STATS_MEMORY_FACTOR)
88
+ if (a >> PAGE_SHIFT > totalram_pages() / DM_STATS_MEMORY_FACTOR)
8989 return false;
9090 #ifdef CONFIG_MMU
9191 if (a > (VMALLOC_END - VMALLOC_START) / DM_STATS_VMALLOC_FACTOR)
....@@ -224,6 +224,7 @@
224224 atomic_read(&shared->in_flight[READ]),
225225 atomic_read(&shared->in_flight[WRITE]));
226226 }
227
+ cond_resched();
227228 }
228229 dm_stat_free(&s->rcu_head);
229230 }
....@@ -262,7 +263,7 @@
262263 if (n_entries != (size_t)n_entries || !(size_t)(n_entries + 1))
263264 return -EOVERFLOW;
264265
265
- shared_alloc_size = sizeof(struct dm_stat) + (size_t)n_entries * sizeof(struct dm_stat_shared);
266
+ shared_alloc_size = struct_size(s, stat_shared, n_entries);
266267 if ((shared_alloc_size - sizeof(struct dm_stat)) / sizeof(struct dm_stat_shared) != n_entries)
267268 return -EOVERFLOW;
268269
....@@ -313,6 +314,7 @@
313314 for (ni = 0; ni < n_entries; ni++) {
314315 atomic_set(&s->stat_shared[ni].in_flight[READ], 0);
315316 atomic_set(&s->stat_shared[ni].in_flight[WRITE], 0);
317
+ cond_resched();
316318 }
317319
318320 if (s->n_histogram_entries) {
....@@ -325,6 +327,7 @@
325327 for (ni = 0; ni < n_entries; ni++) {
326328 s->stat_shared[ni].tmp.histogram = hi;
327329 hi += s->n_histogram_entries + 1;
330
+ cond_resched();
328331 }
329332 }
330333
....@@ -345,6 +348,7 @@
345348 for (ni = 0; ni < n_entries; ni++) {
346349 p[ni].histogram = hi;
347350 hi += s->n_histogram_entries + 1;
351
+ cond_resched();
348352 }
349353 }
350354 }
....@@ -474,6 +478,7 @@
474478 }
475479 DMEMIT("\n");
476480 }
481
+ cond_resched();
477482 }
478483 mutex_unlock(&stats->mutex);
479484
....@@ -750,6 +755,7 @@
750755 local_irq_enable();
751756 }
752757 }
758
+ cond_resched();
753759 }
754760 }
755761
....@@ -865,6 +871,8 @@
865871
866872 if (unlikely(sz + 1 >= maxlen))
867873 goto buffer_overflow;
874
+
875
+ cond_resched();
868876 }
869877
870878 if (clear)