Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2250617pxu; Fri, 9 Oct 2020 11:38:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ8lt8c45RcBBWfpiPpB0IJvhUTQizfUW+IzqjviduFiFf411vnlLXOUbhP0PrpBf/xOgB X-Received: by 2002:a17:906:f51:: with SMTP id h17mr15364099ejj.534.1602268720133; Fri, 09 Oct 2020 11:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602268720; cv=none; d=google.com; s=arc-20160816; b=Zt6tLanzM6GG4owAQP8Do7gHpBHxZskx8WiVxiJploV1v88ofeJctG2Ji19Jd3g5sC rCjGcrLsD7mdOZXcqA96cq5POYGiM0gZIT5w70NWXg5TQaVQ9R/AvSAXoRKUhg9rtqBp jVkNBAjND38++F54r9VL/m1XyuWT6Rm8Uw5tPsVdyARBjtjZlVvgCQbwAJXhySXqTKEw Qarbta68sWiTCFLSDjCWUOrEO1rqlEah2wl1Us69QVdhiP1sUo04GhJQSATqSzPBCq+M HVTwrBht30mjO0I5QiU5HU5lJY52v70PprJOYizgujuWONOieASoVrBVNtC3kGwdWbgg BV2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ciiPvaZqbMG6HZYHrOzAH/ReMGF4QzryMy+6/rRjM+c=; b=U9sUP72sqvj8c3TTW1qwWjactS/4xFLKmZJ9FeuAdtJtOoelIrExpA6K9Amxbn2eaF KwNtma/hHnKDpZQEqamEkbVLTblOoB5bm9/nt6MsQFe2t7WyfUZ9luHzitOT/1iFZeul Pcl7Z+lG5Mb3SAFux584ro+li7SfwAbtgAcTiivSktPqIf8Fv1mm+SGQa97uuXi0ZFVj MjgTdoH/2KqeGfW5T71puQoGa/1/7H4dioIuIbmKKeoSTdjGNYDV1Fwx7qM/wbspmGsT OSIKOWRudsixsxheH8/nYeSbXY8Suoss5befbgd8y1cvyh6fELmiUDop9tdwnZPpEHhd 6g9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=iSsDgTME; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qu4si6592299ejb.611.2020.10.09.11.38.17; Fri, 09 Oct 2020 11:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=iSsDgTME; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387921AbgJIM5o (ORCPT + 99 others); Fri, 9 Oct 2020 08:57:44 -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.