Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6444127ybv; Wed, 12 Feb 2020 12:20:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzKbq7g1Apu2Bmo8DanOxxtTq7UiQVyBBXBw6EMujxZH82QNy9YjfGAaK5UKhIEhcuZ/Mt5 X-Received: by 2002:a9d:68da:: with SMTP id i26mr10858903oto.65.1581538805456; Wed, 12 Feb 2020 12:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581538805; cv=none; d=google.com; s=arc-20160816; b=TS0NdnIYWFsOYincXARA3iV3eOIV31a5yvip0bpuQai1XYbbaY4rpaDQcST1SGmKhB lcBYA+QW6Qdqgc95HQKWjcwAv71wjvaNEp518C4bTpfaeDedY/UUQOC0Ujps/rEnEA6P yHQSrL8IQRGqAG0KocwWbsTuhbC0Yuk/WlqAvKTSqgzE2u9YVEs1ZqMZhqLbFRg/2pC7 130iBQD0pX+tE9KirDw0mGC/ZFtyk3M8oG63HdnVQrEg4VUH6cUSTCeP1mHoDyzN81Tc lR68oN28KIJi8I+eJG7TjXCwvV6HL59UmkvLQUtHVkgBOy1py2LluVk0JYHdhvK104mJ uKVw== 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; bh=okO4hgtmb23fG4o9vU2EUDuWjzMQ3AS6q9VUz3pXMbs=; b=qt6dF0p5U5IjUgly6pq7bLQASaXRlE3tdVnyNyOHbHCYPAGyU+azA/nvLGQmtJxsjf eiYbfwTvrQ5mSytGQCyfE0J5cGS8lyiHaaLyMZMF/CAgxcfh+b2BlIzXg83pM/+btFjD JMiIWhcStGTiq7Hxy2AJeeqrt45rWSFrBXT2SQX4QDuHQKOz2O+BlOc0vY9ydsKcCalZ XreRddKTTKsNvh8tAeUyQDOyqufWNth6KV1nkunUh4BxCxQ60KEDZ1dWn1dqhI+OTj+X juk4c9tGVVDI5mCfY8/7Ii0KdrNB1fyUZksyopCHHIp2bw28+No0kQrWW88ao9RhBXkB RnjA== 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 h18si705915otk.227.2020.02.12.12.19.52; Wed, 12 Feb 2020 12:20:05 -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 S1729013AbgBLUTp (ORCPT + 99 others); Wed, 12 Feb 2020 15:19:45 -0500 Received: from foss.arm.com ([217.140.110.172]:37624 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbgBLUTo (ORCPT ); Wed, 12 Feb 2020 15:19:44 -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 2F4AB328; Wed, 12 Feb 2020 12:19:44 -0800 (PST) Received: from localhost (unknown [10.1.198.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2DB03F68E; Wed, 12 Feb 2020 12:19:43 -0800 (PST) Date: Wed, 12 Feb 2020 20:19:42 +0000 From: Ionela Voinescu To: Suzuki Kuruppassery Poulose Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, sudeep.holla@arm.com, lukasz.luba@arm.com, valentin.schneider@arm.com, rjw@rjwysocki.net, 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 Subject: Re: [PATCH v3 1/7] arm64: add support for the AMU extension v1 Message-ID: <20200212201942.GA12970@arm.com> References: <20200211184542.29585-1-ionela.voinescu@arm.com> <20200211184542.29585-2-ionela.voinescu@arm.com> <93472f17-6465-641d-ea82-3230b5697ffd@arm.com> <20200212161045.GA7475@arm.com> <133890f7-59bb-63b9-0ca8-2294e3596058@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <133890f7-59bb-63b9-0ca8-2294e3596058@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi guys, On Wednesday 12 Feb 2020 at 16:20:56 (+0000), Suzuki Kuruppassery Poulose wrote: > > For better handling I could have a cpumask_available check before the > > allocation just in case the capability type changes in the future, or to > > at least not rely on assumptions based on the type of the capability. > > > > The reason this is dynamic is that I wanted to avoid the memory being > > allocated when disable_amu is true - as Valentin mentioned in a comment > > in the meantime "the static allocation is done against NR_CPUS whereas > > the dynamic one is done against nr_cpu_ids". > > > > Would this be alright? > > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > index 182e05ca3410..4cee6b147ddd 100644 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@ -1222,7 +1222,11 @@ static bool has_amu(const struct arm64_cpu_capabilities *cap, > > * The enable function will also print a detection message. > > */ > > - if (!disable_amu && !zalloc_cpumask_var(&amu_cpus, GFP_KERNEL)) { > > + if (disable_amu) > > + return false; > > + > > + if (!cpumask_available(amu_cpus) && > > + !zalloc_cpumask_var(&amu_cpus, GFP_KERNEL)) { > > pr_err("Activity Monitors Unit (AMU): fail to allocate memory"); > > disable_amu = true; > > } Going down the rabbit hole in regards to this section, it seems it's actually not fine. When CONFIG_CPUMASK_OFFSTACK==y it fails to allocate memory because zalloc_cpumask_var cannot be used before initializing the slub allocator (mm_init) to allocate a cpumask. The alternative alloc_bootmem_cpumask_var is an __init function that can be used only during the initialization phase, which is not the case for has_amu that can be called later (for hotplugged CPUs). Therefore, dynamic allocation is not an option here. Thanks, Ionela.