CN104572282A - 一种将sas控制器中断绑定到cpu的自动化方法 - Google Patents

一种将sas控制器中断绑定到cpu的自动化方法 Download PDF

Info

Publication number
CN104572282A
CN104572282A CN201510002739.0A CN201510002739A CN104572282A CN 104572282 A CN104572282 A CN 104572282A CN 201510002739 A CN201510002739 A CN 201510002739A CN 104572282 A CN104572282 A CN 104572282A
Authority
CN
China
Prior art keywords
cpu
sas controller
sas
interrupt
binding
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510002739.0A
Other languages
English (en)
Inventor
伯绍文
闫硕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201510002739.0A priority Critical patent/CN104572282A/zh
Publication of CN104572282A publication Critical patent/CN104572282A/zh
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明公开一种将SAS控制器中断绑定到CPU的自动化方法,整个过程主要是利用shell脚本实现SAS控制器中断到CPU的自动化绑定,自动实现SAS控制器中断到CPU的绑定,免去人机交互过程;利用shell脚本自动获取SAS控制器中断号,自动计算并分配中断号到指定的CPU,该过程完全自动完成。该自动化方法应用在服务器性能测试阶段和服务器投入使用时,用来提高SAS卡IOPS性能,可以节省人力和时间,提高工作效率。

Description

一种将SAS控制器中断绑定到CPU的自动化方法
技术领域
本发明涉及计算机技术,具体地说是一种将SAS控制器中断绑定到CPU的自动化方法。
背景技术
从2.4版本内核开始,Linux改进了分配特定中断到指定的处理器(或处理器组)的功能,被称为SMP IRQ affinity,它可以控制系统如何响应各种硬件事件,允许限制或者重新分配服务器的工作负载,从而让服务器更有效的工作。 以SAS控制器中断为例,在没有设置SMP IRQ affinity时,所有SAS控制器中断主要被关联到CPU0,这导致了CPU0负载过高,且会影响IOPS性能。通过SMP IRQ affinity,把SAS控制器多个中断分配到多个CPU上,可以分散CPU压力,提高数据处理速度。但是要实现SAS控制器中断到指定CPU之间的绑定需要输入大量的系统命令,这不仅需要熟练的操作和专业知识,还需要耗费大量的时间。
发明内容
本方明针对现有技术存在的技术问题,开发了一个基于shell脚本的将SAS控制器中断绑定到CPU的自动化方法。
本发明所述一种将SAS控制器中断绑定到CPU的自动化方法,解决上述技术问题采用的技术方案如下:整个过程主要是利用shell脚本实现SAS控制器中断到CPU的自动化绑定,自动实现SAS控制器中断到CPU的绑定,免去人机交互过程。
本发明所述自动化方法,利用shell脚本自动获取SAS控制器中断号,自动计算并分配中断号到指定的CPU,该过程完全自动完成。该动化方法的具体流程如下,首先强制关闭irqbalance服务,然后自动获取CPU内核总数,并自动获取SAS控制器中断号、SAS卡中断数量以及绑定这些中断所需的CPU组;最后,显示最终绑定结果,整个过程结束。
本发明的一种将SAS控制器中断绑定到CPU的自动化方法与现有技术相比具有的有益效果是:该自动化方法通过shell脚本实现特定SAS控制器中断到指定CPU的全自动绑定,无需手动输入大量的系统命令和其他操作;较以往需要手动绑定的方法,减少了不必要的人机交互过程,节省人力、时间、成本等资源,并且操作简单无需经验也可完成相关操作;该自动化方法应用在服务器性能测试阶段和服务器投入使用时,用来提高SAS卡IOPS性能,可以节省人力和时间,提高工作效率。
附图说明
附图1为将SAS控制器中断绑定到CPU的自动化方法的流程图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参考附图,对本发明所述一种将SAS控制器中断绑定到CPU的自动化方法进一步详细说明。
本发明所述一种将SAS控制器中断绑定到CPU的自动化方法, 整个过程主要是利用shell脚本实现SAS控制器中断到CPU的自动化绑定,自动实现SAS控制器中断到CPU的绑定,免去人机交互过程。该shell脚本使用方便,操作简单,无需掌握专业知识也可完成操作;该自动化方法应用在服务器性能测试阶段和服务器投入使用时,用来提高SAS卡IOPS性能,可以节省人力和时间,提高工作效率。
实施例1:
本实施例所述一种将SAS控制器中断绑定到CPU的自动化方法, 通过shell脚本实现特定SAS控制器中断到指定CPU的全自动绑定,无需手动输入大量的系统命令和其他操作;整个过程主要是利用shell脚本自动获取SAS控制器中断号,自动计算并分配中断号到指定的CPU,该过程完全自动完成。
本实施例所述自动化方法的具体流程,如附图1所示,首先强制关闭irqbalance服务,然后,自动获取CPU内核总数,并自动获取SAS控制器中断号、SAS卡中断数量以及绑定这些中断所需的CPU组;最后,显示最终绑定结果,整个过程结束。
在该将SAS控制器中断绑定到CPU的自动化方法中,关于强制关闭irqbalance服务:因系统自带用于自动中断分配服务(irqbalance)与本操作冲突,脚本根据OS不同(suse或redhat),首先强制将irqbalance服务关闭;
实现方法如下:
if [ -f /etc/SuSE-release ] && [ -f /etc/init.d/irq_balancer ] ;
then /etc/init.d/irq_balancer stop
elif [ -f /etc/redhat-release ] && [ -f /etc/init.d/irqbalance ];
then /etc/init.d/irqbalance stop
else exit 1;
fi;.
在该将SAS控制器中断绑定到CPU的自动化方法中, 自动计算CPU内核总数(cpu_count):
cpu_count=`cat /proc/cpuinfo | grep –c process `.
在该将SAS控制器中断绑定到CPU的自动化方法中,自动获取SAS控制器的中断号unique id(ioc)、SAS卡中断数量(msix_count)、绑定这些中断所需的CPU组(grouping),是指按CPU内核总数和SAS卡中断号总数,计算每个中断绑定哪些CPU内核,形成位掩码bitmask,并写入/proc/irq/IRQ#/smp_affinity,实现方法如下:
   scsi_host="/sys/class/scsi_host"              
