lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87twy3j7fo.fsf@rustcorp.com.au>
Date:	Tue, 03 Mar 2015 10:09:07 +1030
From:	Rusty Russell <rusty@...tcorp.com.au>
To:	Oleg Drokin <green@...uxhacker.ru>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 05/16] staging/lustre: fix up obsolete cpu function usage.

Oleg Drokin <green@...uxhacker.ru> writes:
> Thanks!
> Seems there was a midair collsion with my own patch that was not as comprehensive
> wrt functions touched: https://lkml.org/lkml/2015/3/2/10

Yep, I posted this for completeness (and for your reference), but
figured you'd handle it.

> But on the other hand I also tried to clean up
> some of the NR_CPUS usage while I was at it and this raises 
> this question, from me, in the code like:
>
> for_each_cpu_mask(i, blah) {
>     blah
>     if (something)
>         break;
> }
> if (i == NR_CPUS)
>     blah;
>
> when we are replacing for_each_cpu_mask with for_each_cpu,
> what do we check the counter against now to see that the entire loop was executed
> and we did not exit prematurely? nr_cpu_ids?

You want >= nr_cpu_ids here.

> Also I assume we still want to get rid of direct cpumask assignments like
>> mask = *cpumask_of_node(cpu_to_node(index));

Yes, but this code is wrong anyway:

		mask = *cpumask_of_node(cpu_to_node(index));
		for (i = max; i < num_online_cpus(); i++)
			cpumask_clear_cpu(i, &mask);

*Never* iterate to num_online_cpus().  eg. if cpus 0 and 3 are online,
num_online_cpus() == 2.  I'm not sure what this code is doing, but it's
not doing it well :)

There are several issues here.  You need to handle cpus going offline
(during this routine, as well as after).  You need to use a
cpumask_var_t, like so:

        cpumask_var_t mask;

...
	case PDB_POLICY_NEIGHBOR:
                if (!alloc_cpumask_var(&mask, GFP_???)) {
                        rc = -ENOMEM;
                        break;
                }
                ...

Or get rid of the mask altogether, eg:

        pc->pc_npartners = -1;
        for_each_cpu(i, cpu_online_mask) {
                if (i < max)
                        pc->pc_npartners++;
        }
        ...

	pidx = 0;
        for_each_cpu(i, cpu_online_mask) {
                if (i >= max)
                        break;
		ppc = &ptlrpcds->pd_threads[i];
		pc->pc_partners[pidx++] = ppc;
		ppc->pc_partners[ppc->pc_npartners++] = pc;
        }

[ This is off the top of my head, no idea if it's right...]

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