On Fri, Jan 23, 2009 at 11:07:06PM -0800, Andrew Morton wrote:
>
> > +int cryptd_enqueue_request(struct cryptd_queue *queue,
> > +                      struct crypto_async_request *request)
> > +{
> > +   int cpu, err, queued;
> > +   struct cryptd_cpu_queue *cpu_queue;
> > +
> > +   cpu = get_cpu();
> > +   cpu_queue = per_cpu_ptr(queue->cpu_queue, cpu);
> > +   spin_lock_bh(&cpu_queue->lock);
> > +   err = crypto_enqueue_request(&cpu_queue->queue, request);
> > +   spin_unlock_bh(&cpu_queue->lock);
> > +   /* INUSE should be set after queue->qlen assigned, but
> > +    * spin_unlock_bh imply a memory barrior already */
> > +   if (!test_and_set_bit_lock(CRYPTD_STATE_INUSE, &cpu_queue->state)) {
> > +           queued = queue_work(kcrypto_wq, &cpu_queue->work);
> > +           BUG_ON(!queued);
> > +   }
> 
> Do we actually need to use CRYPTD_STATE_INUSE here?  The
> WORK_STRUCT_PENDING handling in the workqueue does basically the same
> thing?

Indeed, the INUSE stuff looks vestigial and can probably be removed.
 
> > +{
> > +   int cpu, in_queue;
> > +   struct cryptd_cpu_queue *cpu_queue;
> > +
> > +   for_each_possible_cpu(cpu) {
> > +           cpu_queue = per_cpu_ptr(queue->cpu_queue, cpu);
> > +           spin_lock_bh(&cpu_queue->lock);
> > +           in_queue = crypto_tfm_in_queue(&cpu_queue->queue, tfm);
> > +           spin_unlock_bh(&cpu_queue->lock);
> > +           if (in_queue)
> > +                   return 1;
> > +   }
> > +   return 0;
> > +}
> 
> Did you consider using for_each_online_cpu() and implementing CPU
> hotplug?  There might be situations where the number of possible CPUs
> is much greater than the number of online CPUs.

This is one of those things that just keeps changing. Once upon a
time I'd write code with CPU hotplug triggers and such and someone
would always come through to change them to for_each_possible_cpu
in the name of simplification :)

But yeah I personally still prefer the hotplug way, so no objections
from me.

Thanks for reviewing Andrew!
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to