Repository: kubernetes
Issue: cpumanager:staticpolicy:smtalign: pod admission failed after kubelet restart
Labels: kind/bug,sig/node,triage/accepted

### What happened?

When Kubelet is configured with `static` CPUManager policy + `full-pcpus-only` option, after kubelet restart, pod is not get admitted and  I'm getting the following error under kubelet logs:

```
Dec 04 12:42:25 kubenswrapper[2410667]: I1204 12:42:25.173086 2410667 kubelet.go:2320] "Pod admission denied" podUID="4355ee04-54b0-4755-b23e-d05ce12e54c1" pod="my-app-namespace/app-deployment" reason="SMTAlignmentError" message="SMT Alignment Error: not enough free physical CPUs: available physical CPUs = 1, requested CPUs = 2, CPUs per core = 1"
```

After manually deleting and recreating the pod, it gets admitted, so the claim that there are node enough free physical CPUs is wrong.


Pod spec:

```yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2024-12-04T12:50:20Z"
  name: app-deployment
  namespace: my-app-namespace
  resourceVersion: "11109192"
  uid: 16737fd6-45e1-4371-b10e-3eff1377c224
spec:
  containers:
  - args:
    - while true; do sleep 10000; done;
    command:
    - /bin/sh
    - -c
    image: quay.io/jitesoft/alpine
    imagePullPolicy: Always
    name: app-container2
    resources:
      limits:
        cpu: "2"
        memory: 100Mi
      requests:
        cpu: "2"
        memory: 100Mi
  qosClass: Guaranteed

```

### What did you expect to happen?

After kubelet restart pod should readmitted 

### How can we reproduce it (as minimally and precisely as possible)?
On a node with 4 CPUs:
 `1` reserved (`reserverSystemCPUs`)
 `3` allocatable

1. Configure CPUManager to `static` and `full-pcpus-only` option to `true`
2. Create a Guaranteed QoS class pod requesting 2  exclusive CPUs:
``` yaml
kind: Pod
...
spec:
  containers:
...
    resources:
      limits:
        cpu: "2"
        memory: 100Mi
      requests:
        cpu: "2"
        memory: 100Mi
```
3. wait for pod to start
4. restart kubelet
5. Pod will failed with SMTAlignment error

NOTE:
It's possible to reproduce the issue on a system with any size of CPUs.
A general formula would be:
On a node with `N` CPUs:
 `1` reserved 
 `N-1` allocatable
Create a Guaranteed QoS class pod requesting `N / 2`  exclusive CPUs:

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: v1.29.7
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.31.2
WARNING: version difference between client (1.29) and server (1.31) exceeds the supported minor version skew of +/-1

```

</details>


### Cloud provider

<details>

</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>