cd ${scsi_host}
subfolders=`ls -1`
for i in ${subfolders};
do cd ${scsi_host}/${i};
   if [ `cat proc_name` != "mpt2sas" ];
then    continue;
   fi;                                      
   if [ ! -f reply_queue_count ]; then
      echo "reply_queue_count sysfs attribute doesn't exist"
      continue;
   fi;
   if [ `cat reply_queue_count` -lt 2 ]; then
      continue;
   fi;                                            
   ioc=`cat unique_id`                   #获取SAS控制器的unique id
   index=0
   affinity=1
   cpu_affinity_count=0
   msix_count=`cat /proc/interrupts | grep -c mpt2sas${ioc}-msix`   #总中断数
   if [ ${cpu_count} -gt ${msix_count} ];
then    let grouping=${cpu_count}/${msix_count}          #所需的CPU组
        let grouping_mod=${cpu_count}%${msix_count}.
在该将SAS控制器中断绑定到CPU的自动化方法中,输出SAS控制器的中断号unique id(ioc),cpu内核总数(cpu_count),总中断矢量数量(msix_count),每个中断向量分配的核数。同时,获取SAS卡中断号(a),表示a中断将被路由到哪个指定处理器的位掩码(b),实现方法如下:
   echo grouping = ${grouping}, grouping_mod = ${grouping_mod}
      if [ ${grouping} -lt 2 ]; then
        cpu_grouping=2;
      elif [ ${grouping} -eq 2 ] && [ ${grouping_mod} -eq 0 ]; then
        cpu_grouping=2;
      elif [ ${grouping} -lt 4 ]; then
        cpu_grouping=4;
      elif [ ${grouping} -eq 4 ] && [ ${grouping_mod} -eq 0 ]; then
        cpu_grouping=4;
      elif [ ${grouping} -lt 8 ]; then
        cpu_grouping=8;
      elif [ ${grouping} -eq 8 ] && [ ${grouping_mod} -eq 0 ]; then
        cpu_grouping=8;
      else
        cpu_grouping=16;
      fi;
   else
      cpu_grouping=0;
   fi;
   echo -e "\n"
   echo ioc number = ${ioc}                           #输出SAS控制器
   echo number of core processors = ${cpu_count}        #输出CPU核数
   echo msix vector count = ${msix_count}           #输出中断矢量数量 if [ ${cpu_grouping} -eq 0 ] ; then
      echo number of cores per msix vector = 1
