免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1392 | 回复: 0
打印 上一主题 下一主题

mm/filemap.c __lock_page() [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-13 13:32 |只看该作者 |倒序浏览



(1) mm/filemap.c  
507 void fastcall __lock_page(struct page *page)
508 {
509         DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
510   
     /*
  struct wait_bit_queue wait =
  {
   .key =
   .wait =
   {
   }
  }
      */
511         __wait_on_bit_lock(page_waitqueue(page), &wait, sync_page,
512                                                         TASK_UNINTERRUPTIBLE);
513 }
514 EXPORT_SYMBOL(__lock_page);

(2) include/linux/wait.h
393 #define DEFINE_WAIT_BIT(name, word, bit)                                \
394         struct wait_bit_queue name = {                                  \
395                 .key = __WAIT_BIT_KEY_INITIALIZER(word, bit),           \
396                 .wait   = {                                             \
397                         .private        = current,                      \
398                         .func           = wake_bit_function,            \
399                         .task_list      =                               \
400                                 LIST_HEAD_INIT((name).wait.task_list),  \
401                 },                                                      \
402         }

(3)kernel/wait.c
179 int __sched fastcall
180 __wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
181                         int (*action)(void *), unsigned mode)
182 {
183         int ret = 0;
184
185         do {
186                 prepare_to_wait_exclusive(wq, &q->wait, mode);
187                 if (test_bit(q->key.bit_nr, q->key.flags)) {
188                         if ((ret = (*action)(q->key.flags)))
189                                 break;
190                 }
191         } while (test_and_set_bit(q->key.bit_nr, q->key.flags));
192         finish_wait(wq, &q->wait);
193         return ret;
194 }
195 EXPORT_SYMBOL(__wait_on_bit_lock);

(4) static int sync_page(void *word)
135 {
136         struct address_space *mapping;
137         struct page *page;
138
139         page = container_of((unsigned long *)word, struct page, flags);
140
162         smp_mb();
163         mapping = page_mapping(page);
164         if (mapping && mapping->a_ops && mapping->a_ops->sync_page)
165                 mapping->a_ops->sync_page(page);
166         io_schedule();
167         return 0;
168 }
逻辑简单,调用mapping->a_ops->sync_page(page),对于ext2就是ext2_aops
->block_sync_page->run_task_queue(&tq_disk)(fs/buffer.c).让磁盘有更多
机会运行回写,读入等任务.这样说不定就不用再等待了.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/17526/showart_1079656.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP