mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Valentin Schneider <vschneid@redhat.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>,
	 linux-kernel@vger.kernel.org,
	Shrikanth Hegde <sshegde@linux.vnet.ibm.com>,
	 Ingo Molnar <mingo@redhat.com>,
	 Peter Zijlstra <peterz@infradead.org>,
	 Juri Lelli <juri.lelli@redhat.com>,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	 Ben Segall <bsegall@google.com>,  Mel Gorman <mgorman@suse.de>,
	 Daniel Bristot de Oliveira <bristot@redhat.com>
Subject: Re: [PATCH v2 1/3] sched/topology: Annotate RCU pointers properly
Date: Sun, 04 Feb 2024 09:28:06 +0800	[thread overview]
Message-ID: <87il359fx5.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <xhsmhsf2ahiqg.mognet@vschneid-thinkpadt14sgen2i.remote.csb> (Valentin Schneider's message of "Fri, 02 Feb 2024 18:35:35 +0100")

Valentin Schneider <vschneid@redhat.com> writes:

> On 16/01/24 09:23, Huang, Ying wrote:
>> Pierre Gondois <pierre.gondois@arm.com> 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 <pierre.gondois@arm.com>
>>> ---
>>>  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.
>>
>
> IIUC, something like so could also do?
>
>   distances = rcu_dereference_check(sched_domains_numa_distance, lockdep_is_cpus_held());

Yes.  You are right.  We should do that.

--
Best Regards,
Huang, Ying

  reply	other threads:[~2024-02-04  1:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 14:34 [PATCH v2 0/3] Small cleanup around sparse report Pierre Gondois
2024-01-15 14:34 ` [PATCH v2 1/3] sched/topology: Annotate RCU pointers properly Pierre Gondois
2024-01-16  1:23   ` Huang, Ying
2024-02-02 17:35     ` Valentin Schneider
2024-02-04  1:28       ` Huang, Ying [this message]
2024-01-16  3:56   ` kernel test robot
2024-01-15 14:34 ` [PATCH v2 2/3] sched/fair: Use rq in idle_cpu_without() Pierre Gondois
2024-01-15 14:34 ` [PATCH v2 3/3] sched/fair: Use rq in update_blocked_averages() Pierre Gondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il359fx5.fsf@yhuang6-desk2.ccr.corp.intel.com \
    --to=ying.huang@intel.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pierre.gondois@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=sshegde@linux.vnet.ibm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®