From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EAAFC433DF for ; Fri, 9 Oct 2020 12:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BF8020658 for ; Fri, 9 Oct 2020 12:57:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="iSsDgTME" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387926AbgJIM5p (ORCPT ); Fri, 9 Oct 2020 08:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbgJIM5o (ORCPT ); Fri, 9 Oct 2020 08:57:44 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C8EC0613D2 for ; Fri, 9 Oct 2020 05:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ciiPvaZqbMG6HZYHrOzAH/ReMGF4QzryMy+6/rRjM+c=; b=iSsDgTMEUOFovS146KsV64gqD5 zZLF3ifegUuPfJUd+evyRTNCk5ATVgAtFcXtxVnnUrGE1kdpsKmfwX4r3OIVwHRqQkXVYgwoeDnSt 80mymIk8b1YI6CyW8XZms+ugTBgtVuliwpL+33SIXdY8V+1A5jF25mSKn3I1SSEj1pDVk1ni8/3Ph Gzk7vU+fBarpAJGYhoUinPl2eichy5kxvRyk9LB3q2tHNJD2UB0qIKxPfy/zgSQUoROwnE1V6rDKB /ZEFwTqX7DeY+y/4XS0ijID61ZXWtBOxNBiLJwiO7TdcHM7LfFXSLvkY8GDTAqt7HPy6St3p8V48j y6TMOBoQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQrxd-0001Pm-Bp; Fri, 09 Oct 2020 12:57:25 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 92C213019CE; Fri, 9 Oct 2020 14:57:21 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7BB182B856EA8; Fri, 9 Oct 2020 14:57:21 +0200 (CEST) Date: Fri, 9 Oct 2020 14:57:21 +0200 From: Peter Zijlstra To: "Liang, Kan" Cc: 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, Will Deacon , David Miller Subject: Re: [PATCH V9 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE Message-ID: <20201009125721.GO2628@hirez.programming.kicks-ass.net> References: <20201001135749.2804-1-kan.liang@linux.intel.com> <20201001135749.2804-2-kan.liang@linux.intel.com> <20201009090927.GQ2611@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 09, 2020 at 08:29:25AM -0400, Liang, Kan wrote: > > > On 10/9/2020 5:09 AM, Peter Zijlstra wrote: > > (we might not need the #ifdef gunk, but I've not yet dug out my cross > > compilers this morning) > > > > --- > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -7009,6 +7009,7 @@ static u64 perf_virt_to_phys(u64 virt) > > */ > > static u64 __perf_get_page_size(struct mm_struct *mm, unsigned long addr) > > { > > + struct page *page; > > pgd_t *pgd; > > p4d_t *p4d; > > pud_t *pud; > > @@ -7030,15 +7031,27 @@ static u64 __perf_get_page_size(struct m > > if (!pud_present(*pud)) > > return 0; > > - if (pud_leaf(*pud)) > > + if (pud_leaf(*pud)) { > > +#ifdef pud_page > > + page = pud_page(*pud); > > + if (PageHuge(page)) > > + return page_size(compound_head(page)); > > I think the page_size() returns the Kernel Page Size of a compound page. > What we want is the MMU page size. > > If it's for the generic code, I think it should be a problem for X86. See the PageHuge() condition before it. It only makes sense to provide a hugetlb page-size if the actual hardware supports it. For x86 hugetlb only supports PMD and PUD sized pages, so the added code is pointless and should result in identical behaviour. For architectures that have hugetlb page sizes that do not align with the page-table levels (arm64, sparc64 and possibly power) this will (hopefully) give the right number.