Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5298426pxv; Tue, 6 Jul 2021 23:57:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwi7gsclfrpxqJ4Re7VUych8hPEwWJ24I7hjPyPzgQ8jUeXUnaJzbSGN7UN6tjDpBDMDBVj X-Received: by 2002:a17:906:b0c8:: with SMTP id bk8mr22850131ejb.412.1625641031337; Tue, 06 Jul 2021 23:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625641031; cv=none; d=google.com; s=arc-20160816; b=A4H8jiHR/IGCRwTUhxoulfLubGXQzJTB3ZqyPRcJCX6T6Wx/R4O2/llyTg9ACC5fXa lccmpN/qQTdQeCxKqMlkdTxIFWMOxvgYv+gdsfrOnB+yGoNrLFBpXeWxOCfJrZDJ2JSt 0GpHLpRQZqxdHDTvtvuHiDKd2xrm7M0JB/ssQzRZplw2BPVgOwqdjwlEOkS5/yX3kTY3 K2GAWeu43Z9c4x4/RtMZB4smhpris5f1PHOcHi94oYsY1dJ8TuRX6l7juoPcyGUTiwvR IiY8W6SgKmgaTko6DaEvkw5C3GhZBdOLvZSiEN/PiJB1mHOiagcohfA151xFEtup34NM HJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oyDX1z94Iwos9KVOEKB47u9GSSOGCkU8RG02C1zUisE=; b=ofTCATKCb7kRqkYPB7Rf5Fk+SoMt148j7RaQ6QThhH2lDJ98iLGDgcS93/DJzq3ErY PaS2/tkQ+BbH1AXhyEagmmh44Yg43rcEf0oZb+W8TyJ6JELjt5Cchd1CIAhuKi3EeKvJ Fnl1PxVOyuXpesxzgUDj8U3kzw1OSHRqNR4KJ486zEH2R2yAP3nUZ0IAGWoStRDjGafp IjEvREPgdVdjbwM5U9atOZYn6Xek7HQbe3HQtGbFY+yyQJKrDpxpLRfYj7afumk25SOL KT2M2JI4YWQbk3i/QrN4yx8qsQ3bEtDxC5PC0DUhyvmA5P6tLbihXkFlFiw/abZVy+/J cByw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw28si16558868edb.529.2021.07.06.23.56.47; Tue, 06 Jul 2021 23:57:11 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbhGGG5i (ORCPT + 99 others); Wed, 7 Jul 2021 02:57:38 -0400 Received: from mga05.intel.com ([192.55.52.43]:57030 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbhGGG5h (ORCPT ); Wed, 7 Jul 2021 02:57:37 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="294891331" X-IronPort-AV: E=Sophos;i="5.83,331,1616482800"; d="scan'208";a="294891331" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 23:54:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,331,1616482800"; d="scan'208";a="647775783" Received: from nntpdsd52-165.inn.intel.com ([10.125.52.165]) by fmsmga005.fm.intel.com with ESMTP; 06 Jul 2021 23:54:56 -0700 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: kan.liang@linux.intel.com, ak@linux.intel.com, alexander.antonov@linux.intel.com, alexey.v.bayduraev@linux.intel.com Subject: [RESEND PATCH] perf/x86/intel/uncore: Fix IIO cleanup mapping procedure for SNR/ICX Date: Wed, 7 Jul 2021 09:54:55 +0300 Message-Id: <20210707065455.10271-1-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Antonov Cleanup mapping procedure for IIO PMU is needed to free memory which was allocated for topology data and for attributes in IIO mapping attribute_group. Current implementation of this procedure for Snowridge and Icelake Server platforms doesn't free allocated memory that can be a reason for memory leak issue. Fix the issue with IIO cleanup mapping procedure for these platforms to release allocated memory. Fixes: 10337e95e04c ("perf/x86/intel/uncore: Enable I/O stacks to IIO PMON mapping on ICX") Reviewed-by: Kan Liang Signed-off-by: Alexander Antonov --- arch/x86/events/intel/uncore_snbep.c | 40 +++++++++++++++++++--------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index bb6eb1e5569c..54cdbb96e628 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3836,26 +3836,32 @@ pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag) return ret; } -static int skx_iio_set_mapping(struct intel_uncore_type *type) -{ - return pmu_iio_set_mapping(type, &skx_iio_mapping_group); -} - -static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) +static void +pmu_iio_cleanup_mapping(struct intel_uncore_type *type, struct attribute_group *ag) { - struct attribute **attr = skx_iio_mapping_group.attrs; + struct attribute **attr = ag->attrs; if (!attr) return; for (; *attr; attr++) kfree((*attr)->name); - kfree(attr_to_ext_attr(*skx_iio_mapping_group.attrs)); - kfree(skx_iio_mapping_group.attrs); - skx_iio_mapping_group.attrs = NULL; + kfree(attr_to_ext_attr(*ag->attrs)); + kfree(ag->attrs); + ag->attrs = NULL; kfree(type->topology); } +static int skx_iio_set_mapping(struct intel_uncore_type *type) +{ + return pmu_iio_set_mapping(type, &skx_iio_mapping_group); +} + +static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &skx_iio_mapping_group); +} + static struct intel_uncore_type skx_uncore_iio = { .name = "iio", .num_counters = 4, @@ -4499,6 +4505,11 @@ static int snr_iio_set_mapping(struct intel_uncore_type *type) return pmu_iio_set_mapping(type, &snr_iio_mapping_group); } +static void snr_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &snr_iio_mapping_group); +} + static struct intel_uncore_type snr_uncore_iio = { .name = "iio", .num_counters = 4, @@ -4515,7 +4526,7 @@ static struct intel_uncore_type snr_uncore_iio = { .attr_update = snr_iio_attr_update, .get_topology = snr_iio_get_topology, .set_mapping = snr_iio_set_mapping, - .cleanup_mapping = skx_iio_cleanup_mapping, + .cleanup_mapping = snr_iio_cleanup_mapping, }; static struct intel_uncore_type snr_uncore_irp = { @@ -5090,6 +5101,11 @@ static int icx_iio_set_mapping(struct intel_uncore_type *type) return pmu_iio_set_mapping(type, &icx_iio_mapping_group); } +static void icx_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &icx_iio_mapping_group); +} + static struct intel_uncore_type icx_uncore_iio = { .name = "iio", .num_counters = 4, @@ -5107,7 +5123,7 @@ static struct intel_uncore_type icx_uncore_iio = { .attr_update = icx_iio_attr_update, .get_topology = icx_iio_get_topology, .set_mapping = icx_iio_set_mapping, - .cleanup_mapping = skx_iio_cleanup_mapping, + .cleanup_mapping = icx_iio_cleanup_mapping, }; static struct intel_uncore_type icx_uncore_irp = { base-commit: 3dbdb38e286903ec220aaf1fb29a8d94297da246 -- 2.21.3