Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6148628ybv; Wed, 12 Feb 2020 06:55:26 -0800 (PST) X-Google-Smtp-Source: APXvYqww5Rs3ht/2RVzl1p4knQ4AwGXeG8bgVA1JyHrOz60TgKaWeB4CZ+mgTt920JTtgCKiEVoc X-Received: by 2002:a9d:6647:: with SMTP id q7mr9878412otm.35.1581519326150; Wed, 12 Feb 2020 06:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581519326; cv=none; d=google.com; s=arc-20160816; b=n2DMpvcm//7M378yE9Y+FX5K0C/ZR4k88savyMcNftlafUE9j6KhC3Te2gK1VB4kpq 1Yct9v4+hklvpJoyGRnx4Q2ziyMjOo8w2b/mmmQqn2pj0wS8NzASI4MRUnEUGRu8Jlre RAkGpdxUg7novEcO5uZxksOxWCMEIzAvJzlgWiukvI3JOrJhT16fOlxSOrEOBY3G5hcw 07Us/JQB6Si/zodzrQBUrpVACeP19C5Z+MDGQj32olNw1YRK0jYqlEqNpJ65+GybHux7 fpi74X3p9L8VO5efI2h1yLLbB38kKwivekodMSRfNhgQy1NW7+/foBMTWDukVPK20UvW pgSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=hSvDlKz4zqG9AYQeE9a4GViY3KE4xWWUR4qNH+xKAAA=; b=rOqSbJM1kG7nEbdKWERGAmOygPk5ntgzbSOcsHGCMpWWF8F4rWEq0mZDcTNPyB8KJG 78R4X+KCNMEbLvcx4QoBxz3FLVYaD6BfTXUw2A/LqARzfEqZvwVMRuoILWg17saU6rQ5 VVw1nJmT5CcdwFDkZSTaMDuDejDTo1q006NjRaGhrelfnV/4a9WiiyrvTo7Lsb5AtXHB mihEUEwVLHnzDL42k7LvdLx7tnTfIVAjzqUA8Zl8NgsRMlo0/VS2l8FwsOAAcLPArqPp SVFJZcMfS4fHwMAg54+vXYPP0T8HeAfK0PbxIzQCz+tFWQjZThRSCQG5DPyhzewMhgWy xTDw== ARC-Authentication-Results: i=1; mx.google.com; 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 n207si3191332oig.185.2020.02.12.06.55.13; Wed, 12 Feb 2020 06:55:26 -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; 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 S1728393AbgBLOyt (ORCPT + 99 others); Wed, 12 Feb 2020 09:54:49 -0500 Received: from foss.arm.com ([217.140.110.172]:33824 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbgBLOyt (ORCPT ); Wed, 12 Feb 2020 09:54:49 -0500 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 8540B328; Wed, 12 Feb 2020 06:54:48 -0800 (PST) Received: from [10.1.194.46] (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 63BE63F68F; Wed, 12 Feb 2020 06:54:46 -0800 (PST) Subject: Re: [PATCH v3 1/7] arm64: add support for the AMU extension v1 To: Suzuki Kuruppassery Poulose , Ionela Voinescu , catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, sudeep.holla@arm.com, lukasz.luba@arm.com, rjw@rjwysocki.net Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org References: <20200211184542.29585-1-ionela.voinescu@arm.com> <20200211184542.29585-2-ionela.voinescu@arm.com> <93472f17-6465-641d-ea82-3230b5697ffd@arm.com> From: Valentin Schneider Message-ID: Date: Wed, 12 Feb 2020 14:54:45 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <93472f17-6465-641d-ea82-3230b5697ffd@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/02/2020 11:30, Suzuki Kuruppassery Poulose wrote: >> +static bool has_amu(const struct arm64_cpu_capabilities *cap, >> +               int __unused) >> +{ >> +    /* >> +     * The AMU extension is a non-conflicting feature: the kernel can >> +     * safely run a mix of CPUs with and without support for the >> +     * activity monitors extension. Therefore, if not disabled through >> +     * the kernel command line early parameter, enable the capability >> +     * to allow any late CPU to use the feature. >> +     * >> +     * With this feature enabled, the cpu_enable function will be called >> +     * for all CPUs that match the criteria, including secondary and >> +     * hotplugged, marking this feature as present on that respective CPU. >> +     * The enable function will also print a detection message. >> +     */ >> + >> +    if (!disable_amu && !zalloc_cpumask_var(&amu_cpus, GFP_KERNEL)) { > > This looks problematic. Don't we end up in allocating the memory during > "each CPU" check and thus leaking memory ? Do we really need to allocate > this dynamically ? > For the static vs dynamic thing, I think it's not *too* important here since we don't risk pwning the stack because of the cpumask. That said, if we are somewhat pedantic about memory usage, the static allocation is done against NR_CPUS whereas the dynamic one is done against nr_cpu_ids. Pretty inconsequential for a single cpumask, but I guess it all adds up eventually...