From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: James Clark <james.clark@arm.com>
Cc: Leo Yan <leo.yan@linaro.org>,
coresight@lists.linaro.org, suzuki.poulose@arm.com,
Mike Leach <mike.leach@linaro.org>,
John Garry <john.garry@huawei.com>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf cs-etm: Remove duplicate and incorrect aux size checks
Date: Fri, 10 Dec 2021 09:54:36 -0700 [thread overview]
Message-ID: <20211210165436.GA1236662@p14s> (raw)
In-Reply-To: <6a7fd600-91f3-5feb-d21f-ec7cb704f84c@arm.com>
On Thu, Dec 09, 2021 at 02:16:43PM +0000, James Clark wrote:
>
>
> On 09/12/2021 13:44, Leo Yan wrote:
> > On Wed, Dec 08, 2021 at 02:08:04PM +0000, James Clark wrote:
> >> On 08/12/2021 13:17, Leo Yan wrote:
> >>> Hi James,
> >>>
> >>> On Wed, Dec 08, 2021 at 11:54:35AM +0000, James Clark wrote:
> >>>> There are two checks, one is for size when running without admin, but
> >>>> this one is covered by the driver and reported on in more detail here
> >>>> (builtin-record.c):
> >>>>
> >>>> pr_err("Permission error mapping pages.\n"
> >>>> "Consider increasing "
> >>>> "/proc/sys/kernel/perf_event_mlock_kb,\n"
> >>>> "or try again with a smaller value of -m/--mmap_pages.\n"
> >>>> "(current value: %u,%u)\n",
> >>>
> >>> I looked into the kernel code and found:
> >>>
> >>> sysctl_perf_event_mlock = 512 + (PAGE_SIZE / 1024); // 512KB + 1 page
> >>>
> >>> If the system have multiple cores, let's say 8 cores, then kernel even
> >>> can relax the limitaion with:
> >>>
> >>> user_lock_limit *= num_online_cpus();
> >>>
> >>> So means the memory lock limitation is:
> >>>
> >>> (512KB + 1 page) * 8 = 4MB + 8 pages.
> >>>
> >>> Seems to me, it's much relax than the user space's limitaion 128KB.
> >>> And let's imagine for Arm server, the permitted buffer size can be a
> >>> huge value (e.g. for a system with 128 cores).
> >>>
> >>> Could you confirm if this is right?
> >>
> >> Yes that seems to be the case. And the commit message for that addition
> >> states the reasoning:
> >>
> >> perf_counter: Increase mmap limit
> >>
> >> In a default 'perf top' run the tool will create a counter for
> >> each online CPU. With enough CPUs this will eventually exhaust
> >> the default limit.
> >>
> >> So scale it up with the number of online CPUs.
> >>
> >> To me that makes sense. Normally the memory installed also scales with the
> >> number of cores.
> >>
> >> Are you saying that we should look into modifying that scaling factor in
> >> perf_mmap()? Or that we should still add something to userspace for
> >> coresight to limit user supplied buffer sizes?
> >
> > I don't think we should modify the scaling factor in perf_mmap(), the
> > logic is not only used by AUX buffer, it's shared by normal event
> > ring buffer.
> >
> >> I think it makes sense to allow the user to specify any value that will work,
> >> it's up to them.
> >
> > Understand, I verified this patch with below steps:
> >
> > root@debian:~# echo 0 > /proc/sys/kernel/perf_event_paranoid
> >
> > leoy@debian:~$ perf record -e cs_etm// -m 4M,8M -o perf_test.data -- sleep 1
> > Permission error mapping pages.
> > Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
> > or try again with a smaller value of -m/--mmap_pages.
> > (current value: 1024,2048)
> >
> > leoy@debian:~$ perf record -e cs_etm// -m 4M,4M -o perf_test.data -- sleep 1
> > Couldn't synthesize bpf events.
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.607 MB perf_test.data ]
> >
> > So this patch looks good for me:
> >
> > Reviewed-by: Leo Yan <leo.yan@linaro.org>
> >
> Thanks Leo!
Arnaldo is not on the recipient list and as such he won't see this patch...
WARNING: multiple messages have this Message-ID (diff)
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: James Clark <james.clark@arm.com>
Cc: Leo Yan <leo.yan@linaro.org>,
coresight@lists.linaro.org, suzuki.poulose@arm.com,
Mike Leach <mike.leach@linaro.org>,
John Garry <john.garry@huawei.com>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf cs-etm: Remove duplicate and incorrect aux size checks
Date: Fri, 10 Dec 2021 09:54:36 -0700 [thread overview]
Message-ID: <20211210165436.GA1236662@p14s> (raw)
In-Reply-To: <6a7fd600-91f3-5feb-d21f-ec7cb704f84c@arm.com>
On Thu, Dec 09, 2021 at 02:16:43PM +0000, James Clark wrote:
>
>
> On 09/12/2021 13:44, Leo Yan wrote:
> > On Wed, Dec 08, 2021 at 02:08:04PM +0000, James Clark wrote:
> >> On 08/12/2021 13:17, Leo Yan wrote:
> >>> Hi James,
> >>>
> >>> On Wed, Dec 08, 2021 at 11:54:35AM +0000, James Clark wrote:
> >>>> There are two checks, one is for size when running without admin, but
> >>>> this one is covered by the driver and reported on in more detail here
> >>>> (builtin-record.c):
> >>>>
> >>>> pr_err("Permission error mapping pages.\n"
> >>>> "Consider increasing "
> >>>> "/proc/sys/kernel/perf_event_mlock_kb,\n"
> >>>> "or try again with a smaller value of -m/--mmap_pages.\n"
> >>>> "(current value: %u,%u)\n",
> >>>
> >>> I looked into the kernel code and found:
> >>>
> >>> sysctl_perf_event_mlock = 512 + (PAGE_SIZE / 1024); // 512KB + 1 page
> >>>
> >>> If the system have multiple cores, let's say 8 cores, then kernel even
> >>> can relax the limitaion with:
> >>>
> >>> user_lock_limit *= num_online_cpus();
> >>>
> >>> So means the memory lock limitation is:
> >>>
> >>> (512KB + 1 page) * 8 = 4MB + 8 pages.
> >>>
> >>> Seems to me, it's much relax than the user space's limitaion 128KB.
> >>> And let's imagine for Arm server, the permitted buffer size can be a
> >>> huge value (e.g. for a system with 128 cores).
> >>>
> >>> Could you confirm if this is right?
> >>
> >> Yes that seems to be the case. And the commit message for that addition
> >> states the reasoning:
> >>
> >> perf_counter: Increase mmap limit
> >>
> >> In a default 'perf top' run the tool will create a counter for
> >> each online CPU. With enough CPUs this will eventually exhaust
> >> the default limit.
> >>
> >> So scale it up with the number of online CPUs.
> >>
> >> To me that makes sense. Normally the memory installed also scales with the
> >> number of cores.
> >>
> >> Are you saying that we should look into modifying that scaling factor in
> >> perf_mmap()? Or that we should still add something to userspace for
> >> coresight to limit user supplied buffer sizes?
> >
> > I don't think we should modify the scaling factor in perf_mmap(), the
> > logic is not only used by AUX buffer, it's shared by normal event
> > ring buffer.
> >
> >> I think it makes sense to allow the user to specify any value that will work,
> >> it's up to them.
> >
> > Understand, I verified this patch with below steps:
> >
> > root@debian:~# echo 0 > /proc/sys/kernel/perf_event_paranoid
> >
> > leoy@debian:~$ perf record -e cs_etm// -m 4M,8M -o perf_test.data -- sleep 1
> > Permission error mapping pages.
> > Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
> > or try again with a smaller value of -m/--mmap_pages.
> > (current value: 1024,2048)
> >
> > leoy@debian:~$ perf record -e cs_etm// -m 4M,4M -o perf_test.data -- sleep 1
> > Couldn't synthesize bpf events.
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.607 MB perf_test.data ]
> >
> > So this patch looks good for me:
> >
> > Reviewed-by: Leo Yan <leo.yan@linaro.org>
> >
> Thanks Leo!
Arnaldo is not on the recipient list and as such he won't see this patch...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-12-10 16:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 11:54 [PATCH] perf cs-etm: Remove duplicate and incorrect aux size checks James Clark
2021-12-08 11:54 ` James Clark
2021-12-08 13:17 ` Leo Yan
2021-12-08 13:17 ` Leo Yan
2021-12-08 14:08 ` James Clark
2021-12-08 14:08 ` James Clark
2021-12-09 13:44 ` Leo Yan
2021-12-09 13:44 ` Leo Yan
2021-12-09 14:16 ` James Clark
2021-12-09 14:16 ` James Clark
2021-12-10 16:54 ` Mathieu Poirier [this message]
2021-12-10 16:54 ` Mathieu Poirier
2021-12-10 17:55 ` Arnaldo Carvalho de Melo
2021-12-10 17:55 ` Arnaldo Carvalho de Melo
2021-12-10 19:03 ` Arnaldo Carvalho de Melo
2021-12-10 19:03 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211210165436.GA1236662@p14s \
--to=mathieu.poirier@linaro.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@arm.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=namhyung@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.