[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201005072142.IIC30776.FFtOOHMOVFJLQS@I-love.SAKURA.ne.jp>
Date: Fri, 7 May 2010 21:42:14 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: xiaosuo@...il.com, akpm@...ux-foundation.org
Cc: eric.dumazet@...il.com, jslaby@...e.cz, viro@...iv.linux.org.uk,
paulmck@...ux.vnet.ibm.com, adobriyan@...il.com, mingo@...e.hu,
peterz@...radead.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, avi@...hat.com
Subject: Re: [RFC] mm: generic adaptive large memory allocation APIs
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().
> struct work_struct *work;
>
> work = ptr;
> BUILD_BUG_ON(sizeof(struct work_struct) > PAGE_SIZE);
> INIT_WORK(work, kvfree_work);
> schedule_work(work);
> } else {
> vfree(ptr);
> }
> } else {
> struct page *page;
>
> page = virt_to_head_page(ptr);
> if (PageSlab(page) || PageCompound(page))
> kfree(ptr);
> else
> free_pages_exact(ptr, page->private);
> }
> }
--
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