From: Will Deacon <will@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: kan.liang@linux.intel.com, mingo@redhat.com, acme@kernel.org,
linux-kernel@vger.kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@redhat.com,
eranian@google.com, ak@linux.intel.com, dave.hansen@intel.com,
kirill.shutemov@linux.intel.com, mpe@ellerman.id.au,
benh@kernel.crashing.org, paulus@samba.org,
David Miller <davem@davemloft.net>
Subject: Re: [PATCH V9 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE
Date: Fri, 9 Oct 2020 10:37:51 +0100 [thread overview]
Message-ID: <20201009093750.GD29594@willie-the-truck> (raw)
In-Reply-To: <20201009090927.GQ2611@hirez.programming.kicks-ass.net>
On Fri, Oct 09, 2020 at 11:09:27AM +0200, Peter Zijlstra wrote:
> On Thu, Oct 01, 2020 at 06:57:46AM -0700, kan.liang@linux.intel.com wrote:
> > +/*
> > + * Return the MMU page size of a given virtual address
> > + */
> > +static u64 __perf_get_page_size(struct mm_struct *mm, unsigned long addr)
> > +{
> > + pgd_t *pgd;
> > + p4d_t *p4d;
> > + pud_t *pud;
> > + pmd_t *pmd;
> > + pte_t *pte;
> > +
> > + pgd = pgd_offset(mm, addr);
> > + if (pgd_none(*pgd))
> > + return 0;
> > +
> > + p4d = p4d_offset(pgd, addr);
> > + if (!p4d_present(*p4d))
> > + return 0;
> > +
> > + if (p4d_leaf(*p4d))
> > + return 1ULL << P4D_SHIFT;
> > +
> > + pud = pud_offset(p4d, addr);
> > + if (!pud_present(*pud))
> > + return 0;
> > +
> > + if (pud_leaf(*pud))
> > + return 1ULL << PUD_SHIFT;
> > +
> > + pmd = pmd_offset(pud, addr);
> > + if (!pmd_present(*pmd))
> > + return 0;
> > +
> > + if (pmd_leaf(*pmd))
> > + return 1ULL << PMD_SHIFT;
> > +
> > + pte = pte_offset_map(pmd, addr);
> > + if (!pte_present(*pte)) {
> > + pte_unmap(pte);
> > + return 0;
> > + }
> > +
> > + pte_unmap(pte);
> > + return PAGE_SIZE;
> > +}
>
> So this mostly works, but gets a number of hugetlb and arch specific
> things wrong.
>
> With the first 3 patches, this is only exposed to x86 and Power.
> Michael, does the above work for you?
>
> Looking at:
>
> arch/powerpc/include/asm/book3s/64/hugetlb.h:check_and_get_huge_psize()
>
> You seem to limit yourself to page-table sizes, however if I then look
> at the same function in:
>
> arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> arch/powerpc/include/asm/nohash/hugetlb-book3e.h
>
> it doesn't seem to constrain itself so.
>
> Patch 4 makes it all far worse by exposing it to pretty much everybody.
>
> Now, I think we can fix at least the user mappings with the below delta,
> but if archs are using non-page-table MMU sizes we'll need arch helpers.
>
> ARM64 is in that last boat.
>
> Will, can you live with the below, if not, what would you like to do,
> make the entire function __weak so that you can override it, or hook
> into it somewhere?
Hmm, so I don't think we currently have any PMUs that set 'data->addr'
on arm64, in which case maybe none of this currently matters for us.
However, I must admit that I couldn't figure out exactly what gets exposed
to userspace when the backend drivers don't look at the sample_type or
do anything with the addr field.
Will
next prev parent reply other threads:[~2020-10-09 9:38 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 13:57 [PATCH V9 0/4] Add the page size in the perf record (kernel) kan.liang
2020-10-01 13:57 ` [PATCH V9 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE kan.liang
2020-10-09 9:09 ` Peter Zijlstra
2020-10-09 9:16 ` Peter Zijlstra
2020-10-09 9:37 ` Will Deacon [this message]
2020-10-09 9:53 ` Peter Zijlstra
2020-10-20 2:49 ` Leo Yan
2020-10-20 7:19 ` Peter Zijlstra
2020-10-20 8:16 ` Leo Yan
2020-10-09 12:29 ` Liang, Kan
2020-10-09 12:57 ` Peter Zijlstra
2020-10-09 13:28 ` Michael Ellerman
2020-10-12 8:48 ` Will Deacon
2020-10-13 14:57 ` Liang, Kan
2020-10-13 15:46 ` Peter Zijlstra
2020-10-13 16:34 ` Peter Zijlstra
2020-11-04 17:11 ` Liang, Kan
2020-11-10 15:20 ` Liang, Kan
2020-11-11 9:57 ` Peter Zijlstra
2020-11-11 11:22 ` Peter Zijlstra
2020-11-11 12:43 ` Peter Zijlstra
2020-11-11 15:30 ` Matthew Wilcox
2020-11-11 15:52 ` Peter Zijlstra
2020-11-11 15:57 ` Peter Zijlstra
2020-11-11 16:38 ` Matthew Wilcox
2020-11-11 17:22 ` Peter Zijlstra
2020-11-11 18:26 ` Matthew Wilcox
2020-11-11 20:00 ` Peter Zijlstra
2020-11-11 22:33 ` Matthew Wilcox
2020-11-12 9:53 ` Peter Zijlstra
2020-11-12 11:36 ` Peter Zijlstra
2020-11-12 14:01 ` Matthew Wilcox
2020-10-29 10:51 ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-10-01 13:57 ` [PATCH V9 2/4] perf/x86/intel: Support PERF_SAMPLE_DATA_PAGE_SIZE kan.liang
2020-10-29 10:51 ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-10-01 13:57 ` [PATCH V9 3/4] powerpc/perf: " kan.liang
2020-10-29 10:51 ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-10-01 13:57 ` [PATCH V9 4/4] perf/core: Add support for PERF_SAMPLE_CODE_PAGE_SIZE kan.liang
2020-10-29 10:51 ` [tip: perf/core] " tip-bot2 for Stephane Eranian
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=20201009093750.GD29594@willie-the-truck \
--to=will@kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=benh@kernel.crashing.org \
--cc=dave.hansen@intel.com \
--cc=davem@davemloft.net \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®