Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp188760rdb; Mon, 15 Jan 2024 17:54:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IErn/r+Ed3Qv3zyDsYp/tBjzF/PIDTHztty/eLJuqHBzBNQK6m+C7gA6YzYVptpgBfbxkMG X-Received: by 2002:a05:600c:a06:b0:40e:545b:80bc with SMTP id z6-20020a05600c0a0600b0040e545b80bcmr3349506wmp.29.1705370073976; Mon, 15 Jan 2024 17:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705370073; cv=none; d=google.com; s=arc-20160816; b=HwAtYUuZ5kddTJQR4dfhMeQdX1iJozSi3Zy36fdSgVzbSXKObHUvihGSQrWMhQlcpz MDfGcvW0mi0fQGDXIKyHVrKh8W5QWJc+jqS/ZEY5E2DGuJ2mP7bLFloB1ucoBiHOD7gb hAYbdKwZHxHKIEGsovbf2c9NPoWEjI/WPqjLZ1vRE6Ghkn9igtElGLiGTvQyshBkRMYn 1v8BRorMVLh5gdyYFzFS+cF1LRgttcmiYJAbHEmjztXtSLjyFh6gqe3XtmZI7fmC4bNj DwhUM76rIL3ct7o0XN+GT4zKGqaIeR0c6qyTXb9m8Iozf81BmNRuqxp4GugZnrcJgO5M 0Ewg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=o8hnltv5srOuJiY42p6bbzUt1u60cDFedeaX1OngYaM=; fh=ihGboVTtCv8CzsMj3hT37OeobYFojCPTfdKvuSJWOkM=; b=JhYAP8EslkAsAWKli4asIrKdHCIv1OYeryG0r3ctbqgFUr6lhwP+E8oRA13UG49AoR 5+nyU8ppLSjFpsLEBBz6ZHujZ8MOr3vLUU/jCcyeoMhIeO04eUA23ZCLHs6gpb6cJn6k 8ze1VPAMxCEiaDiuooYxdyhCVgy9UTBB+Y//ziGjCqZqsMN84Bgxe0xQoCjngRhHWUSd rQlZ7qoQW6HOr5N8kJ44WDOzgQOn9VSJZlfgx+JzZ4WhwGXA6RPTTZQ8AYSJSuzLqR6Q CXMnHSp0TjSoN3hl9hSzL2dAwYdB6DzjciBvFRrUktGXxPuOfCLjdDNdAU/sV7UVxyBx ihsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jxz4VonQ; spf=pass (google.com: domain of linux-kernel+bounces-26907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bs5-20020a170906d1c500b00a28b9e9906csi4213057ejb.100.2024.01.15.17.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jxz4VonQ; spf=pass (google.com: domain of linux-kernel+bounces-26907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 80C341F23AAA for ; Tue, 16 Jan 2024 01:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91B657491; Tue, 16 Jan 2024 01:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jxz4VonQ" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CBBD8BFE for ; Tue, 16 Jan 2024 01:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705368308; x=1736904308; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=UF3bollbDru88APZqfgYdHHI6MxP3KGUb+uE+8+oI1A=; b=jxz4VonQaWht9Vuucf3pWNwWXGju74oeERqKUPRYFKuFQrZPaXmTItYU OiBoXWlReifsSTsNuB0x1RMJy1AoayZyVkJBSIIN8xgKJFG71V8juEC5S +CFE66I14eo0PXT/UtpH9QMUlRXjeC6SOYDwHVzH/MKODk0D1+cfpKeZV 8yS9Pub1ORthdObX8A9Ih5TiZrxGrNq51DwpBNoVsxgXtV7+dcgr9uiSI gL13+Vg5MPtREWh0eKh1VIyhQP1qhtKTQblh2hh71ZJmrqIZCut3GTNhI +TxlvqryBMLUKosDdgFTA5yXImpJqDd9NSOvDAMnW8NcMViRGZ8z7a2+f g==; X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="464006963" X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="464006963" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2024 17:25:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="733429707" X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="733429707" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2024 17:25:04 -0800 From: "Huang, Ying" To: Pierre Gondois Cc: , Shrikanth Hegde , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider Subject: Re: [PATCH v2 1/3] sched/topology: Annotate RCU pointers properly In-Reply-To: <20240115143427.1820628-2-pierre.gondois@arm.com> (Pierre Gondois's message of "Mon, 15 Jan 2024 15:34:24 +0100") References: <20240115143427.1820628-1-pierre.gondois@arm.com> <20240115143427.1820628-2-pierre.gondois@arm.com> Date: Tue, 16 Jan 2024 09:23:07 +0800 Message-ID: <8734uy137o.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Pierre Gondois writes: > Cleanup RCU-related spare errors by annotating RCU pointers. > > sched_domains_numa_distance: > error: incompatible types in comparison expression > (different address spaces): > int [noderef] __rcu * > int * > > sched_domains_numa_masks: > error: incompatible types in comparison expression > (different address spaces): > struct cpumask **[noderef] __rcu * > struct cpumask *** > > The cast to (void *) adds the following sparse warning: > warning: cast removes address space '__rcu' of expression > but this should be normal. > > Fixes: 0fb3978b0aac ("sched/numa: Fix NUMA topology for systems with CPU-less nodes") > Signed-off-by: Pierre Gondois > --- > kernel/sched/topology.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index 10d1391e7416..2a2da9b33e31 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -1542,8 +1542,8 @@ static int sched_domains_numa_levels; > static int sched_domains_curr_level; > > int sched_max_numa_distance; > -static int *sched_domains_numa_distance; > -static struct cpumask ***sched_domains_numa_masks; > +static int __rcu *sched_domains_numa_distance; > +static struct cpumask ** __rcu *sched_domains_numa_masks; > #endif > > /* > @@ -1988,8 +1988,8 @@ void sched_init_numa(int offline_node) > > static void sched_reset_numa(void) > { > - int nr_levels, *distances; > - struct cpumask ***masks; > + int nr_levels, __rcu *distances; > + struct cpumask ** __rcu *masks; No. distances and masks are not accessed via RCU in the function. Instead, they should be assigned like below, distances = rcu_dereference_raw(sched_domains_numa_distance); Because sched_domains_numa_distance is protected by cpu_hotplug_lock, but the lock is static. Some comments are deserved. Anyway, please read RCU document before making the change. https://docs.kernel.org/RCU/index.html > nr_levels = sched_domains_numa_levels; > sched_domains_numa_levels = 0; > @@ -2003,7 +2003,7 @@ static void sched_reset_numa(void) > int i, j; > > synchronize_rcu(); > - kfree(distances); > + kfree((void *)distances); > for (i = 0; i < nr_levels && masks; i++) { > if (!masks[i]) > continue; > @@ -2011,7 +2011,7 @@ static void sched_reset_numa(void) > kfree(masks[i][j]); > kfree(masks[i]); > } > - kfree(masks); > + kfree((void *)masks); > } > if (sched_domain_topology_saved) { > kfree(sched_domain_topology); -- Best Regards, Huang, Ying