Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cxl list -u can't handle device serial numbers #227

Open
sscargal opened this issue Dec 3, 2022 · 2 comments
Open

cxl list -u can't handle device serial numbers #227

sscargal opened this issue Dec 3, 2022 · 2 comments

Comments

@sscargal
Copy link

sscargal commented Dec 3, 2022

When I list the memdev information, I see a serial number:

# cxl list -vvv -m mem0
[
  {
    "memdev":"mem0",
    "pmem_size":0,
    "ram_size":68719476736,
    [...snip...]
    "serial":9947034306373222400,  <<<<<<<<<<<<
    "numa_node":0,
    "host":"0000:38:00.0",
    "state":"disabled",
    "partition_info":{
      "total_size":68719476736,
      "volatile_only_size":68719476736,
      "persistent_only_size":0,
      "partition_alignment_size":0
    }
  }
]

However, when the -u (Human Readable) option is provided, this causes an out-of-range condition, so the serial number becomes bogus:

# cxl list -vvv -m mem0 -u
{
  "memdev":"mem0",
  "pmem_size":0,
  "ram_size":"64.00 GiB (68.72 GB)",
  [...snip...]
  "serial":"0x7fffffffffffffff",  <<<<<<<<<<<<
  "numa_node":0,
  "host":"0000:38:00.0",
  "state":"disabled",
  "partition_info":{
    "total_size":"64.00 GiB (68.72 GB)",
    "volatile_only_size":"64.00 GiB (68.72 GB)",
    "persistent_only_size":0,
    "partition_alignment_size":0
  }
}

The device reports a serial number of:

# lspci -s 0000:38:00.0 -vvv | grep -i serial
	Capabilities: [148 v1] Device Serial Number 8a-0a-f7-00-00-00-00-00

Converting the integer value returns the correct serial number:

(9947034306373222400)Base10 = (8A0AF70000000000)Base16

Maintaining a hex value for the serial number should resolve this. Converting it to decimal, then to human readable, has no use and makes mapping/identifying devices harder.

@djbw
Copy link
Member

djbw commented Dec 3, 2022

I wonder if this patch fixes it:
patch.txt

...i.e. that the problem arises from mixing int64 and uint64 json-c APIs. Otherwise it's likely too late to create that ABI breakage for the machine readable version of the serial number.

@sscargal
Copy link
Author

Sorry for the delayed response. The patch does fix the issue with -u. Thank you.

# ./cxl list -vvv -m mem0
[
  {
    "memdev":"mem0",
    "pmem_size":0,
    "ram_size":68719476736,
    [...snip...]
    "serial":9947034306373222400,
    "numa_node":0,
    "host":"0000:38:00.0",
    "state":"disabled",
    "partition_info":{
      "total_size":68719476736,
      "volatile_only_size":68719476736,
      "persistent_only_size":0,
      "partition_alignment_size":0
    }
  }
]

The serial number now displays correctly with the -u option

# ./cxl list -vvv -m mem0 -u
{
  "memdev":"mem0",
  "pmem_size":0,
  "ram_size":"64.00 GiB (68.72 GB)",
  [...snip...]
  "serial":"0x8a0af70000000000",   <<<<<< Correct
  "numa_node":0,
  "host":"0000:38:00.0",
  "state":"disabled",
  "partition_info":{
    "total_size":"64.00 GiB (68.72 GB)",
    "volatile_only_size":"64.00 GiB (68.72 GB)",
    "persistent_only_size":0,
    "partition_alignment_size":0
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants