【Linux 内核】CPU 分类与状态 ( CPU 处理器分类

阅读: 评论:0

【Linux 内核】CPU 分类与状态 ( CPU 处理器分类

【Linux 内核】CPU 分类与状态 ( CPU 处理器分类

文章目录

  • 一、CPU 处理器分类
    • 1、根据物理属性分类 ( SMT、MC、SoC )
    • 2、Linux 内核中 CPU 分类
  • 二、Linux 内核源码中的 CPU 状态源码





一、CPU 处理器分类




1、根据物理属性分类 ( SMT、MC、SoC )


根据 CPU 的物理属性 , 可以将 CPU 分为如下几类 :

  • SMT : 全称 " Simultaneous Multithreading " , 同时多线程 , 又称为 " 超线程 " , 一个物理核心 , 可以有 2 2 2 个执行线程 , 使用相同的 CPU 资源 , 共享 L1 Cache 缓存 ;
  • MC : Multicore 多核 , 每个物理核心 独享一个 L1 Cache 缓存 ;
  • SoC : System on Chip , 系统级芯片 ;

2、Linux 内核中 CPU 分类


Linux 内核中 , 对 CPU 处理器的分类 :

  • CONFIG_SCHED_SMT : 对应 SMT 芯片 , " 超线程 " , 一个物理核心 , 可以有 2 2 2 个执行线程 , 使用相同的 CPU 资源 , 共享 L1 Cache 缓存 ;
  • CONFIG_SCHED_MC : 对应 MC 多核芯片 , 每个物理核心 独享一个 L1 Cache 缓存 ;
  • DIE : 对应 SoC 芯片 ;




二、Linux 内核源码中的 CPU 状态源码



Linux 内核中 , 通过 bitmap 管理 CPU 处理器 , 并且在 Linux 源码中的 linux-5.6.18includelinuxcpumask.h 头文件源码中 , 定义了 CPU 的四种状态 :

  • cpu_possible_mask : 表示系统中 可以执行的 CPU 核心个数 , 可执行指的是现在可以运行 以及 将来某个时间段可以运行 ;
  • cpu_online_mask : 表示当前系统中 有多少个正在运行的 CPU 核心个数 ;
  • cpu_present_mask : 表示当前系统中 有多少个具备 online 条件的 CPU 核心个数 , 不一定都处于 online 状态 ;
  • cpu_active_mask : 表示当前系统中 有多少个活跃的 CPU 核心 ;
/** The following particular system cpumasks and operations manage* possible, present, active and online cpus.**     cpu_possible_mask- has bit 'cpu' set iff cpu is populatable*     cpu_present_mask - has bit 'cpu' set iff cpu is populated*     cpu_online_mask  - has bit 'cpu' set iff cpu available to scheduler*     cpu_active_mask  - has bit 'cpu' set iff cpu available to migration**  If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.**  The cpu_possible_mask is fixed at boot time, as the set of CPU id's*  that it is possible might ever be plugged in at anytime during the*  life of that system boot.  The cpu_present_mask is dynamic(*),*  representing which CPUs are currently plugged in.  And*  cpu_online_mask is the dynamic subset of cpu_present_mask,*  indicating those CPUs available for scheduling.**  If HOTPLUG is enabled, then cpu_possible_mask is forced to have*  all NR_CPUS bits set, otherwise it is just the set of CPUs that*  ACPI reports present at boot.**  If HOTPLUG is enabled, then cpu_present_mask varies dynamically,*  depending on what ACPI reports as currently plugged in, otherwise*  cpu_present_mask is just a copy of cpu_possible_mask.**  (*) Well, cpu_present_mask is dynamic in the hotplug case.  If not*      hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.** Subtleties:* 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode*    assumption that their single CPU is online.  The UP*    cpu_{online,possible,present}_masks are placebos.  Changing them*    will have no useful affect on the following num_*_cpus()*    and cpu_*() macros in the UP case.  This ugliness is a UP*    optimization - don't waste any instructions or memory references*    asking if you're online or how many CPUs there are if there is*    only one CPU.*/extern struct cpumask __cpu_possible_mask;
extern struct cpumask __cpu_online_mask;
extern struct cpumask __cpu_present_mask;
extern struct cpumask __cpu_active_mask;
#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
#define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
#define cpu_present_mask  ((const struct cpumask *)&__cpu_present_mask)
#define cpu_active_mask   ((const struct cpumask *)&__cpu_active_mask)

本文发布于:2024-02-03 03:42:32,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170690295048424.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:内核   处理器   状态   Linux   CPU
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23