Re: Interrupt and spin_lock

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

 



I've applied your modifications but nothing happens.

struct wrprotected_pages *mk_page(unsigned long addr)
{
   struct wrprotected_pages *wr_page;

   wr_page = (struct wrprotected_pages *) kmalloc(sizeof(struct 
                                       wrprotected_pages), GFP_ATOMIC);
   INIT_LIST_HEAD(&wr_page->list);
   wr_page->address = addr;

   return wr_page;
}

struct vm_wrprotected *mk_vm(struct vm_area_struct *vm)
{
   struct vm_wrprotected *wr_vma;

   wr_vma = (struct vm_wrprotected*) kmalloc(sizeof(struct vm_wrprotected), 
                                                                                          GFP_ATOMIC);
   INIT_LIST_HEAD(&wr_vma->pages_list);
   INIT_LIST_HEAD(&wr_vma->list);
   wr_vma->vm_start = vm->vm_start;
   wr_vma->vm_end = vm->vm_end;

   return wr_vma;
}

void set_vm_not_writable(struct mm_struct *mm, struct vm_area_struct *vm)
{
   struct vm_wrprotected *vma;
   struct wrprotected_pages *page;
   unsigned long addr;
   pte_t *pte;

   vma = mk_vm(vm);
   for (addr = vm->vm_start; addr<vm->vm_end; addr+=PAGE_SIZE){
      pte = get_pte_from_address(mm, addr);
      if (pte != NULL)
         if (pte_write(*pte)){
            set_pte(pte, pte_wrprotect(*pte));
            page = mk_page(addr);
            list_add_tail(&page->list, &vma->pages_list);
         }
   }
   list_add_tail(&vma->list, &vm_write_protected);

   return;
}

The last function is called between spinlock.

   spin_lock_irqsave(&protected_lock, flags_lock);
   set_vm_not_writable(mm, vm);
   spin_unlock_irqrestore(&protected_lock, flags_lock);

Now, before I post all lines of code, I want to think about the right use of 
spin_locks in my project.
I've a question on them.
I use spin_lock_irqsave/spin_unlock_irqrestore from outside the page fault 
handler and spin_lock/spin_unlock from within it. What happens if I use
spin_lock_irqsave/spin_unlock_irqrestore also form within the handler?
I've this doubt as the function that scans the lists I've created is the same 
used from within and form outside the handler. How can I resolve this 
conflicting situation? Have I to duplicate this function?

Vincenzo.

		
___________________________________ 
Yahoo! Messenger: chiamate gratuite in tutto il mondo 
http://it.beta.messenger.yahoo.com


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux