Re: [PATCH] 2.5.21 Nonlinear CPU support

From: Robert Love (rml@tech9.net)
Date: Wed Jun 12 2002 - 15:54:55 EST


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/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:26 EST