@@ -606,12 +606,17 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
606606 return evlist -> mmap != NULL ? 0 : - ENOMEM ;
607607}
608608
609- static int __perf_evlist__mmap (struct perf_evlist * evlist ,
610- int idx , int prot , int mask , int fd )
609+ struct mmap_params {
610+ int prot ;
611+ int mask ;
612+ };
613+
614+ static int __perf_evlist__mmap (struct perf_evlist * evlist , int idx ,
615+ struct mmap_params * mp , int fd )
611616{
612617 evlist -> mmap [idx ].prev = 0 ;
613- evlist -> mmap [idx ].mask = mask ;
614- evlist -> mmap [idx ].base = mmap (NULL , evlist -> mmap_len , prot ,
618+ evlist -> mmap [idx ].mask = mp -> mask ;
619+ evlist -> mmap [idx ].base = mmap (NULL , evlist -> mmap_len , mp -> prot ,
615620 MAP_SHARED , fd , 0 );
616621 if (evlist -> mmap [idx ].base == MAP_FAILED ) {
617622 pr_debug2 ("failed to mmap perf event ring buffer, error %d\n" ,
@@ -625,8 +630,8 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
625630}
626631
627632static int perf_evlist__mmap_per_evsel (struct perf_evlist * evlist , int idx ,
628- int prot , int mask , int cpu , int thread ,
629- int * output )
633+ struct mmap_params * mp , int cpu ,
634+ int thread , int * output )
630635{
631636 struct perf_evsel * evsel ;
632637
@@ -635,8 +640,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
635640
636641 if (* output == -1 ) {
637642 * output = fd ;
638- if (__perf_evlist__mmap (evlist , idx , prot , mask ,
639- * output ) < 0 )
643+ if (__perf_evlist__mmap (evlist , idx , mp , * output ) < 0 )
640644 return -1 ;
641645 } else {
642646 if (ioctl (fd , PERF_EVENT_IOC_SET_OUTPUT , * output ) != 0 )
@@ -651,8 +655,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
651655 return 0 ;
652656}
653657
654- static int perf_evlist__mmap_per_cpu (struct perf_evlist * evlist , int prot ,
655- int mask )
658+ static int perf_evlist__mmap_per_cpu (struct perf_evlist * evlist ,
659+ struct mmap_params * mp )
656660{
657661 int cpu , thread ;
658662 int nr_cpus = cpu_map__nr (evlist -> cpus );
@@ -663,8 +667,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
663667 int output = -1 ;
664668
665669 for (thread = 0 ; thread < nr_threads ; thread ++ ) {
666- if (perf_evlist__mmap_per_evsel (evlist , cpu , prot , mask ,
667- cpu , thread , & output ))
670+ if (perf_evlist__mmap_per_evsel (evlist , cpu , mp , cpu ,
671+ thread , & output ))
668672 goto out_unmap ;
669673 }
670674 }
@@ -677,8 +681,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
677681 return -1 ;
678682}
679683
680- static int perf_evlist__mmap_per_thread (struct perf_evlist * evlist , int prot ,
681- int mask )
684+ static int perf_evlist__mmap_per_thread (struct perf_evlist * evlist ,
685+ struct mmap_params * mp )
682686{
683687 int thread ;
684688 int nr_threads = thread_map__nr (evlist -> threads );
@@ -687,8 +691,8 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot,
687691 for (thread = 0 ; thread < nr_threads ; thread ++ ) {
688692 int output = -1 ;
689693
690- if (perf_evlist__mmap_per_evsel (evlist , thread , prot , mask , 0 ,
691- thread , & output ))
694+ if (perf_evlist__mmap_per_evsel (evlist , thread , mp , 0 , thread ,
695+ & output ))
692696 goto out_unmap ;
693697 }
694698
@@ -793,7 +797,9 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
793797 struct perf_evsel * evsel ;
794798 const struct cpu_map * cpus = evlist -> cpus ;
795799 const struct thread_map * threads = evlist -> threads ;
796- int prot = PROT_READ | (overwrite ? 0 : PROT_WRITE ), mask ;
800+ struct mmap_params mp = {
801+ .prot = PROT_READ | (overwrite ? 0 : PROT_WRITE ),
802+ };
797803
798804 if (evlist -> mmap == NULL && perf_evlist__alloc_mmap (evlist ) < 0 )
799805 return - ENOMEM ;
@@ -804,7 +810,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
804810 evlist -> overwrite = overwrite ;
805811 evlist -> mmap_len = perf_evlist__mmap_size (pages );
806812 pr_debug ("mmap size %zuB\n" , evlist -> mmap_len );
807- mask = evlist -> mmap_len - page_size - 1 ;
813+ mp . mask = evlist -> mmap_len - page_size - 1 ;
808814
809815 evlist__for_each (evlist , evsel ) {
810816 if ((evsel -> attr .read_format & PERF_FORMAT_ID ) &&
@@ -814,9 +820,9 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
814820 }
815821
816822 if (cpu_map__empty (cpus ))
817- return perf_evlist__mmap_per_thread (evlist , prot , mask );
823+ return perf_evlist__mmap_per_thread (evlist , & mp );
818824
819- return perf_evlist__mmap_per_cpu (evlist , prot , mask );
825+ return perf_evlist__mmap_per_cpu (evlist , & mp );
820826}
821827
822828int perf_evlist__create_maps (struct perf_evlist * evlist , struct target * target )
0 commit comments