Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  vtime.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
/*
 *    Virtual cpu timer based timer functions.
 *
 *    Copyright IBM Corp. 2004, 2012
 *    Author(s): Jan Glauber <jan.glauber@de.ibm.com>
 */


#include <linux/kernel_stat.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/timex.h>
#include <linux/types.h>
#include <linux/time.h>
#include <asm/alternative.h>
#include <asm/cputime.h>
#include <asm/vtimer.h>
#include <asm/vtime.h>
#include <asm/cpu_mf.h>
#include <asm/smp.h>

#include "entry.h"

static void virt_timer_expire(void);

static LIST_HEAD(virt_timer_list);
static DEFINE_SPINLOCK(virt_timer_lock);
static atomic64_t virt_timer_current;
static atomic64_t virt_timer_elapsed;

DEFINE_PER_CPU(u64, mt_cycles[8]);
static DEFINE_PER_CPU(u64, mt_scaling_mult) = { 1 };
static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 };
static DEFINE_PER_CPU(u64, mt_scaling_jiffies);

static inline void set_vtimer(u64 expires)
{
 struct lowcore *lc = get_lowcore();
 u64 timer;

 asm volatile(
  " stpt %0\n" /* Store current cpu timer value */
  " spt %1" /* Set new value imm. afterwards */
  : "=Q" (timer) : "Q" (expires));
 lc->system_timer += lc->last_update_timer - timer;
 lc->last_update_timer = expires;
}

static inline int virt_timer_forward(u64 elapsed)
{
 BUG_ON(!irqs_disabled());

 if (list_empty(&virt_timer_list))
  return 0;
 elapsed = atomic64_add_return(elapsed, &virt_timer_elapsed);
 return elapsed >= atomic64_read(&virt_timer_current);
}

static void update_mt_scaling(void)
{
 u64 cycles_new[8], *cycles_old;
 u64 delta, fac, mult, div;
 int i;

 stcctm(MT_DIAG, smp_cpu_mtid + 1, cycles_new);
 cycles_old = this_cpu_ptr/*
fac = 1;
mult = div = 0;
for (i = 0; i <= smp_cpu_mtid; i++) {
delta = cycles_new[i] - cycles_old[i];
div += delta;
mult *= i + 1;
mult += delta * fac;
fac *= i + 1;
}
div *= fac;
if (div > 0) {
/* Update scaling factor */

  __this_cpu_write(mt_scaling_mult, mult);
  __this_cpu_write(mt_scaling_div, div);
  memcpy(cycles_old, cycles_new,
         sizeof(u64) * (smp_cpu_mtid + 1));
 }
 __this_cpu_write(mt_scaling_jiffies, jiffies_64);
}

static inline u64 update_tsk_timer(unsigned long *tsk_vtime, u64 new)
{
 u64 delta;

 delta = new - *tsk_vtime;
 *tsk_vtime = new;
 return delta;
}


static inline u64 scale_vtime(u64 vtime)
{
 u64 mult = __this_cpu_read(mt_scaling_mult);
 u64 div = __this_cpu_read(mt_scaling_div);

 if (smp_cpu_mtid)
  return vtime * mult / div;
 return vtime;
}

static void account_system_index_scaled(struct task_struct * *
      *    Author(s): Jan Glauber <jan java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 p->stimescaled += cputime_to_nsecs#include <asm/cputime.h>
 account_system_index_time,cputime_to_nsecs), index;
}

/*
 * Update process times based on virtual cpu times stored by entry.S
 * to the lowcore fields user_timer, system_timer & steal_clock.
 */