#如cpu_group=0,每个中断对应一个核
   else
      echo number of cores per msix vector = ${cpu_grouping}
#输出每个中断矢量对应的CPU组
   fi;
   echo -e "\n"
   while [ ${msix_count} -gt ${index} ] && \
      ( [ ${cpu_affinity_count} -lt ${cpu_count} ] || \
        [ ${cpu_affinity_count} -eq ${cpu_count} ] ); do
      b=0
   a=`cat /proc/interrupts | grep -w mpt2sas${ioc}-msix${index} | cut -d : -f 1`   #获取msix(index)对应的控制器中断号
      irq_number=`basename ${a}`
      cd /proc/irq/${irq_number}            #进入相应中断的配置目录
      if [ ${cpu_grouping} -ne 0 ]; then
        loop=1
        calculate_affinity=${affinity}
        let cpu_affinity_count=${cpu_affinity_count}+1
        while [ ${loop} -lt ${cpu_grouping} ]; do
           let affinity=${affinity}*2
           let calculate_affinity=${calculate_affinity}+${affinity}
           let loop=${loop}+1
           let cpu_affinity_count=${cpu_affinity_count}+1
        done;
        b=`printf "%x" ${calculate_affinity}`
#获取msix(index)绑定CPU的对应Bitmask
      else
        let cpu_affinity_count=${cpu_affinity_count}+1
        b=`printf "%x" ${affinity}`
      fi;
   echo cpu_affinity_count = ${cpu_affinity_count}
      if [ ${cpu_affinity_count} -lt ${cpu_count} ] || \
         [ ${cpu_affinity_count} -eq ${cpu_count} ]; then
        let length=${#b}
        let number_of_words=${length}/8
        let extra_word=${length}%8
        let i=0
        if [ ${extra_word} -gt 0 ]; then
           echo -n "${b:0:${extra_word}}" > /tmp/smp_affinity-${index}
           if [ ${number_of_words} -gt 0 ]; then
              echo -n "," >> /tmp/smp_affinity-${index}
           fi
        fi
        while [ $i -lt ${number_of_words} ]; do
           echo -n "${b:${i}*8+${extra_word}:8}" >> /tmp/smp_affinity-${index}
           let i=${i}+1
           if [ $i -lt ${number_of_words} ]; then
               echo -n "," >> /tmp/smp_affinity-${index}
           fi
        done
        cat /tmp/smp_affinity-${index} > smp_affinity 
#将bitmask写入相应中断CPU绑定配置文件smp_affinity
        rm -f /tmp/smp_affinity-${index}  
#       echo -e "\tmsix index = ${index}, irq number =  ${irq_number}, cpu affinity mask = ${b}"
        echo -e "\tmsix index = ${index}, irq number =  ${irq_number}, cpu affinity mask = `cat smp_affinity`"
        let index=${index}+1
        let affinity=${affinity}*2
      fi;
   done
   echo -e "\nWe have set affinity for ${index} msix vectors and ${cpu_count} core processors\n"
done.
该将SAS控制器中断绑定到CPU 的自动化实现方法,借用SHELL脚本实现SAS控制器中断到CPU的自动绑定,大大简化了操作流程,特别对于多盘位服务器,使用的SAS控制器中断比较多,使用该方法可以轻松实现大量SAS控制器到CPU的绑定。该自动化方法可应用于所有x86服务器产品,在服务器测试阶段或者其他阶段,在提高SAS卡性能测试准确性和优化性能的同时,为公司节省了人力、时间、成本等资源,也减少了不必要的人机交互过程。
上述具体实施方式仅是本发明的具体个案,本发明的专利保护范围包括但不限于上述具体实施方式,任何符合本发明的权利要求书的且任何所属技术领域的普通技术人员对其所做的适当变化或替换,皆应落入本发明的专利保护范围。

Claims (3)

1.一种将SAS控制器中断绑定到CPU的自动化方法,其特征在于,利用shell脚本实现SAS控制器中断到CPU的自动化绑定,利用shell脚本自动获取SAS控制器中断号,自动计算并分配中断号到指定的CPU;该动化方法的具体流程如下:首先强制关闭irqbalance服务,然后自动获取CPU内核总数,并自动获取SAS控制器中断号、SAS卡中断数量以及绑定这些中断所需的CPU组;最后,显示最终绑定结果。
2.根据权利要求1所述一种将SAS控制器中断绑定到CPU的自动化方法,其特征在于,按CPU内核总数和SAS卡中断号总数,计算每个中断绑定哪些CPU内核,形成位掩码。
3.根据权利要求2所述一种将SAS控制器中断绑定到CPU的自动化方法,其特征在于,输出SAS控制器的中断号、cpu内核总数、总中断矢量数量,以及每个中断向量分配的核数。
CN201510002739.0A 2015-01-05 2015-01-05 一种将sas控制器中断绑定到cpu的自动化方法 Pending CN104572282A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510002739.0A CN104572282A (zh) 2015-01-05 2015-01-05 一种将sas控制器中断绑定到cpu的自动化方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510002739.0A CN104572282A (zh) 2015-01-05 2015-01-05 一种将sas控制器中断绑定到cpu的自动化方法

Publications (1)

Publication Number Publication Date
CN104572282A true CN104572282A (zh) 2015-04-29

Family

ID=53088429

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510002739.0A Pending CN104572282A (zh) 2015-01-05 2015-01-05 一种将sas控制器中断绑定到cpu的自动化方法

Country Status (1)

Country Link
CN (1) CN104572282A (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550039A (zh) * 2015-12-21 2016-05-04 浪潮电子信息产业股份有限公司 一种基于Redhat Linux系统下网卡性能调优的实现方法
CN106502786A (zh) * 2016-10-08 2017-03-15 郑州云海信息技术有限公司 一种中断分配方法及装置
CN107025186A (zh) * 2016-01-29 2017-08-08 龙芯中科技术有限公司 中断号分配方法及装置
CN107943632A (zh) * 2017-11-23 2018-04-20 郑州云海信息技术有限公司 一种实现多nvme盘配置服务器中各盘性能均衡的方法及系统

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050246461A1 (en) * 2004-04-29 2005-11-03 International Business Machines Corporation Scheduling threads in a multi-processor computer
CN1766861A (zh) * 2005-12-02 2006-05-03 北京中星微电子有限公司 多中断处理单元的中断处理的装置和方法
CN101246438A (zh) * 2008-03-07 2008-08-20 中兴通讯股份有限公司 一种对称多处理系统中进程与中断的处理方法及装置
CN101634974A (zh) * 2009-08-26 2010-01-27 成都市华为赛门铁克科技有限公司 一种多中断类型的处理方法、装置和系统
CN101901167A (zh) * 2010-07-22 2010-12-01 网御神州科技(北京)有限公司 一种多cpu架构下的多网络安全审计方法和系统
CN102521047A (zh) * 2011-11-15 2012-06-27 重庆邮电大学 实现多核处理器间中断负载均衡的方法
CN102567109A (zh) * 2010-12-07 2012-07-11 苹果公司 中断分配方案
CN103389913A (zh) * 2013-07-30 2013-11-13 武汉邮电科学研究院 一种用于Linux系统的实时中断处理方法
CN103699428A (zh) * 2013-12-20 2014-04-02 华为技术有限公司 一种虚拟网卡中断亲和性绑定的方法和计算机设备

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050246461A1 (en) * 2004-04-29 2005-11-03 International Business Machines Corporation Scheduling threads in a multi-processor computer
CN1766861A (zh) * 2005-12-02 2006-05-03 北京中星微电子有限公司 多中断处理单元的中断处理的装置和方法
CN101246438A (zh) * 2008-03-07 2008-08-20 中兴通讯股份有限公司 一种对称多处理系统中进程与中断的处理方法及装置
CN101634974A (zh) * 2009-08-26 2010-01-27 成都市华为赛门铁克科技有限公司 一种多中断类型的处理方法、装置和系统
CN101901167A (zh) * 2010-07-22 2010-12-01 网御神州科技(北京)有限公司 一种多cpu架构下的多网络安全审计方法和系统
CN102567109A (zh) * 2010-12-07 2012-07-11 苹果公司 中断分配方案
CN102521047A (zh) * 2011-11-15 2012-06-27 重庆邮电大学 实现多核处理器间中断负载均衡的方法
CN103389913A (zh) * 2013-07-30 2013-11-13 武汉邮电科学研究院 一种用于Linux系统的实时中断处理方法
CN103699428A (zh) * 2013-12-20 2014-04-02 华为技术有限公司 一种虚拟网卡中断亲和性绑定的方法和计算机设备

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
南风轩: "Linux技巧:多核下绑定硬件进程到不同CPU", 《博客园 HTTP://WWW.CNBLOGS.COM/ZACKYANG/ARCHIVE/2012/02/08/2342141.HTML》 *
王伟 等: "基于MPCore与Linux的中断亲和性研究", 《南京大学学报(自然科学)》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550039A (zh) * 2015-12-21 2016-05-04 浪潮电子信息产业股份有限公司 一种基于Redhat Linux系统下网卡性能调优的实现方法
CN107025186A (zh) * 2016-01-29 2017-08-08 龙芯中科技术有限公司 中断号分配方法及装置
CN106502786A (zh) * 2016-10-08 2017-03-15 郑州云海信息技术有限公司 一种中断分配方法及装置
CN107943632A (zh) * 2017-11-23 2018-04-20 郑州云海信息技术有限公司 一种实现多nvme盘配置服务器中各盘性能均衡的方法及系统

Similar Documents

Publication Publication Date Title
US9798682B2 (en) Completion notification for a storage device
AU2014311463B2 (en) Virtual machine monitor configured to support latency sensitive virtual machines
WO2018099299A1 (zh) 一种图数据处理的方法、装置及系统
US20170004005A1 (en) Exception handling in microprocessor systems
US20070079022A1 (en) Gathering I/O Measurement Data During an I/O Operation Process
US8566831B2 (en) Execution of work units in a heterogeneous computing environment
US7783867B2 (en) Controlling instruction execution in a processing environment
US9697031B2 (en) Method for implementing inter-virtual processor interrupt by writing register data in a single write operation to a virtual register
EP2881860B1 (en) Method for implementing an interrupt between virtual processors, related device, and system
CN104572282A (zh) 一种将sas控制器中断绑定到cpu的自动化方法
US9395918B2 (en) Dynamic record management including opening a virtual storage access method (VSAM) data set and modifying a VSAM control block structure
CN105677479A (zh) 并行运行gpu运算程序的实现方法及装置
US10817220B2 (en) Sharing processor cores in a multi-threading block i/o request processing data storage system
CN104932922A (zh) 一种调整sas卡硬盘启动顺序的方法及装置
CN104951342A (zh) 一种调整启动顺序的方法及装置
US9552223B2 (en) Post-return asynchronous code execution
US20130212587A1 (en) Shared resources in a docked mobile environment
US10761922B2 (en) Method and system to decrease measured usage license charges for diagnostic data collection
CN105138388A (zh) 虚拟机监控方法及装置
US20150278299A1 (en) External merge sort method and device, and distributed processing device for external merge sort
US10783059B2 (en) Method and system to decrease measured usage license charges for diagnostic data collection
CN102945214B (zh) 基于io延迟时间分布优化中断处理任务的方法
EP3200083B1 (en) Resource scheduling method and related apparatus
CN102929819B (zh) 用于处理计算机系统中的存储设备的中断请求的方法
CN104965749A (zh) 一种kvm虚拟机快照恢复优化方法及系统

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150429

WD01 Invention patent application deemed withdrawn after publication