Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1441345pxb; Thu, 28 Oct 2021 03:53:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYbZKMhWxkdcIz7p5UM3/9q9G65FBRZCCXIWQQJ1Bo/ODXmoYsU3Drw/+qzl6HN6EOpI4v X-Received: by 2002:a17:907:98a2:: with SMTP id ju2mr4407821ejc.267.1635418398490; Thu, 28 Oct 2021 03:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635418398; cv=none; d=google.com; s=arc-20160816; b=VCj6v4ZuvHGtY1eeDIf4z/5CsKfMstKGaBqxgwSoBp2shvK2wPBhvOYfmMY2PaVyRp lRL2/Q8QDCf5sCCuwLEYgLW7CVtdpgADkckvZu4zBKrpA6WSE6Jq8wL64xmeVzD42c+M agQ7VDXSm/SrHQkCWTHq8+maMAfC7yhb4rQscS6VuvnFQbYUIWM8PntUBCrZ1U2aZEvz kMa8CvAm8OLkKW4qbWIPdgzOY3G7g98iX6xScQNY8J8wW0kL3NXFke8iYOVgcNStxWlB Bqp3uOnL3R6nQFVRRz0R35PN8JqyGcz6DxcRafqj8ZIld6fnF/JvbQ38dvNYTUblQNZR EVhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=RWOIZk1THjwuwnHawh3dLtkbHPZl3QdCjqd7n6jUbrs=; b=Q7eiEIyOzhm5dpYRn47G/xT5f7pImnhCSh8ymH7ZS4FK9gt2IXSREz5ockOOr6IXpK P3WSy1dVUrSu2bbTsauoMyZdgg5t5VQp0jU7AYNLea2TN0D5dNkn+anBiEviMePFNVw5 dkts6C6JbAv87MZulhlj8Ob5Gb+QPX2pacbbkb0fRKGqZwjy9XLxnfplcisIfFicnuaI iCq3JPfFTcB+GwJV18AOH59Do5SljnvLHVKap+OobKI4Q5/J6QrF3A416uzzyyC0YXGd wMY0+7zZOG55JZOCNb128bJR1dVm2HoEzv8DVFSMR2eEYGCNk2fACLc5zWbPeEryv5vg JmpA== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs7si3996088ejc.329.2021.10.28.03.52.54; Thu, 28 Oct 2021 03:53:18 -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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbhJ1Kvc (ORCPT + 99 others); Thu, 28 Oct 2021 06:51:32 -0400 Received: from foss.arm.com ([217.140.110.172]:53354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbhJ1Kvc (ORCPT ); Thu, 28 Oct 2021 06:51:32 -0400 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 273AF1FB; Thu, 28 Oct 2021 03:49:05 -0700 (PDT) Received: from e113632-lin (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CFBD3F5A1; Thu, 28 Oct 2021 03:49:04 -0700 (PDT) From: Valentin Schneider To: Jiasheng Jiang , peterz@infradead.org, namit@vmware.com, mingo@kernel.org, dave.hansen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: Re: [PATCH v3] cpumask: Fix implicit type conversion In-Reply-To: <1635404811-2992370-1-git-send-email-jiasheng@iscas.ac.cn> References: <1635404811-2992370-1-git-send-email-jiasheng@iscas.ac.cn> Date: Thu, 28 Oct 2021 11:48:56 +0100 Message-ID: <871r45whk7.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/10/21 07:06, Jiasheng Jiang wrote: > The description of the macro in `include/linux/cpumask.h` says the > variable 'cpu' can be int, whose value ranges from (-2^31) to > (2^31 - 1). > However in the for_each_cpu(), 'nr_cpu_ids' and the return value of > cpumask_next() is unsigned int, whose value ranges from 0 to > (2^32 - 1). > If return value of cpumask_next() is (2^31), the restrict > 'cpu < nr_cpu_ids' can also be statisfied, but the actual value > of 'cpu' is (-2^31). > Take amd_pmu_cpu_starting() in `arch/x86/events/amd/core.c` as an > example. When value of 'cpu' is (-2^31), then in the per_cpu(), > there will apear __per_cpu_offset[-2^31], which is array out of > bounds error. > Moreover, the num of cpu to be the negative doesn't make sense and > may easily causes trouble. > It is universally accepted that the implicit type conversion is > terrible. > Also, having the good programming custom will set an example for > others. > Thus, it might be better to fix the macro description of 'cpu' and > deal with all the existing issues. > AFAIA the upper bounds for NR_CPUS are around 2^12 (arm64) and 2^13 (x86); I don't think we're anywhere near supporting such massive systems. I got curious and had a look at the size of .data..percpu on a defconfig arm64 kernel - I get about ~40KB. So purely on the percpu data side of things, we're talking about 100TB of RAM... Trying to improve the code is laudable, but I don't see much incentive in the churn ATM. > Fixes: c743f0a ("sched/fair, cpumask: Export for_each_cpu_wrap()") > Fixes: 8bd93a2 ("rcu: Accelerate grace period if last non-dynticked CPU") > Fixes: 984f2f3 ("cpumask: introduce new API, without changing anything, v3") Where's the v1->v2->v3 changelog? This is merely fiddling with doc headers, what's being fixed here?