linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	linux-next@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH] cpumask:cpumask_of_node-ia64 fix
Date: Wed, 10 Dec 2008 20:31:42 -0800	[thread overview]
Message-ID: <494097AE.8020107@sgi.com> (raw)
In-Reply-To: <494093F7.5020000@sgi.com>

Mike Travis wrote:
> KOSAKI Motohiro wrote:
>> ===
>> Subject: [PATCH] cpumask:cpumask_of_node-ia64 fix
>> Impact: bug fix
>>
>> commit 07c636deede53ff3e96d54df0ece2c838e61951f introduce new CPU mask API and change cpu_mask variable type.
>>
>> -----------------------------------------------
>> -               cpumask_t cpu_mask;
>> +               const struct cpumask *cpu_mask;
>> --------------------------------------------------
>>
>>
>> However, its change is incomplete. in build time, compiler output following type mismatch warnings.
>>
>>   arch/ia64/kernel/iosapic.c:708: warning: passing argument 2 of '__cpu_clear' from incompatible pointer type
>>   arch/ia64/kernel/iosapic.c:711: warning: passing argument 1 of '__cpus_weight' from incompatible pointer type
>>   arch/ia64/kernel/iosapic.c:719: warning: passing argument 1 of '__first_cpu' from incompatible pointer type
>>   arch/ia64/kernel/iosapic.c:720: warning: passing argument 2 of '__next_cpu' from incompatible pointer type
> 
> Good catch, however ...
>>
>> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>> CC: "Luck, Tony" <tony.luck@intel.com>
>> CC: Rusty Russell <rusty@rustcorp.com.au>
>> ---
>>  arch/ia64/kernel/iosapic.c |   10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> Index: b/arch/ia64/kernel/iosapic.c
>> ===================================================================
>> --- a/arch/ia64/kernel/iosapic.c
>> +++ b/arch/ia64/kernel/iosapic.c
>> @@ -695,7 +695,7 @@ get_target_cpu (unsigned int gsi, int ir
>>  #ifdef CONFIG_NUMA
>>  	{
>>  		int num_cpus, cpu_index, iosapic_index, numa_cpu, i = 0;
>> -		const struct cpumask *cpu_mask;
>> +		struct cpumask *cpu_mask;
>>  
>>  		iosapic_index = find_iosapic(gsi);
>>  		if (iosapic_index < 0 ||
>> @@ -705,10 +705,10 @@ get_target_cpu (unsigned int gsi, int ir
>>  		cpu_mask = cpumask_of_node(iosapic_lists[iosapic_index].node);
>>  		for_each_cpu_and(numa_cpu, cpu_mask, &domain) {
>>  			if (!cpu_online(numa_cpu))
>> -				cpu_clear(numa_cpu, cpu_mask);
>> +				cpu_clear(numa_cpu, *cpu_mask);
> 
> ... you cannot modify the read-only cpumask_of_node map.  Suggested alternative below.
> 
>>  		}
>>  
>> -		num_cpus = cpus_weight(cpu_mask);
>> +		num_cpus = cpus_weight(*cpu_mask);
>>  
>>  		if (!num_cpus)
>>  			goto skip_numa_setup;
>> @@ -716,8 +716,8 @@ get_target_cpu (unsigned int gsi, int ir
>>  		/* Use irq assignment to distribute across cpus in node */
>>  		cpu_index = irq % num_cpus;
>>  
>> -		for (numa_cpu = first_cpu(cpu_mask) ; i < cpu_index ; i++)
>> -			numa_cpu = next_cpu(numa_cpu, cpu_mask);
>> +		for (numa_cpu = first_cpu(*cpu_mask) ; i < cpu_index ; i++)
>> +			numa_cpu = next_cpu(numa_cpu, *cpu_mask);
>>  
>>  		if (numa_cpu != NR_CPUS)
>>  			return cpu_physical_id(numa_cpu);
>>
>>
>> --
> ---
>  arch/ia64/kernel/iosapic.c |   16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> --- linux-2.6-next.orig/arch/ia64/kernel/iosapic.c
> +++ linux-2.6-next/arch/ia64/kernel/iosapic.c
> @@ -703,23 +703,23 @@ get_target_cpu (unsigned int gsi, int ir
>  			goto skip_numa_setup;
>  
>  		cpu_mask = cpumask_of_node(iosapic_lists[iosapic_index].node);
> +		num_cpus = 0;
>  		for_each_cpu_and(numa_cpu, cpu_mask, &domain) {
> -			if (!cpu_online(numa_cpu))
> -				cpu_clear(numa_cpu, cpu_mask);
> +			if (cpu_online(numa_cpu))
> +				num_cpus++;
>  		}
>  
> -		num_cpus = cpus_weight(cpu_mask);
> -
>  		if (!num_cpus)
>  			goto skip_numa_setup;
>  
>  		/* Use irq assignment to distribute across cpus in node */
>  		cpu_index = irq % num_cpus;
>  
> -		for (numa_cpu = first_cpu(cpu_mask) ; i < cpu_index ; i++)
> -			numa_cpu = next_cpu(numa_cpu, cpu_mask);
> +		for_each_cpu_and(numa_cpu, cpu_mask, cpu_online_mask)
> +			if (i++ >= cpu_index)
> +				break;

Oops, looks like I over-simplified the above...

		for_each_cpu_and(numa_cpu, cpu_mask, &domain)
			if (cpu_online(numa_cpu) && i++ >= cpu_index)
				break;
	
>  
> -		if (numa_cpu != NR_CPUS)
> +		if (numa_cpu < nr_cpu_ids)
>  			return cpu_physical_id(numa_cpu);
>  	}
>  skip_numa_setup:
> @@ -730,7 +730,7 @@ skip_numa_setup:
>  	 * case of NUMA.)
>  	 */
>  	do {
> -		if (++cpu >= NR_CPUS)
> +		if (++cpu >= nr_cpu_ids)
>  			cpu = 0;
>  	} while (!cpu_online(cpu) || !cpu_isset(cpu, domain));
>  
> ---
> 
> One aside, I'm not sure of ia64, but x86_64 keeps only online cpus in the cpumask_of_node_map.
> IOW, if a cpu goes offline, it's removed from the map.  So the whole and'ing thing above may
> be unnecessary. 

  reply	other threads:[~2008-12-11  4:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10  5:46 linux-next: Tree for December 10 Stephen Rothwell
2008-12-10  9:36 ` KOSAKI Motohiro
2008-12-10 12:05   ` [bug?] bio: add experimental support for inlining a number of bio_vecs inside the bio KOSAKI Motohiro
2008-12-10 12:12     ` Jens Axboe
2008-12-10 21:13       ` Andrew Morton
2008-12-11  7:32         ` Jens Axboe
2008-12-11  0:39       ` KOSAKI Motohiro
2008-12-10  9:39 ` linux-next: Tree for December 10 KOSAKI Motohiro
2008-12-10 11:21   ` KOSAKI Motohiro
2008-12-10 11:17 ` [BUILD-FAILURE] linux-next: next-20081210 - s390x - lcs drivers breaks with !CONFIG_IP_MULTICAST Kamalesh Babulal
2008-12-10 12:08   ` Heiko Carstens
2008-12-10 16:31     ` Kamalesh Babulal
2008-12-10 22:52 ` linux-next: Tree for December 10 Andrew Morton
2008-12-10 23:53   ` Rafael J. Wysocki
2008-12-11  0:38     ` Andrew Morton
2008-12-11  1:15 ` mpt fusion device warning 5 times KOSAKI Motohiro
2008-12-11  1:58 ` [PATCH] cpumask:cpumask_of_node-ia64 fix KOSAKI Motohiro
2008-12-11  4:09   ` [linux-next][PATCH] " KOSAKI Motohiro
2008-12-11  4:15   ` [PATCH] " Mike Travis
2008-12-11  4:31     ` Mike Travis [this message]
2008-12-11  4:53     ` KOSAKI Motohiro
2008-12-12  8:11       ` Rusty Russell

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=494097AE.8020107@sgi.com \
    --to=travis@sgi.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sfr@canb.auug.org.au \
    --cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).