Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 000A8C4332F for ; Mon, 13 Dec 2021 08:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233383AbhLMI4l (ORCPT ); Mon, 13 Dec 2021 03:56:41 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4250 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbhLMI4k (ORCPT ); Mon, 13 Dec 2021 03:56:40 -0500 Received: from fraeml710-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JCFgc3hB3z67Zt3; Mon, 13 Dec 2021 16:54:36 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml710-chm.china.huawei.com (10.206.15.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 13 Dec 2021 09:56:38 +0100 Received: from [10.47.80.231] (10.47.80.231) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 13 Dec 2021 08:56:36 +0000 Subject: Re: [PATCH 01/22] libperf: Add comments to perf_cpu_map. To: Arnaldo Carvalho de Melo , Ian Rogers CC: Andi Kleen , Jiri Olsa , "Namhyung Kim" , Kajol Jain , "Paul A . Clarke" , Riccardo Mancini , Kan Liang , Peter Zijlstra , "Ingo Molnar" , Mark Rutland , "Alexander Shishkin" , , , "Vineet Singh" , James Clark , "Mathieu Poirier" , Suzuki K Poulose , Mike Leach , Leo Yan , , , References: <20211208024607.1784932-1-irogers@google.com> <20211208024607.1784932-2-irogers@google.com> From: John Garry Message-ID: <02b330aa-ebce-11b2-9d3f-9b2497ae7133@huawei.com> Date: Mon, 13 Dec 2021 08:56:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.80.231] X-ClientProxiedBy: lhreml728-chm.china.huawei.com (10.201.108.79) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/2021 19:08, Arnaldo Carvalho de Melo wrote: >>>> +/** >>>> + * A sized, reference counted, sorted array of integers representing CPU >>>> + * numbers. This is commonly used to capture which CPUs a PMU is associated >>>> + * with. >>>> + */ >>>> struct perf_cpu_map { >>>> refcount_t refcnt; >>>> + /** Length of the map array. */ >>>> int nr; I'd have /s/nr/len/, as it means the map length, as opposed to confusing nr meaning with number of cpus in the host or something else. And the new comment uses "Length" also. >>>> + /** The CPU values. */ >>>> int map[]; >>> would simply more distinct names for the variables help instead of or in >>> addition to comments? > Well, in this case the typical usage doesn't help, as 'struct > perf_cpu_map' are being used simply as "map" There are a lot of instances to change ... but I am all up for using consistent and well-meaning variable / argument names per type. > where it should be cpu_map, > so we would have: > > cpu_map->nr > > And all should be obvious, no? Otherwise we would have redundant 'cpu', > like: > > cpu_map->nr_cpus > > And 'map' should really be entries, so: > > cpu_map->entries[index]; > > Would be clear enough, o? > >> Thanks John! I agree. The phrase that is often used is intention >> revealing names. The kernel style for naming is to be brief: