📄 sn2_smp.c
字号:
#else rr_value = REGION_NUMBER(start);#endif shub1 = is_shub1(); if (shub1) { data0 = (1UL << SH1_PTC_0_A_SHFT) | (nbits << SH1_PTC_0_PS_SHFT) | (rr_value << SH1_PTC_0_RID_SHFT) | (1UL << SH1_PTC_0_START_SHFT);#ifndef XEN ptc0 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH1_PTC_0); ptc1 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH1_PTC_1);#else ptc0 = (unsigned long *)GLOBAL_MMR_PHYS_ADDR(0, SH1_PTC_0); ptc1 = (unsigned long *)GLOBAL_MMR_PHYS_ADDR(0, SH1_PTC_1);#endif } else { data0 = (1UL << SH2_PTC_A_SHFT) | (nbits << SH2_PTC_PS_SHFT) | (1UL << SH2_PTC_START_SHFT);#ifndef XEN ptc0 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH2_PTC + #else ptc0 = (unsigned long *)GLOBAL_MMR_PHYS_ADDR(0, SH2_PTC + #endif (rr_value << SH2_PTC_RID_SHFT)); ptc1 = NULL; } mynasid = get_nasid(); use_cpu_ptcga = local_node_uses_ptc_ga(shub1); max_active = max_active_pio(shub1); itc = ia64_get_itc(); spin_lock_irqsave(PTC_LOCK(shub1), flags); itc2 = ia64_get_itc(); __get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc; __get_cpu_var(ptcstats).shub_ptc_flushes++; __get_cpu_var(ptcstats).nodes_flushed += nix; if (!mymm) __get_cpu_var(ptcstats).shub_ptc_flushes_not_my_mm++; if (use_cpu_ptcga && !mymm) { old_rr = ia64_get_rr(start); ia64_set_rr(start, (old_rr & 0xff) | (rr_value << 8)); ia64_srlz_d(); } wait_piowc(); do { if (shub1) data1 = start | (1UL << SH1_PTC_1_START_SHFT); else data0 = (data0 & ~SH2_PTC_ADDR_MASK) | (start & SH2_PTC_ADDR_MASK); deadlock = 0; active = 0; for (ibegin = 0, i = 0; i < nix; i++) { nasid = nasids[i]; if (use_cpu_ptcga && unlikely(nasid == mynasid)) { ia64_ptcga(start, nbits << 2); ia64_srlz_i(); } else { ptc0 = CHANGE_NASID(nasid, ptc0); if (ptc1) ptc1 = CHANGE_NASID(nasid, ptc1); pio_atomic_phys_write_mmrs(ptc0, data0, ptc1, data1); active++; } if (active >= max_active || i == (nix - 1)) { if ((deadlock = wait_piowc())) { sn2_ptc_deadlock_recovery(nasids, ibegin, i, mynasid, ptc0, data0, ptc1, data1); if (reset_max_active_on_deadlock()) max_active = 1; } active = 0; ibegin = i + 1; } } start += (1UL << nbits); } while (start < end); itc2 = ia64_get_itc() - itc2; __get_cpu_var(ptcstats).shub_itc_clocks += itc2; if (itc2 > __get_cpu_var(ptcstats).shub_itc_clocks_max) __get_cpu_var(ptcstats).shub_itc_clocks_max = itc2; if (old_rr) { ia64_set_rr(start, old_rr); ia64_srlz_d(); } spin_unlock_irqrestore(PTC_LOCK(shub1), flags); preempt_enable();}#endif/* * sn2_ptc_deadlock_recovery * * Recover from PTC deadlocks conditions. Recovery requires stepping thru each * TLB flush transaction. The recovery sequence is somewhat tricky & is * coded in assembly language. */voidsn2_ptc_deadlock_recovery(short *nasids, short ib, short ie, int mynasid, volatile unsigned long *ptc0, unsigned long data0, volatile unsigned long *ptc1, unsigned long data1){ short nasid, i; unsigned long *piows, zeroval, n; __get_cpu_var(ptcstats).deadlocks++; piows = (unsigned long *) pda->pio_write_status_addr; zeroval = pda->pio_write_status_val; for (i=ib; i <= ie; i++) { nasid = nasids[i]; if (local_node_uses_ptc_ga(is_shub1()) && nasid == mynasid) continue; ptc0 = CHANGE_NASID(nasid, ptc0); if (ptc1) ptc1 = CHANGE_NASID(nasid, ptc1); n = sn2_ptc_deadlock_recovery_core(ptc0, data0, ptc1, data1, piows, zeroval); __get_cpu_var(ptcstats).deadlocks2 += n; }}/** * sn_send_IPI_phys - send an IPI to a Nasid and slice * @nasid: nasid to receive the interrupt (may be outside partition) * @physid: physical cpuid to receive the interrupt. * @vector: command to send * @delivery_mode: delivery mechanism * * Sends an IPI (interprocessor interrupt) to the processor specified by * @physid * * @delivery_mode can be one of the following * * %IA64_IPI_DM_INT - pend an interrupt * %IA64_IPI_DM_PMI - pend a PMI * %IA64_IPI_DM_NMI - pend an NMI * %IA64_IPI_DM_INIT - pend an INIT interrupt */void sn_send_IPI_phys(int nasid, long physid, int vector, int delivery_mode){ long val; unsigned long flags = 0; volatile long *p; p = (long *)GLOBAL_MMR_PHYS_ADDR(nasid, SH_IPI_INT); val = (1UL << SH_IPI_INT_SEND_SHFT) | (physid << SH_IPI_INT_PID_SHFT) | ((long)delivery_mode << SH_IPI_INT_TYPE_SHFT) | ((long)vector << SH_IPI_INT_IDX_SHFT) | (0x000feeUL << SH_IPI_INT_BASE_SHFT); mb(); if (enable_shub_wars_1_1()) { spin_lock_irqsave(&sn2_global_ptc_lock, flags); } pio_phys_write_mmr(p, val); if (enable_shub_wars_1_1()) { wait_piowc(); spin_unlock_irqrestore(&sn2_global_ptc_lock, flags); }}EXPORT_SYMBOL(sn_send_IPI_phys);/** * sn2_send_IPI - send an IPI to a processor * @cpuid: target of the IPI * @vector: command to send * @delivery_mode: delivery mechanism * @redirect: redirect the IPI? * * Sends an IPI (InterProcessor Interrupt) to the processor specified by * @cpuid. @vector specifies the command to send, while @delivery_mode can * be one of the following * * %IA64_IPI_DM_INT - pend an interrupt * %IA64_IPI_DM_PMI - pend a PMI * %IA64_IPI_DM_NMI - pend an NMI * %IA64_IPI_DM_INIT - pend an INIT interrupt */void sn2_send_IPI(int cpuid, int vector, int delivery_mode, int redirect){ long physid; int nasid; physid = cpu_physical_id(cpuid);#ifdef XEN if (!sn_nodepda) { ia64_sn_get_sapic_info(physid, &nasid, NULL, NULL); } else#endif nasid = cpuid_to_nasid(cpuid); /* the following is used only when starting cpus at boot time */ if (unlikely(nasid == -1)) ia64_sn_get_sapic_info(physid, &nasid, NULL, NULL); sn_send_IPI_phys(nasid, physid, vector, delivery_mode);}#ifdef CONFIG_PROC_FS#define PTC_BASENAME "sgi_sn/ptc_statistics"static void *sn2_ptc_seq_start(struct seq_file *file, loff_t * offset){ if (*offset < NR_CPUS) return offset; return NULL;}static void *sn2_ptc_seq_next(struct seq_file *file, void *data, loff_t * offset){ (*offset)++; if (*offset < NR_CPUS) return offset; return NULL;}static void sn2_ptc_seq_stop(struct seq_file *file, void *data){}static int sn2_ptc_seq_show(struct seq_file *file, void *data){ struct ptc_stats *stat; int cpu; cpu = *(loff_t *) data; if (!cpu) { seq_printf(file, "# cpu ptc_l newrid ptc_flushes nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max not_my_mm deadlock2\n"); seq_printf(file, "# ptctest %d\n", sn2_ptctest); } if (cpu < NR_CPUS && cpu_online(cpu)) { stat = &per_cpu(ptcstats, cpu); seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l, stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed, stat->deadlocks, 1000 * stat->lock_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 1000 * stat->shub_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 1000 * stat->shub_itc_clocks_max / per_cpu(cpu_info, cpu).cyc_per_usec, stat->shub_ptc_flushes_not_my_mm, stat->deadlocks2); } return 0;}static struct seq_operations sn2_ptc_seq_ops = { .start = sn2_ptc_seq_start, .next = sn2_ptc_seq_next, .stop = sn2_ptc_seq_stop, .show = sn2_ptc_seq_show};static int sn2_ptc_proc_open(struct inode *inode, struct file *file){ return seq_open(file, &sn2_ptc_seq_ops);}static struct file_operations proc_sn2_ptc_operations = { .open = sn2_ptc_proc_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release,};static struct proc_dir_entry *proc_sn2_ptc;static int __init sn2_ptc_init(void){ if (!ia64_platform_is("sn2")) return 0; if (!(proc_sn2_ptc = create_proc_entry(PTC_BASENAME, 0444, NULL))) { printk(KERN_ERR "unable to create %s proc entry", PTC_BASENAME); return -EINVAL; } proc_sn2_ptc->proc_fops = &proc_sn2_ptc_operations; spin_lock_init(&sn2_global_ptc_lock); return 0;}static void __exit sn2_ptc_exit(void){ remove_proc_entry(PTC_BASENAME, NULL);}module_init(sn2_ptc_init);module_exit(sn2_ptc_exit);#endif /* CONFIG_PROC_FS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -