ia64/xen-unstable

changeset 153:5b394412fded

bitkeeper revision 1.28 (3e4bdf33sufyB9J_a-mb8comwfYdfw)

more elegant way of reading multiple values atomically
author rn@wyvis.camb.intel-research.net
date Thu Feb 13 18:08:51 2003 +0000 (2003-02-13)
parents 42a318e8648e
children 99a121f0ecff
files xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c
line diff
     1.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Thu Feb 13 15:58:34 2003 +0000
     1.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Thu Feb 13 18:08:51 2003 +0000
     1.3 @@ -101,16 +101,12 @@ static inline long long get_s_time(void)
     1.4  
     1.5  	spin_lock_irqsave(&hyp_stime_lock, flags);
     1.6  
     1.7 -    pcc = HYPERVISOR_shared_info->st_timestamp;
     1.8 -	mb();	
     1.9 -	if (pcc != shadow_st_pcc) {
    1.10 -st_again:
    1.11 -		shadow_st_pcc = HYPERVISOR_shared_info->st_timestamp;
    1.12 +	while ((pcc = HYPERVISOR_shared_info->st_timestamp) != shadow_st_pcc)
    1.13 +	{
    1.14 +		barrier();
    1.15 +		shadow_st_pcc = pcc;
    1.16  		shadow_st     = HYPERVISOR_shared_info->system_time;
    1.17 -		pcc = HYPERVISOR_shared_info->st_timestamp;
    1.18 -		mb();
    1.19 -		if (pcc != shadow_st_pcc)
    1.20 -			goto st_again;
    1.21 +		barrier();
    1.22  	}
    1.23  
    1.24      now = shadow_st;
    1.25 @@ -120,7 +116,9 @@ st_again:
    1.26  	delta = ((u64)delta_tsc * st_scale_f);
    1.27  	delta >>= 32;
    1.28  	delta += ((u64)delta_tsc * st_scale_i);
    1.29 +
    1.30  	spin_unlock_irqrestore(&hyp_time_lock, flags);
    1.31 +
    1.32      return now + delta; 
    1.33  
    1.34  }
    1.35 @@ -145,19 +143,14 @@ void do_gettimeofday(struct timeval *tv)
    1.36  
    1.37  	spin_lock_irqsave(&hyp_wctime_lock, flags);
    1.38  
    1.39 -	version = HYPERVISOR_shared_info->wc_version;
    1.40 -	mb();
    1.41 -	if (version != shadow_wc_version) {
    1.42 -	wc_again:
    1.43 -		shadow_wc_version   = HYPERVISOR_shared_info->wc_version;
    1.44 +	while ((version = HYPERVISOR_shared_info->wc_version)!= shadow_wc_version)
    1.45 +	{
    1.46 +		barrier();
    1.47 +		shadow_wc_version   = version;
    1.48  		shadow_tv_sec       = HYPERVISOR_shared_info->tv_sec;
    1.49  		shadow_tv_usec      = HYPERVISOR_shared_info->tv_usec;
    1.50  		shadow_wc_timestamp = HYPERVISOR_shared_info->wc_timestamp;
    1.51 -		shadow_wc_version   = HYPERVISOR_shared_info->wc_version;
    1.52 -		version =  HYPERVISOR_shared_info->wc_version;
    1.53 -		mb();
    1.54 -		if (version != shadow_wc_version)
    1.55 -			goto wc_again;
    1.56 +		barrier();
    1.57  	}
    1.58  
    1.59  	now   = NOW();