MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / raw_lock

Method raw_lock

llama.cpp:1097–1117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1095 #endif
1096
1097 bool raw_lock(const void * addr, size_t size) const {
1098 if (!mlock(addr, size)) {
1099 return true;
1100 }
1101
1102 char* errmsg = std::strerror(errno);
1103 bool suggest = (errno == ENOMEM);
1104
1105 // Check if the resource limit is fine after all
1106 struct rlimit lock_limit;
1107 if (suggest && getrlimit(RLIMIT_MEMLOCK, &lock_limit)) {
1108 suggest = false;
1109 }
1110 if (suggest && (lock_limit.rlim_max > lock_limit.rlim_cur + size)) {
1111 suggest = false;
1112 }
1113
1114 fprintf(stderr, "warning: failed to mlock %zu-byte buffer (after previously locking %zu bytes): %s\n%s",
1115 size, this->size, errmsg, suggest ? MLOCK_SUGGESTION : "");
1116 return false;
1117 }
1118
1119 #undef MLOCK_SUGGESTION
1120

Callers

nothing calls this directly

Calls 3

fprintfFunction · 0.85
llama_format_win_errFunction · 0.70
c_strMethod · 0.45

Tested by

no test coverage detected