Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp229199rdg; Thu, 12 Oct 2023 04:11:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEFEcEL9wWBVXuIGNrDn6KrHvrdr4kNg+gbWlrwoWtSuFnxdf58IQVoebKeBUz/iduD4w+ X-Received: by 2002:a17:902:ea86:b0:1c9:ccbd:6867 with SMTP id x6-20020a170902ea8600b001c9ccbd6867mr3331181plb.38.1697109108540; Thu, 12 Oct 2023 04:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697109108; cv=none; d=google.com; s=arc-20160816; b=nRCUtXb4JhR6V0irgXYp3PiwQ35PR1h1I1V/5vu1z2Ctc4znKQyR3WbtxaNPAin7PD rb0BVzlRUTotYH2z7d1HuvFoUGfzdJq8RN1kUeSxJshIZ350n1VD8fQZQlll63RTbF6j XQnDiBk2MPt4egoKmHHGgQHqb9iDE0JEXhb8ecq1+O20CnIqgBJwSriMj+tsPafj/cE2 fLPFvplM2f15AbyKxN36MfZjfqycTl8dCUAZyzjRKANvsXAvSeHgZo/QCf55LI1YeNKd DLlHup7ruo0CE4+OO7rBM9MMJepkaE0bI0+jufbmb/j/OxoZIY87xhwvRctVfTdWJB0x BnDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=8x3GePOL2KSd/2ovIClFl+wJQ+cPZ4pop7KUlhdszbM=; fh=35w9gyY3a8Ab3Ldxtj/bv9lfB0Pa1m9+lbaz5GsEEcc=; b=aoUEetJEIZkyWyXRi3tF1BvH6cU6nLNBhW4F0CLZYkHa3RHZPAb9wbXdZ26hfJSQcP loivbg3cxj7NZcVe6StWdfxZWfLkWUajCY2kYpC220krlBYx3fb1I27lmRJMiqAIklt8 QciCLADSWGarnlhJ5/zEeayKJujCheRZMIqR1BYvZ00xouOKmnjWyKttGpPD4VQUx5ce f515dvrCfrMQzMqLj+Rft2me4U4w3/AVgExZRaK4AB3lfI87tJ8w9i/j3ZsMK9tYKG2P rR4Z9qpMJuqLGS55kJ6PBvPCj65WTlphUJhLvzYFgqS3MirdoJQdruaQuoFtvq1xWiLQ goJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c23-20020a170902b69700b001b674055d72si1865429pls.621.2023.10.12.04.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id F2400812724B; Thu, 12 Oct 2023 04:11:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377950AbjJLLLb (ORCPT + 99 others); Thu, 12 Oct 2023 07:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343805AbjJLLLa (ORCPT ); Thu, 12 Oct 2023 07:11:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 761AF90 for ; Thu, 12 Oct 2023 04:11:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04A9113D5; Thu, 12 Oct 2023 04:12:09 -0700 (PDT) Received: from [10.163.62.137] (unknown [10.163.62.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BFF93F762; Thu, 12 Oct 2023 04:11:25 -0700 (PDT) Message-ID: <5eabcdf7-f88c-4c79-a5c8-0c000493d72a@arm.com> Date: Thu, 12 Oct 2023 16:41:23 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() Content-Language: en-US To: Robin Murphy , James Clark , linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Mark Rutland , linux-kernel@vger.kernel.org References: <20231009035638.165270-1-anshuman.khandual@arm.com> <896fc51e-2c74-29f7-2c7e-f14f29c401a4@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:11:43 -0700 (PDT) On 10/10/23 17:29, Robin Murphy wrote: > On 09/10/2023 10:17 am, James Clark wrote: >> >> >> On 09/10/2023 04:56, Anshuman Khandual wrote: >>> There is just a single call site remaining for armv8_pmu_init(), passing on >>> NULL pointers for all custom 'struct attribute_group'. These arguments are >>> not really getting used and hence can just be dropped off, thus simplifying >>> the code further. >>> >>> Cc: Will Deacon >>> Cc: Mark Rutland >>> Cc: linux-arm-kernel@lists.infradead.org >>> Cc: linux-kernel@vger.kernel.org >>> Signed-off-by: Anshuman Khandual >>> --- >>> This applies on v6.6-rc5. >>> >>>   drivers/perf/arm_pmuv3.c | 17 +++++------------ >>>   1 file changed, 5 insertions(+), 12 deletions(-) >>> >>> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >>> index 8fcaa26f0f8a..fe4db1831662 100644 >>> --- a/drivers/perf/arm_pmuv3.c >>> +++ b/drivers/perf/arm_pmuv3.c >>> @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) >>>   } >>>     static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>> -              int (*map_event)(struct perf_event *event), >>> -              const struct attribute_group *events, >>> -              const struct attribute_group *format, >>> -              const struct attribute_group *caps) >>> +              int (*map_event)(struct perf_event *event)) >>>   { >>>       int ret = armv8pmu_probe_pmu(cpu_pmu); >>>       if (ret) >>> @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>>         cpu_pmu->name            = name; >>>       cpu_pmu->map_event        = map_event; >>> -    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? >>> -            events : &armv8_pmuv3_events_attr_group; >>> -    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? >>> -            format : &armv8_pmuv3_format_attr_group; >>> -    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? >>> -            caps : &armv8_pmuv3_caps_attr_group; >>> - >>> +    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; >>> +    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; >>> +    cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; >>>       armv8_pmu_register_sysctl_table(); >>>       return 0; >>>   } >>> @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>>   static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, >>>                      int (*map_event)(struct perf_event *event)) >>>   { >>> -    return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); >>> +    return armv8_pmu_init(cpu_pmu, name, map_event); >> >> I think the whole point of the nogroups wrapper was to add the NULLs. If >> you remove them, then you can remove the nogroups function too and just >> call armv8_pmu_init() directly instead. > > Indeed the "nogroups" wrapper is entirely meaningless if the callee no longer accepts groups anyway. > >> And as it wasn't clear why they were there in the first place, I went to >> look and found this (e424b17) : >> >>    Although nobody uses non-default sysfs attributes today, there's >>    minimal impact to preserving the notion that maybe, some day, somebody >>    might, so we may as well keep up appearances. >> >> It might be worth mentioning that the decision has now been made in the >> other way. > > Right, the intent at the time was very much just a cosmetic cleanup to help readability and simplify adding new PMU names, and rather deliberately stepping around the question of making material changes to the interface itself. If we've reached the point where we're happy to agree that consistency with the PMUv2 code is no longer helpful to continuing development of the PMUv3 code, then *that* would be the fundamental point of this change. Does the following commit message sound complete after dropping off the armv8_pmu_init_nogroups() helper as well. driver: perf: arm_pmuv3: Drop some unused arguments from armv8_pmu_init() There is just a single call site remaining for armv8_pmu_init(), passing on NULL pointers for all custom 'struct attribute_group'. These arguments are not really getting used, and hence can be dropped. Afterwards the function armv8_pmu_init_nogroups() itself becomes redundant and can also be dropped as well. The commit e424b1798526 ("arm64: perf: Refactor PMU init callbacks") wanted to preserve the notion that non-default sysfs attributes could be used some time in the future and hence armv8_pmu_init_nogroups() stayed on but now it can be dropped to remove some redundant indirection, simplifying the code.