History

perf: Cap allocation order at aux_watermark

Currently, we start allocating AUX pages half the size of the total requested AUX buffer size, ignoring the attr.aux_watermark setting. This, in turn, makes intel_pt driver disregard the watermark also, as it uses page order for its SG (ToPA) configuration. Now, this can be fixed in the intel_pt PMU driver, but seeing as it's the only one currently making use of high order allocations, there is no reason not to fix the allocator instead. This way, any other driver wishing to add this support would not have to worry about this.

Alexander Shishkin committed 5 years ago

Commit d68e6791 parent cface031 file · +18 −16Browse files

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

Unified · Split

kernel/events/ring_buffer.c+18−16
@@ -674,21 +674,26 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event, · 673 unmodified lines
674674 if (!has_aux(event))
675675 return -EOPNOTSUPP;
676676
677− /*
678− * We need to start with the max_order that fits in nr_pages,
679− * not the other way around, hence ilog2() and not get_order.
680− */
681− max_order = ilog2(nr_pages);
682−
683− /*
684− * PMU requests more than one contiguous chunks of memory
685− * for SW double buffering
686− */
687677 if (!overwrite) {
688− if (!max_order)
689− return -EINVAL;
678+ /*
679+ * Watermark defaults to half the buffer, and so does the
680+ * max_order, to aid PMU drivers in double buffering.
681+ */
682+ if (!watermark)
683+ watermark = nr_pages << (PAGE_SHIFT - 1);
690684
691− max_order--;
685+ /*
686+ * Use aux_watermark as the basis for chunking to
687+ * help PMU drivers honor the watermark.
688+ */
689+ max_order = get_order(watermark);
690+ } else {
691+ /*
692+ * We need to start with the max_order that fits in nr_pages,
693+ * not the other way around, hence ilog2() and not get_order.
694+ */
695+ max_order = ilog2(nr_pages);
696+ watermark = 0;
692697 }
693698
694699 rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
@@ -743,9 +748,6 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event, · 48 unmodified lines
743748 rb->aux_overwrite = overwrite;
744749 rb->aux_watermark = watermark;
745750
746− if (!rb->aux_watermark && !rb->aux_overwrite)
747− rb->aux_watermark = nr_pages << (PAGE_SHIFT - 1);
748−
749751 out:
750752 if (!ret)
751753 rb->aux_pgoff = pgoff;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t