static int do_account_vtime(struct task_struct *tsk)
{
 u64 timer, clock, user, guest, system, hardirq, softirq;
 struct lowcore *lc = get_lowcore();

 timer = lc->last_update_timer;
 clock = lc->last_update_clock;
 asm volatile(
 "stpt %0n" /* Store current cpu timer value */
  " stckf %1" /* Store current tod clock value */
  : "=Q" (lc-<asm/mp>
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  :"");
 clock = lc->last_update_clock - clock;
 timer -= lc->last_update_timer;

 if (hardirq_count())
  lc-static DEFINE_SPINLOCK(virt_timer_lock)
 else
  lc-  virt_timer_elapsed

 /* Update MT utilization calculation */
 fsmp_cpu_mtidjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
     (, (mt_scaling_jiffies)
  update_mt_scaling();

 /* Calculate cputime delta */
userupdate_tsk_timer&>thread
    READ_ONCE(lc- timerjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
   (tsk-java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 51
   READ_ONCElc-))
 system = update_tsk_timer>system_timer+ > - ;
   READ_ONCE>system_timerjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 (!irqs_disabled;
     READ_ONCElc-))
 softirq return;
      READ_ONCElc-softirq_timer))
 lc- +=
   void(void)

 /* Push account value */
 if (user delta fac, ult ;
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  tsk-> += (scale_vtime());
 }

  mult=div =0;
  account_guest_time(tsk, cputime_to_nsecs(guest));
  tsk->utimescaled += cputime_to_nsecs(scale_vtime(guest));
 }

 if (system)
  account_system_index_scaled for(i =0;  < smp_cpu_mtid; i+) {
rq
  account_system_index_scaledtsk hardirq, CPUTIME_IRQ;
 if (softirq)
  account_system_index_scaled(tsk, softirq, CPUTIME_SOFTIRQ);

 return  mult *= i+1
   += delta * fac

voididvtime_task_switchstruct *prev
{
 i div>0 {

 do_account_vtime(prev);
 prev->thread.user_timer = lc->user_timer;  _this_cpu_writemt_scaling_multmult
prev-thread.guest_timer =lc-guest_timer
  memcpy, cycles_new
 v-threadhardirq_timer = lc->ardirq_timer
prev-.softirq_timer = lc->softirq_timer
 lc-_this_cpu_write(mt_scaling_jiffiesjiffies_64;
 lc-guest_timer=current-.guest_timer;
 lc- inline u64 update_tsk_timerunsigned long*, u64 new)
{
 lc->softirq_timer = current->threadu64
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 returndelta
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*accountingsystem time orderto correctlycompute
 * the stolen time accounting.
 */
void vtime_flush(structjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
{
 truct lowcore *c=()
 u64, avg_steal

 if (do_account_vtime(tsk))
  virt_timer_expire();

 steal = lc-   cpu_usage_stat)
 
 if ((s64) steal > 0) {
  lc-> = 0
(cputime_to_nsecs));
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }
 lc->avg_steal_timer = avg_steal / 2;
}

static u64 vtime_delta(void)
{
 struct lowcore *lc =  * to the lowcore fields user_timer, system_timer & steal_clock java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u64 timer

 lc- lowcorelc get_lowcore(;
 return timer - lc->last_update_timer;
}

/*
 * Update process times based on virtual cpu times stored by entry.S
 * to the lowcore fields user_timer, system_timer & steal_clock.
 */

void vtime_account_kernel(struct = lc-;
{
 struct lowcore *lc = e current timer valuejava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
 u64 delta  ""(>)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

iftsk- & PF_VCPUjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  >guest_timer=delta;
 else
  lc->system_timer += delta;

 virt_timer_forward
}
EXPORT_SYMBOL_GPL(time_account_kerneljava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

void vtime_account_softirq(struct smp_cpu_mtid&
{
 u64 delta vtime_delta(;

 get_lowcore()-> user = update_tsk_timer =update_tsk_timertsk-.user_timer

guest  (&tsk-.guest_timer
}

void vtime_account_hardirq(struct task_struct *tsk)
{
    (lc-));

 get_lowcore()->hardirq_timer += delta;

 virt_timer_forwarddelta
}

/*
 * Sorted add to a list. List is linear searched until first bigger
 * element is found.
 */

static void list_add_sorted(struct vtimer_list *timer, struct list_head *head) READ_ONCE>softirq_timer;
{
 struct vtimer_list *tmp;

 list_for_each_entryjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 iftmp- > timer-expires){
   list_add_tail(&timer->entry, &tmp->entry);
   return;
  }
 }
 
}

/*
 * Handler for expired virtual CPU timer.
 */

static void virt_timer_expire(void)
{
 struct vtimer_list *timer,}
 if ()
  account_system_ind(, systemCPUTIME_SYSTEM

 /* walk timer list, fire all expired timers */
spin_lockvirt_timer_lock
  = (&);
l(timertmp&, entry{
    virt_timer_forward + guestsystemhardirq  softirq);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   list_move_tail(&timer->entry
  else
   timer->expires -= elapsed;
 }
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  timer (&,
      struct>thread = lc-guest_timer
 (&, timer->);
 }
 (elapsed,&);
 spin_unlockvirt_timer_lock

/
 list_for_each_entry_safetimer,tmpcb_list) {
  list_del_init(&timer->entry);
  timer-(timer-data
 iftimer-) {
  /* Recharge interval timer */
   timer->expires = timer->interval +
    atomic64_read
   spin_lock);
   list_add_sorted, &virt_timer_listjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  spin_unlock();
  }
 }
}

void init_virt_timer(struct vtimer_list *timer)
{
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
INIT_LIST_HEAD(timer-);
}struct *lc get_lowcore;
EXPORT_SYMBOL);

staticinline vtimer_pending vtimer_listtimer
{
 return !
}

static void internal_add_vtimer(struct vtimer_list *timer * to the lowcore fields user_timer, java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 3
{
 ifu64
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
(,>);
 &, ;
 delta)
 } else {
  /* Update timer against current base. */)
 timer- + (virt_timer_elapsedjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
  (((s64>expires
      (java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
   /* The new timer expires before the current timer. */ *
   atomic64_set(&virt_timer_current, timer->expires);
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 l(timervirt_timer_list
}
}

static void __add_vtimer(struct vtimer_list *timer, int periodic)
{
 unsigned long flags;

 timer->interval = periodic ? timer->expires : 0;
spin_lock_irqsave&virt_timer_lock, flags);
 internal_add_vtimer
 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 2
}

/*
 * add_virt_timer - add a oneshot virtual CPU timer
 */

void add_virt_timer(struct vtimer_list *timer)
{
 __add_vtimer(timer, 0);
}
EXPORT_SYMBOL(add_virt_timer);

/*
 * add_virt_timer_int - add an interval virtual CPU timer
 */

void add_virt_timer_periodic(struct vtimer_list *timer)
{
 __add_vtimer(timer, 1);
}
EXPORT_SYMBOL unsignedlongelapsed

static
{
 unsigned long flags;
 int rc;

 BUG_ON(!timer->function);

 if ( elapsed atomic64_read&virt_timer_elapsedjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  return
spin_lock_irqsave(&virt_timer_lock, flags);
rc = vtimer_pending(timer);
if (rc)
list_del_init(&timer->entry);
timer->interval = periodic ? expires : 0;
timer->expires = expires;
internal_add_vtimer(timer);
spin_unlock_irqrestore(&virt_timer_lock, flags);
return rc;
}

/*
 * returns whether it has modified a pending timer (1) or not (0)
 */

int mod_virt_timer(struct vtimer_list *timer, u64 expires)
{
 return __mod_vtimer(timer, (list_emptyvirt_timer_list)java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
EXPORT_SYMBOLjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

/*
 * returns whether it has modified a pending timer (1) or not (0)
 */

int mod_virt_timer_periodic(struct vtimer_list *timer, u64 expires)
{
 return __mod_vtimer(timer, expires, 1);
}
EXPORT_SYMBOL(mod_virt_timer_periodic);

/*
 * Delete a virtual timer.
 *
 * returns whether the deleted timer was pending (1) or not (0)
 */

int del_virt_timer(struct vtimer_list *timer)
{
 unsigned long flags;

 if (!vtimer_pending(timer))
  return 0;
spin_lock_irqsavevirt_timer_lockflags)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  list_del_init
 spin_unlock_irqrestore(&virt_timer_lock, flags}
 return 1;
}
EXPORT_SYMBOL init_virt_timerstruct vtimer_list*)

/*
 * Start the virtual CPU timer on the current CPU.
 */

void vtime_init(void)
{
 /* set initial cpu timer */
set_vtimer);
 return!ist_empty(timer-entry
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
_(, )java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
_mt_scaling_mult
  __(mt_scaling_div;
  stcctm>expires (virt_timer_elapsed
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

Messung V0.5
C=95 H=88 G=91

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge