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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux