ia64/xen-unstable

changeset 189:dbf8bc3ff290

bitkeeper revision 1.51 (3e4f67279oV-bmkkWw6EtRDc-swzow)

time.c, dom0_core.c, defconfig, dev.c, domain.c:
Minor cleanups.
author kaf24@labyrinth.cl.cam.ac.uk
date Sun Feb 16 10:25:43 2003 +0000 (2003-02-16)
parents 27c9e1a4e843
children 74a183b3173d
files xen-2.4.16/arch/i386/time.c xen-2.4.16/common/domain.c xen-2.4.16/net/dev.c xenolinux-2.4.16-sparse/arch/xeno/defconfig xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c
line diff
     1.1 --- a/xen-2.4.16/arch/i386/time.c	Sun Feb 16 10:00:03 2003 +0000
     1.2 +++ b/xen-2.4.16/arch/i386/time.c	Sun Feb 16 10:25:43 2003 +0000
     1.3 @@ -182,8 +182,8 @@ mktime (unsigned int year, unsigned int 
     1.4  	}
     1.5  	return ((((unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day)+
     1.6  			  year*365 - 719499
     1.7 -				 )*24 + hour /* now have hours */
     1.8 -				)*60 + min /* now have minutes */
     1.9 +        )*24 + hour /* now have hours */
    1.10 +        )*60 + min /* now have minutes */
    1.11          )*60 + sec; /* finally seconds */
    1.12  }
    1.13  
    1.14 @@ -214,14 +214,14 @@ static unsigned long get_cmos_time(void)
    1.15  		year = CMOS_READ(RTC_YEAR);
    1.16  	} while (sec != CMOS_READ(RTC_SECONDS));
    1.17  	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
    1.18 -	  {
    1.19 +    {
    1.20  	    BCD_TO_BIN(sec);
    1.21  	    BCD_TO_BIN(min);
    1.22  	    BCD_TO_BIN(hour);
    1.23  	    BCD_TO_BIN(day);
    1.24  	    BCD_TO_BIN(mon);
    1.25  	    BCD_TO_BIN(year);
    1.26 -	  }
    1.27 +    }
    1.28  	spin_unlock(&rtc_lock);
    1.29  	if ((year += 1900) < 1970)
    1.30  		year += 100;
    1.31 @@ -337,16 +337,15 @@ static void update_time(unsigned long fo
    1.32  	new_st = NOW();
    1.33  	rdtscl(new_pcc);
    1.34  
    1.35 -	/* update system time  */
    1.36 +	/* Update system time. */
    1.37  	spin_lock_irqsave(&stime_lock, flags);
    1.38 -
    1.39  	stime_now = new_st;
    1.40  	stime_pcc=new_pcc;
    1.41 -
    1.42 -	spin_unlock_irqrestore(&stime_lock, flags);
    1.43 +    /* Don't reeenable IRQs until we release wctime_lock. */
    1.44 +	spin_unlock(&stime_lock);
    1.45  
    1.46 -	/* update wall clock time  */
    1.47 -	spin_lock_irqsave(&wctime_lock, flags);
    1.48 +	/* Update wall clock time. */
    1.49 +	spin_lock(&wctime_lock);
    1.50  	usec = ((unsigned long)(new_st - wctime_st))/1000;
    1.51  	usec += wall_clock_time.tv_usec;
    1.52  	while (usec >= 1000000) {
    1.53 @@ -360,7 +359,8 @@ static void update_time(unsigned long fo
    1.54  	TRC(printk("TIME[%02d] update time: stime_now=%lld now=%lld,wct=%ld:%ld\n",
    1.55  			   smp_processor_id(), stime_now, new_st, wall_clock_time.tv_sec,
    1.56  			   wall_clock_time.tv_usec));
    1.57 -	/* reload timer */
    1.58 +
    1.59 +	/* Reload the timer. */
    1.60   again:
    1.61  	update_timer.expires  = new_st + MILLISECS(200);
    1.62  	if(add_ac_timer(&update_timer) == 1) {
     2.1 --- a/xen-2.4.16/common/domain.c	Sun Feb 16 10:00:03 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Sun Feb 16 10:25:43 2003 +0000
     2.3 @@ -137,39 +137,6 @@ long kill_other_domain(unsigned int dom)
     2.4  }
     2.5  
     2.6  
     2.7 -/* Release resources belonging to task @p. */
     2.8 -void release_task(struct task_struct *p)
     2.9 -{
    2.10 -    struct list_head *list_ent, *tmp;
    2.11 -    ASSERT(p->state == TASK_DYING);
    2.12 -    ASSERT(!p->has_cpu);
    2.13 -    write_lock_irq(&tasklist_lock);
    2.14 -    REMOVE_LINKS(p);
    2.15 -    write_unlock_irq(&tasklist_lock);
    2.16 -
    2.17 -    /*
    2.18 -     * Safe! Only queue skbuffs with tasklist_lock held.
    2.19 -     * Only access shared_info with tasklist_lock held.
    2.20 -     * And free_task_struct() only releases if refcnt == 0.
    2.21 -     */
    2.22 -    while ( p->num_net_vifs )
    2.23 -    {
    2.24 -        destroy_net_vif(p);
    2.25 -    }
    2.26 -    if ( p->mm.perdomain_pt ) free_page((unsigned long)p->mm.perdomain_pt);
    2.27 -    free_page((unsigned long)p->shared_info);
    2.28 -
    2.29 -    list_for_each_safe(list_ent, tmp, &p->pg_head)
    2.30 -    {
    2.31 -        struct pfn_info *pf = list_entry(list_ent, struct pfn_info, list);
    2.32 -        pf->type_count = pf->tot_count = pf->flags = 0;
    2.33 -        list_del(list_ent);
    2.34 -        list_add(list_ent, &free_list);
    2.35 -    }
    2.36 -
    2.37 -    free_task_struct(p);
    2.38 -}
    2.39 -
    2.40  unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes)
    2.41  {
    2.42      struct list_head *temp;
    2.43 @@ -206,6 +173,83 @@ unsigned int alloc_new_dom_mem(struct ta
    2.44      return 0;
    2.45  }
    2.46   
    2.47 +
    2.48 +void free_all_dom_mem(struct task_struct *p)
    2.49 +{
    2.50 +    struct list_head *list_ent, *tmp;
    2.51 +
    2.52 +    list_for_each_safe(list_ent, tmp, &p->pg_head)
    2.53 +    {
    2.54 +        struct pfn_info *pf = list_entry(list_ent, struct pfn_info, list);
    2.55 +        pf->type_count = pf->tot_count = pf->flags = 0;
    2.56 +        list_del(list_ent);
    2.57 +        list_add(list_ent, &free_list);
    2.58 +    }
    2.59 +
    2.60 +    p->tot_pages = 0;
    2.61 +}
    2.62 +
    2.63 +
    2.64 +/* Release resources belonging to task @p. */
    2.65 +void release_task(struct task_struct *p)
    2.66 +{
    2.67 +    ASSERT(p->state == TASK_DYING);
    2.68 +    ASSERT(!p->has_cpu);
    2.69 +    write_lock_irq(&tasklist_lock);
    2.70 +    REMOVE_LINKS(p);
    2.71 +    write_unlock_irq(&tasklist_lock);
    2.72 +
    2.73 +    /*
    2.74 +     * Safe! Only queue skbuffs with tasklist_lock held.
    2.75 +     * Only access shared_info with tasklist_lock held.
    2.76 +     * And free_task_struct() only releases if refcnt == 0.
    2.77 +     */
    2.78 +    while ( p->num_net_vifs )
    2.79 +    {
    2.80 +        destroy_net_vif(p);
    2.81 +    }
    2.82 +    if ( p->mm.perdomain_pt ) free_page((unsigned long)p->mm.perdomain_pt);
    2.83 +    free_page((unsigned long)p->shared_info);
    2.84 +
    2.85 +    free_all_dom_mem(p);
    2.86 +
    2.87 +    free_task_struct(p);
    2.88 +}
    2.89 +
    2.90 +
    2.91 +void construct_cmdline(char *dst, struct task_struct *p)
    2.92 +{
    2.93 +    int dom = p->domain;
    2.94 +    unsigned char boot[150];
    2.95 +    unsigned char ipbase[20], nfsserv[20], gateway[20], netmask[20];
    2.96 +    unsigned char nfsroot[70];
    2.97 +
    2.98 +    if ( strcmp("",opt_nfsroot) )
    2.99 +    {
   2.100 +        /* NFS root for Xenolinux. */
   2.101 +        snprintf(nfsroot, 70, opt_nfsroot, dom); 
   2.102 +        snprintf(boot, 200,
   2.103 +                " root=/dev/nfs ip=%s:%s:%s:%s::eth0:off nfsroot=%s",
   2.104 +                 quad_to_str(opt_ipbase + dom, ipbase),
   2.105 +                 quad_to_str(opt_nfsserv, nfsserv),
   2.106 +                 quad_to_str(opt_gateway, gateway),
   2.107 +                 quad_to_str(opt_netmask, netmask),
   2.108 +                 nfsroot);
   2.109 +    }
   2.110 +    else
   2.111 +    {   
   2.112 +        /* Non-NFS root for Xenolinux. */
   2.113 +        snprintf(boot, 200,
   2.114 +                " ip=%s::%s:%s::eth0:off",
   2.115 +                 quad_to_str(opt_ipbase + dom, ipbase),
   2.116 +                 quad_to_str(opt_gateway, gateway),
   2.117 +                 quad_to_str(opt_netmask, netmask));
   2.118 +    }
   2.119 +
   2.120 +    strcpy(dst, boot);
   2.121 +}
   2.122 +
   2.123 +
   2.124  /* final_setup_guestos is used for final setup and launching of domains other
   2.125   * than domain 0. ie. the domains that are being built by the userspace dom0
   2.126   * domain builder.
   2.127 @@ -311,21 +355,7 @@ int final_setup_guestos(struct task_stru
   2.128      }
   2.129      *dst = '\0';
   2.130  
   2.131 -    if ( opt_nfsroot )
   2.132 -    {
   2.133 -        unsigned char boot[150];
   2.134 -        unsigned char ipbase[20], nfsserv[20], gateway[20], netmask[20];
   2.135 -        unsigned char nfsroot[70];
   2.136 -        snprintf(nfsroot, 70, opt_nfsroot, p->domain); 
   2.137 -        snprintf(boot, 200,
   2.138 -                " root=/dev/nfs ip=%s:%s:%s:%s::eth0:off nfsroot=%s",
   2.139 -                 quad_to_str(opt_ipbase + p->domain, ipbase),
   2.140 -                 quad_to_str(opt_nfsserv, nfsserv),
   2.141 -                 quad_to_str(opt_gateway, gateway),
   2.142 -                 quad_to_str(opt_netmask, netmask),
   2.143 -                 nfsroot);
   2.144 -        strcpy(dst, boot);
   2.145 -    }
   2.146 +    construct_cmdline(dst, p);
   2.147  
   2.148      /* Reinstate the caller's page tables. */
   2.149      __asm__ __volatile__ (
   2.150 @@ -404,7 +434,7 @@ int setup_guestos(struct task_struct *p,
   2.151                 dom, (mod[nr_mods-1].mod_end-mod[0].mod_start)>>20,
   2.152                 (params->memory_kb)>>11,
   2.153                 (params->memory_kb)>>10);
   2.154 -        /* XXX should free domain memory here XXX */
   2.155 +        free_all_dom_mem(p);
   2.156          return -1;
   2.157      }
   2.158  
   2.159 @@ -578,34 +608,8 @@ int setup_guestos(struct task_struct *p,
   2.160          }
   2.161      }
   2.162      *dst = '\0';
   2.163 -//printk("opt_nfsroot=%d,%s XX cmd =: %s\n",opt_nfsroot,opt_nfsroot,virt_startinfo_address->cmd_line);
   2.164  
   2.165 -    if ( strcmp("",opt_nfsroot) )
   2.166 -    {   // if nfsroot has been set to something
   2.167 -        unsigned char boot[150];
   2.168 -        unsigned char ipbase[20], nfsserv[20], gateway[20], netmask[20];
   2.169 -        unsigned char nfsroot[70];
   2.170 -        snprintf(nfsroot, 70, opt_nfsroot, dom); 
   2.171 -        snprintf(boot, 200,
   2.172 -                " root=/dev/nfs ip=%s:%s:%s:%s::eth0:off nfsroot=%s",
   2.173 -                 quad_to_str(opt_ipbase + dom, ipbase),
   2.174 -                 quad_to_str(opt_nfsserv, nfsserv),
   2.175 -                 quad_to_str(opt_gateway, gateway),
   2.176 -                 quad_to_str(opt_netmask, netmask),
   2.177 -                 nfsroot);
   2.178 -        strcpy(dst, boot);
   2.179 -    }
   2.180 -    else
   2.181 -    {   
   2.182 -        unsigned char boot[150];
   2.183 -        unsigned char ipbase[20], nfsserv[20], gateway[20], netmask[20];
   2.184 -        snprintf(boot, 200,
   2.185 -                " ip=%s::%s:%s::eth0:off",
   2.186 -                 quad_to_str(opt_ipbase + dom, ipbase),
   2.187 -                 quad_to_str(opt_gateway, gateway),
   2.188 -                 quad_to_str(opt_netmask, netmask));
   2.189 -        strcpy(dst, boot);
   2.190 -    }
   2.191 +    construct_cmdline(dst, p);
   2.192  
   2.193  
   2.194      /* Reinstate the caller's page tables. */
     3.1 --- a/xen-2.4.16/net/dev.c	Sun Feb 16 10:00:03 2003 +0000
     3.2 +++ b/xen-2.4.16/net/dev.c	Sun Feb 16 10:25:43 2003 +0000
     3.3 @@ -40,7 +40,7 @@
     3.4  #define rtnl_unlock() ((void)0)
     3.5  #define dst_init() ((void)0)
     3.6  
     3.7 -#if 1
     3.8 +#if 0
     3.9  #define DPRINTK(_f, _a...) printk(_f , ## _a)
    3.10  #else 
    3.11  #define DPRINTK(_f, _a...) ((void)0)
     4.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/defconfig	Sun Feb 16 10:00:03 2003 +0000
     4.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/defconfig	Sun Feb 16 10:25:43 2003 +0000
     4.3 @@ -113,7 +113,7 @@ CONFIG_BLK_DEV_LOOP=y
     4.4  CONFIG_BLK_DEV_NBD=y
     4.5  CONFIG_BLK_DEV_RAM=y
     4.6  CONFIG_BLK_DEV_RAM_SIZE=4096
     4.7 -CONFIG_BLK_DEV_INITRD=y
     4.8 +# CONFIG_BLK_DEV_INITRD is not set
     4.9  CONFIG_XENOLINUX_BLOCK=y
    4.10  
    4.11  #
     5.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Sun Feb 16 10:00:03 2003 +0000
     5.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Sun Feb 16 10:25:43 2003 +0000
     5.3 @@ -212,11 +212,8 @@ static int cmd_write_proc(struct file *f
     5.4      }
     5.5      else if ( op.cmd == DO_PGUPDATES )
     5.6      {
     5.7 -        p = op.u.pgupdate.pgt_update_arr;
     5.8 -        for ( i = 0; i < op.u.pgupdate.num_pgt_updates; i++ )
     5.9 -        {
    5.10 -            ret = HYPERVISOR_pt_update(p + i*8, 1);
    5.11 -        }
    5.12 +        ret = HYPERVISOR_pt_update(op.u.pgupdate.pgt_update_arr,
    5.13 +                                   op.u.pgupdate.num_pgt_updates);
    5.14      }
    5.15      else
    5.16      {
     6.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Sun Feb 16 10:00:03 2003 +0000
     6.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Sun Feb 16 10:25:43 2003 +0000
     6.3 @@ -241,11 +241,11 @@ static inline void do_timer_interrupt(in
     6.4  {
     6.5  	struct timeval tv;
     6.6  	long long time, delta;
     6.7 -
     6.8 +	
     6.9  #ifdef XENO_TIME_DEBUG
    6.10  	static u32 foo_count = 0;
    6.11  	foo_count++;		
    6.12 -	if (foo_count>= 10000) {
    6.13 +	if (foo_count>= 1000) {
    6.14  		s64 n = NOW();
    6.15  		struct timeval tv;
    6.16  		do_gettimeofday(&tv);
    6.17 @@ -254,7 +254,6 @@ static inline void do_timer_interrupt(in
    6.18  		foo_count = 0;
    6.19  	}
    6.20  #endif
    6.21 -
    6.22      /*
    6.23       * The next bit really sucks:
    6.24       * Linux not only uses do_gettimeofday() to keep a notion of