CMB hotplug

Haibo Wu haibowu at hcdatainc.com
Wed Feb 1 22:12:35 PST 2023


Hi all,

I mapped cmb resource file and wrote data to it. When I unplugged the ssd, I thought that a SIGBUG should be generated but the program was still running. So was this a normal behavior?

kernel version: 5.15.88
OS: centos 7.4

My code like this:
size_t resource_size= 268435456;
size_t remain = resource_size;
size_t offset = 0;
size_t range = 128;
char tmp;
int fd = open("/sys/bus/pci/devices/0000:5e:00.0/resource4_wc", O_RDWR);
void * map_addr = mmap(NULL, resource_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
while (remain > 0) {
  memcpy(map_addr + offset, buf + offset, range);
  memcpy(&tmp, map_addr + offset, 0);
  remain -= range;
  offset += range;
  if (remain == 0) {
    remain = resource_size;
    offset = 0;
}

Thanks,
Haibo



More information about the Linux-nvme mailing list