Re: [PATCH] 2.5.21 Nonlinear CPU support

Robert Love (rml@tech9.net)
12 Jun 2002 13:54:55 -0700


On Wed, 2002-06-12 at 13:03, H. Peter Anvin wrote:

> while ( 1 ) {
> disable_preemption();
> cpu = current_cpu();
> if ( decompression_buffers[cpu] ) {
> do_decompression(decompression_buffers[cpu]);
> enable_preemption();
> break; /* DONE, EXIT LOOP */
> } else {
> enable_preemption();
> down_sem(allocation_semaphore);
> /* Avoid race condition here */
> if ( !decompression_buffers[cpu] )
> decompression_buffers[cpu] = vmalloc(BUFFER_SIZE);
> up_sem(allocation_semaphore);
> }
> }

Just a note, in 2.5 we recently added put_cpu() and get_cpu() that work
basically like:

int cpu;

cpu = get_cpu();
/* critical non-preemptible section */
put_cpu();

i.e., a preempt-safe interface to smp_processor_id() that disables and
enables preemption for you... makes it a little easier.

Robert Love

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