Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5226854ybl; Tue, 10 Dec 2019 02:39:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwBmOqnwmNDN/sggGjT2u5sFcSW/icK/L0h7OH/KF6lGyiET6FAayNuLA/Iq5TahRCxSKt4 X-Received: by 2002:aca:df07:: with SMTP id w7mr3376229oig.145.1575974383150; Tue, 10 Dec 2019 02:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575974383; cv=none; d=google.com; s=arc-20160816; b=pLccL9cW2+TB3CErp0YG8AsAxOYTKlHvIUYysC38dYl+00gJZEOHiQhK/UMiUVqaQv Tt1s9+r+DQYEcyjKtWJyspCJ7tqmpLSgkrBQbJFnLw7Ur7XwBubs9eQzqQB+F4yqeZUC j0u/23/wQIaQ7R0dqMuFOzcW3B039Q7Wau7S50sAB/lTVlKwzZ5g59PFuVOMXE31uAyU 8ye2IMGGQF/jq7jOAGyV3qGmCPCyRtQa3QkRoiVr9QzSHJH1sod84UHTwFXda9DvPNVk HB8FSZQLlVN8Els7U6n04Be5/U+BH3CRXjMFmSNtbN+OxO8V5SQEiB8crntm79DEW94z ACgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0Pk6fpOAs1zSSn4uGzDdXFp1KU2QDahtOIvZD6vEWak=; b=wQWWw06eevCKfuP781x4gaKZ6+3ooXcGL34hZ7h2wZDl4oEiivJ5H/YowCIRiSjhau geNAMjbJFhIA9uEbW+yNBQrY75Ppw+aU6axwb3OHxg+gFmkxzVz0sKRtt3p26pqfWdaq c+4TNkqQgoAWIEm9qlH5xLJKn7ypek4ETIVzBalK+TEf6++zhEGKgquD3SU2tIj13iUx L6+kFLaRpuHLYvD92IqdPUExPEqUyR/uu/QesLb4m02HFLdYJxYoXvhevWVYVZ5gBwjH /qlFQsNYW/PyimX5YmpzK2w34WtF8+4nAkENPuHFYXXE09Do9vmEYHJSXit1V3bNfilv iHnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="pN8Vw//n"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si1681882oij.136.2019.12.10.02.39.29; Tue, 10 Dec 2019 02:39:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="pN8Vw//n"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbfLJKhW (ORCPT + 99 others); Tue, 10 Dec 2019 05:37:22 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57800 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727039AbfLJKhV (ORCPT ); Tue, 10 Dec 2019 05:37:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0Pk6fpOAs1zSSn4uGzDdXFp1KU2QDahtOIvZD6vEWak=; b=pN8Vw//nXw/J1ZpW6zbXebw9r 3O48iCaw57kz+I/1T+kauz+XWS/o6O/445wKuqKmaej/huO89KLJD1I/fQbXEDoQLdY7k8a6K5YEs JSh/sgd3akyRO7GLjMnUBKkSQTloU4tMNb8lmpRB50x06XIS0cy+6FIsDfgjqI9k6wkd9pvbg62g4 Dy1zPNy46Du7r3pUWD0ya/wVDm0iOSozpmgNUtR9jqw5O7DHmUkQ8/Rp5AXdP28+gi3C5o0LP8P8J qP1StmNyXpHsXK6OPhutJZiw34qzhqlw0VTBptZkfI+LIzPCGitXb/qIYhiy2rzxFp9W7ISqJ0mXj HhTWn9Suw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iectE-00082e-UL; Tue, 10 Dec 2019 10:37:13 +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 9FCFA305FD1; Tue, 10 Dec 2019 11:35:50 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 13A212010F13C; Tue, 10 Dec 2019 11:37:10 +0100 (CET) Date: Tue, 10 Dec 2019 11:37:10 +0100 From: Peter Zijlstra To: roman.sudarikov@linux.intel.com Cc: mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com, bgregg@netflix.com, ak@linux.intel.com, kan.liang@linux.intel.com, alexander.antonov@intel.com, Greg Kroah-Hartman Subject: Re: [PATCH v2 2/3] perf x86: Add compaction function for uncore attributes Message-ID: <20191210103710.GM2844@hirez.programming.kicks-ass.net> References: <20191210091451.6054-1-roman.sudarikov@linux.intel.com> <20191210091451.6054-3-roman.sudarikov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191210091451.6054-3-roman.sudarikov@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 10, 2019 at 12:14:50PM +0300, roman.sudarikov@linux.intel.com wrote: > From: Roman Sudarikov > > In current design, there is an implicit assumption that array of pointers > to uncore type attributes is NULL terminated. However, not all attributes > are mandatory for each Uncore unit type, e.g. "events" is required for > IMC but doesn't exist for CHA. That approach correctly supports only one > optional attribute which also must be the last in the row. > The patch removes limitation by safely removing embedded NULL elements. > > Co-developed-by: Alexander Antonov > Signed-off-by: Alexander Antonov > Signed-off-by: Roman Sudarikov > --- > arch/x86/events/intel/uncore.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c > index 24e120289018..a05352c4fc01 100644 > --- a/arch/x86/events/intel/uncore.c > +++ b/arch/x86/events/intel/uncore.c > @@ -923,6 +923,22 @@ static void uncore_types_exit(struct intel_uncore_type **types) > uncore_type_exit(*types); > } > > +static void uncore_type_attrs_compaction(struct intel_uncore_type *type) > +{ > + int i, j; > + int size = ARRAY_SIZE(type->attr_groups); > + > + for (i = 0, j = 0; i < size; i++) { > + if (!type->attr_groups[i]) > + continue; > + if (i > j) { > + type->attr_groups[j] = type->attr_groups[i]; > + type->attr_groups[i] = NULL; > + } > + j++; > + } > +} GregKH had objections to us playing silly games like that and made us use is_visible() for the regular PMU driver. Also see commit: baa0c83363c7 ("perf/x86: Use the new pmu::update_attrs attribute group")