History

perf: Disallow sparse AUX allocations for non-SG PMUs in overwrite mode

PMUs that don't support hardware scatter tables require big contiguous chunks of memory and a PMI to switch between them. However, in overwrite using a PMI for this purpose adds extra overhead that the users would like to avoid. Thus, in overwrite mode for such PMUs we can only allow one contiguous chunk for the entire requested buffer. This patch changes the behavior accordingly, so that if the buddy allocator fails to come up with a single high-order chunk for the entire requested buffer, the allocation will fail.

Alexander Shishkin committed 11 years ago

Commit aa319bc1 parent cc1790c1 file · +14 −0Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/events/ring_buffer.c+14−0
@@ -493,6 +493,20 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, · 492 unmodified lines
493 rb->aux_pages[rb->aux_nr_pages] = page_address(page++);493 rb->aux_pages[rb->aux_nr_pages] = page_address(page++);
494 }494 }
495 495
496 /*
497 * In overwrite mode, PMUs that don't support SG may not handle more
498 * than one contiguous allocation, since they rely on PMI to do double
499 * buffering. In this case, the entire buffer has to be one contiguous
500 * chunk.
501 */
502 if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) &&
503 overwrite) {
504 struct page *page = virt_to_page(rb->aux_pages[0]);
505
506 if (page_private(page) != max_order)
507 goto out;
508 }
509
496 rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages,510 rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages,
497 overwrite);511 overwrite);
498 if (!rb->aux_priv)512 if (!rb->aux_priv)