7420815176b73b881fdef08bb6641a6bd543dbdd
[pti/rtp.git] /
1 From 55b007fcc580559e12d72c53ae39ba0136488b24 Mon Sep 17 00:00:00 2001
2 From: Jackie Huang <jackie.huang@windriver.com>
3 Date: Wed, 6 Dec 2023 17:28:44 +0800
4 Subject: [PATCH 10/12] isolcpu: handle devPath when it doesn't exist
5
6 The /dev/cpu/<cpunum>/cpuid doesn't exist and is not supported
7 for Arm architecture, so check its existence before passing
8 devPath to DeviceSpec.
9
10 Test Plan:
11 PASS: build-pkgs on x86-64 host
12 PASS: build-image on x86-64 host
13 PASS: build-pkgs on arm64 host
14 PASS: build-image on arm64 host
15 PASS: Deploy AIO-SX on x86-64 target
16 PASS: Deploy AIO-SX on arm64 target
17 PASS: Deploy AIO-DX on arm64 targets
18 PASS: Deploy std (2+2+2) on arm64 targets
19
20 Story: 2010739
21 Task: 47981
22
23 Change-Id: I0f4905139365e6dc071994c46672816ae22b294d
24 Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
25 ---
26  .../isolcpus-device-plugin/files/isolcpu.go   | 20 ++++++++++++-------
27  1 file changed, 13 insertions(+), 7 deletions(-)
28
29 diff --git a/kubernetes/plugins/isolcpus-device-plugin/files/isolcpu.go b/kubernetes/plugins/isolcpus-device-plugin/files/isolcpu.go
30 index 1ef784df..0ebab58b 100644
31 --- a/kubernetes/plugins/isolcpus-device-plugin/files/isolcpu.go
32 +++ b/kubernetes/plugins/isolcpus-device-plugin/files/isolcpu.go
33 @@ -27,6 +27,7 @@ import (
34         "isolcpu_plugin/kubernetes/pkg/kubelet/cm/cpuset"
35         "github.com/pkg/errors"
36          "io/ioutil"
37 +       "os"
38         "strconv"
39         "strings"
40          "time"
41 @@ -111,13 +112,18 @@ func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
42                          cpustr := strconv.Itoa(cpu)
43                         numaNode, _ := dp.getCPUNode(cpu)
44                         devPath := path.Join("/dev/cpu", cpustr, "cpuid")
45 -                       debug.Printf("Adding %s to isolcpus", devPath)
46 -                       var nodes []pluginapi.DeviceSpec
47 -                       nodes = append(nodes, pluginapi.DeviceSpec{
48 -                               HostPath:      devPath,
49 -                               ContainerPath: devPath,
50 -                               Permissions:   "r",
51 -                       })
52 +                       var nodes []pluginapi.DeviceSpec
53 +                       if _, err := os.Stat(devPath); os.IsNotExist(err) {
54 +                               debug.Printf("Dev path %s doesn't exist", devPath)
55 +                       } else {
56 +                               debug.Printf("Adding %s to isolcpus", devPath)
57 +                               nodes = append(nodes, pluginapi.DeviceSpec{
58 +                                       HostPath:      devPath,
59 +                                       ContainerPath: devPath,
60 +                                       Permissions:   "r",
61 +                               })
62 +
63 +                       }
64                         devTree.AddDevice(deviceType, cpustr, dpapi.DeviceInfo{
65                             State: pluginapi.Healthy, Nodes: nodes, NumaNode: numaNode,
66                         })
67 -- 
68 2.30.2
69