code: def ioctl(fd, request, argp):
      st = time.perf_counter()
      ret = libc.syscall(
          IOCTL_SYSCALL,
          ctypes.c_int(fd),
          ctypes.c_ulong(request),
          ctypes.c_void_p(argp),
      )
      et = time.perf_counter() - st
      idir, size, itype, nr = (
          (request >> 30),
          (request >> 16) & 0x3FFF,
          (request >> 8) & 0xFF,
          request & 0xFF,
      )
      if nr in nrs and itype == 75:
          # /dev/kfd
          name, stype = nrs[nr]
          s = get_struct(argp, stype)
          print(
              f"{(st-start)*1000:7.2f} ms +{et*1000.:7.2f} ms : {ret:2d} = {name:40s}",
              " ".join(format_struct(s)),
          )
          if name == "AMDKFD_IOC_SVM":
              out = ctypes.cast(
                  s.attrs,
                  ctypes.POINTER(
                      kfd_ioctl.struct_kfd_ioctl_svm_attribute
                  ),
              )
              for i in range(s.nattr):
                  print(
                      f"{i}: {kfd_ioctl.kfd_ioctl_svm_attr_type__enumvalues[out[i].type]:40s}: {out[i].value:#x}"
                  )
      else:
          print(
              "ioctl",
              f"{idir=} {size=} {itype=} {nr=} {fd=} {ret=}",
              os.readlink(f"/proc/self/fd/{fd}") if fd >= 0 else "",
          )
      return ret
  
imports: import ctypes, ctypes.util, struct, platform, pathlib, re, time, os
  from extra.hip_gpu_driver import kfd_ioctl
label_desc: Use image node_id 5 for calling a global function with example usage: ioctl(fd, request, argp) and returns: ret