direct-io.hg

changeset 349:15ffd7ee35df

bitkeeper revision 1.160.1.2 (3e8ca5d6NuIwQ-85rqA_rDQ3WcxL2A)

mm.h, xen_block.c, memory.c:
Changed the page-typing fix around; it at least _looks_ a bit more generic now :-)
author kaf24@scramble.cl.cam.ac.uk
date Thu Apr 03 21:21:26 2003 +0000 (2003-04-03)
parents e5e04893c022
children 4fd13119bcc6
files xen/common/memory.c xen/drivers/block/xen_block.c xen/include/xeno/mm.h
line diff
     1.1 --- a/xen/common/memory.c	Thu Apr 03 18:58:55 2003 +0000
     1.2 +++ b/xen/common/memory.c	Thu Apr 03 21:21:26 2003 +0000
     1.3 @@ -441,7 +441,7 @@ static int get_page(unsigned long page_n
     1.4              page->flags &= ~PG_type_mask;
     1.5              page->flags |= PGT_writeable_page;
     1.6          }
     1.7 -        page->flags &= ~PG_noflush;
     1.8 +        page->flags |= PG_need_flush;
     1.9          get_page_type(page);
    1.10      }
    1.11  
    1.12 @@ -500,9 +500,13 @@ static void put_page(unsigned long page_
    1.13      ASSERT(DOMAIN_OKAY(page->flags));
    1.14      ASSERT((!writeable) || 
    1.15             ((page_type_count(page) != 0) && 
    1.16 -            ((page->flags & PG_type_mask) == PGT_writeable_page)));
    1.17 +            ((page->flags & PG_type_mask) == PGT_writeable_page) &&
    1.18 +            ((page->flags & PG_need_flush) == PG_need_flush)));
    1.19      if ( writeable && (put_page_type(page) == 0) )
    1.20 +    {
    1.21          tlb_flush[smp_processor_id()] = 1;
    1.22 +        page->flags &= ~PG_need_flush;
    1.23 +    }
    1.24      put_page_tot(page);
    1.25  }
    1.26  
     2.1 --- a/xen/drivers/block/xen_block.c	Thu Apr 03 18:58:55 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_block.c	Thu Apr 03 21:21:26 2003 +0000
     2.3 @@ -306,9 +306,9 @@ static void __lock_buffer(unsigned long 
     2.4          {
     2.5              if ( page->type_count == 0 )
     2.6              {
     2.7 -                page->flags &= ~PG_type_mask;
     2.8 +                page->flags &= ~(PG_type_mask | PG_need_flush);
     2.9                  /* NB. This ref alone won't cause a TLB flush. */
    2.10 -                page->flags |= PGT_writeable_page | PG_noflush;
    2.11 +                page->flags |= PGT_writeable_page;
    2.12              }
    2.13              get_page_type(page);
    2.14          }
    2.15 @@ -332,11 +332,11 @@ static void unlock_buffer(struct task_st
    2.16          page = frame_table + pfn;
    2.17          if ( writeable_buffer &&
    2.18               (put_page_type(page) == 0) &&
    2.19 -             !(page->flags & PG_noflush) )
    2.20 +             (page->flags & PG_need_flush) )
    2.21          {
    2.22              __flush_tlb();
    2.23 +            page->flags &= ~PG_need_flush;
    2.24          }
    2.25 -        page->flags &= ~PG_noflush;
    2.26          put_page_tot(page);
    2.27      }
    2.28      spin_unlock_irqrestore(&p->page_lock, flags);
     3.1 --- a/xen/include/xeno/mm.h	Thu Apr 03 18:58:55 2003 +0000
     3.2 +++ b/xen/include/xeno/mm.h	Thu Apr 03 21:21:26 2003 +0000
     3.3 @@ -98,17 +98,17 @@ typedef struct pfn_info {
     3.4  #define PGT_net_rx_buf      (8<<24) /* this page has been pirated by the net code. */
     3.5  
     3.6  /*
     3.7 - * This bit is sometimes set by Xen when it holds a writeable reference to a 
     3.8 - * page that shouldn't cause a TLB flush when it is dropped. For example, a 
     3.9 - * disk write to a page with initial type_count == 0, which returns to 0 after 
    3.10 - * the I/O. In this case, we'd normally flush the TLB because a writeable page 
    3.11 - * has just lost its mutually-exclusive type. But this isn't necessary here 
    3.12 - * because the writeable reference never made it into user-accessible TLB 
    3.13 - * (didn't make it into TLB at all, in fact).
    3.14 + * This bit indicates that the TLB must be flushed when the type count of this
    3.15 + * frame drops to zero. This is needed on current x86 processors only for
    3.16 + * frames which have guestos-accessible writeable mappings. In this case we must 
    3.17 + * prevent stale TLB entries allowing the frame to be written if it used for a
    3.18 + * page table, for example.
    3.19   * 
    3.20 - * This bit is obviously nuked in a few places, for safety.
    3.21 + * We have this bit because the writeable type is actually also used to pin a page
    3.22 + * when it is used as a disk read buffer. This doesn't require a TLB flush because
    3.23 + * the frame never has a mapping in the TLB.
    3.24   */
    3.25 -#define PG_noflush          (1<<28)
    3.26 +#define PG_need_flush       (1<<28)
    3.27  
    3.28  #define PageSlab(page)		test_bit(PG_slab, &(page)->flags)
    3.29  #define PageSetSlab(page)	set_bit(PG_slab, &(page)->flags)