Re: [RFC] mm: generic adaptive large memory allocation APIs

From: Peter Zijlstra
Date: Fri May 07 2010 - 08:53:07 EST


On Fri, 2010-05-07 at 21:42 +0900, Tetsuo Handa wrote:
> Changli Gao wrote:
> > static void __kvfree(void *ptr, bool inatomic)
>
> inatomic might be confusing because what vfree() checks is
> BUG_ON(in_interrupt()) rather than BUG_ON(in_atomic()).
>
> > {
> > if (unlikely(ZERO_OR_NULL_PTR(ptr)))
> > return;
> > if (is_vmalloc_addr(ptr)) {
> > if (inatomic) {
>
> By the way, is in_interrupt() a heavy operation?
>
> register unsigned long current_stack_pointer asm("esp") __used;
> static inline struct thread_info *current_thread_info(void)
> {
> return (struct thread_info *)
> (current_stack_pointer & ~(THREAD_SIZE - 1));
> }
> #define preempt_count() (current_thread_info()->preempt_count)
> #define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK | NMI_MASK))
> #define in_interrupt() (irq_count())
>
> If we can agree on changing from (inatomic) to (in_interrupt()),
> we can merge kvfree() and kvfree_inatomic().

I really dislike all of that, just don't allow usage from interrupt
context.



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