Commit d484361
perf evlist: Reduce affinity use and move into iterator, fix no affinity
The evlist__for_each_cpu iterator will call sched_setaffitinity when
moving between CPUs to avoid IPIs.
If only 1 IPI is saved then this may be unprofitable as the delay to get
scheduled may be considerable.
This may be particularly true if reading an event group in `perf stat`
in interval mode.
Move the affinity handling completely into the iterator so that a single
evlist__use_affinity can determine whether CPU affinities will be used.
For `perf record` the change is minimal as the dummy event and the real
event will always make the use of affinities the thing to do.
In `perf stat`, tool events are ignored and affinities only used if >1
event on the same CPU occur.
Determining if affinities are useful is done by evlist__use_affinity
which tests per-event whether the event's PMU benefits from affinity use
- it is assumed only perf event using PMUs do.
Fix a bug where when there are no affinities that the CPU map iterator
may reference a CPU not present in the initial evsel. Fix by making the
iterator and non-iterator code common.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>1 parent 4717291 commit d484361
5 files changed
Lines changed: 174 additions & 131 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
373 | 372 | | |
374 | 373 | | |
375 | 374 | | |
376 | 375 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 376 | + | |
385 | 377 | | |
386 | 378 | | |
387 | 379 | | |
| |||
393 | 385 | | |
394 | 386 | | |
395 | 387 | | |
396 | | - | |
397 | | - | |
398 | 388 | | |
399 | 389 | | |
400 | 390 | | |
| |||
793 | 783 | | |
794 | 784 | | |
795 | 785 | | |
796 | | - | |
797 | 786 | | |
798 | 787 | | |
799 | 788 | | |
| |||
805 | 794 | | |
806 | 795 | | |
807 | 796 | | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | 797 | | |
817 | 798 | | |
818 | 799 | | |
| |||
825 | 806 | | |
826 | 807 | | |
827 | 808 | | |
828 | | - | |
829 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
830 | 816 | | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
837 | 821 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
842 | 826 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
847 | 845 | | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
| 846 | + | |
| 847 | + | |
864 | 848 | | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | 849 | | |
869 | 850 | | |
870 | | - | |
871 | 851 | | |
872 | 852 | | |
873 | 853 | | |
874 | 854 | | |
875 | 855 | | |
876 | 856 | | |
877 | 857 | | |
878 | | - | |
| 858 | + | |
879 | 859 | | |
880 | 860 | | |
881 | 861 | | |
| |||
884 | 864 | | |
885 | 865 | | |
886 | 866 | | |
887 | | - | |
| 867 | + | |
888 | 868 | | |
889 | 869 | | |
890 | 870 | | |
| |||
893 | 873 | | |
894 | 874 | | |
895 | 875 | | |
896 | | - | |
| 876 | + | |
| 877 | + | |
897 | 878 | | |
898 | | - | |
| 879 | + | |
899 | 880 | | |
900 | | - | |
| 881 | + | |
| 882 | + | |
901 | 883 | | |
| 884 | + | |
902 | 885 | | |
903 | 886 | | |
904 | 887 | | |
905 | | - | |
906 | | - | |
907 | 888 | | |
908 | 889 | | |
909 | 890 | | |
| |||
1065 | 1046 | | |
1066 | 1047 | | |
1067 | 1048 | | |
1068 | | - | |
1069 | 1049 | | |
1070 | 1050 | | |
1071 | 1051 | | |
| |||
0 commit comments