内存映射和DMA

内存映射和DMA

struct page {
 unsigned long flags;  /* Atomic flags, some possibly
      * updated asynchronously */
 atomic_t _count;  /* Usage count, see below. */   //对该页的访问计数,当计数值为0时,给空闲链表。
 union {
  atomic_t _mapcount; /* Count of ptes mapped in mms,
      * to show when page is mapped
      * & limit reverse map searches.
      */
  struct {  /* SLUB */
   u16 inuse;
   u16 objects;
  };
 };
 union {
     struct {
  unsigned long private;  /* Mapping-private opaque data:
        * usually used for buffer_heads
       * if PagePrivate set; used for
       * swp_entry_t if PageSwapCache;
       * indicates order in the buddy
       * system if PG_buddy is set.
       */
  struct address_space *mapping; /* If low bit clear, points to
       * inode address_space, or NULL.
       * If page mapped as anonymous
       * memory, low bit is set, and
       * it points to anon_vma object:
       * see PAGE_MAPPING_ANON below.
       */
     };
#if USE_SPLIT_PTLOCKS
     spinlock_t ptl;
#endif
     struct kmem_cache *slab; /* SLUB: Pointer to slab */
     struct page *first_page; /* Compound tail pages */
 };
 union {
  pgoff_t index;  /* Our offset within mapping. */
  void *freelist;  /* SLUB: freelist req. slab lock */
 };
 struct list_head lru;  /* Pageout list, eg. active_list
      * protected by zone->lru_lock !
      */
 /*
  * On machines where all RAM is mapped into kernel address space,
  * we can simply calculate the virtual address. On machines with
  * highmem some memory is mapped into kernel virtual memory
  * dynamically, so we need a place to store that address.
  * Note that this field could be 16 bits on x86 ... ;)
  *
  * Architectures with slow multiplication can define
  * WANT_PAGE_VIRTUAL in asm/page.h
  */
#if defined(WANT_PAGE_VIRTUAL)
 void *virtual;   /* Kernel virtual address (NULL if    //若页面被映射,则指向页的内核虚拟地址。否则为NULL
        not kmapped, ie. highmem) */
#endif /* WANT_PAGE_VIRTUAL */
};

struct page结构是对内核中物理页的抽象,用来保存内核需要知道的所有物理内存信息。
kmalloc返回的内存是内核逻辑地址。

vmalloc分配的是逻辑上连续,物理上不一定连续的地址,这是典型的内核虚拟地址范围大于逻辑地址的例子。

kmap也是为系统中的页返回内核虚拟地址。

页框:物理内存上的一个数据块,通常为4KB或8KB。

页表:将虚拟地址转换为相应的物理地址的一种机制。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值