Skip to content

Commit

Permalink
prov/util: Statically set uffd callbacks
Browse files Browse the repository at this point in the history
Subscribe, unsubscribe, and valid are callbacks which are dynamically
setup. Change this to be statically set.

Signed-off-by: Ian Ziemba <[email protected]>
  • Loading branch information
iziemba committed Jan 23, 2025
1 parent 6990129 commit 0eedfbb
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions prov/util/src/uffd_mem_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,28 @@

static int ofi_uffd_start(struct ofi_mem_monitor *monitor);
static void ofi_uffd_stop(struct ofi_mem_monitor *monitor);
static int ofi_uffd_subscribe(struct ofi_mem_monitor *monitor,
const void *addr, size_t len,
union ofi_mr_hmem_info *hmem_info);
static bool ofi_uffd_valid(struct ofi_mem_monitor *monitor,
const struct ofi_mr_info *info,
struct ofi_mr_entry *entry);

static struct ofi_uffd uffd = {
.monitor.iface = FI_HMEM_SYSTEM,
.monitor.init = ofi_monitor_init,
.monitor.cleanup = ofi_monitor_cleanup,
.monitor.start = ofi_uffd_start,
.monitor.stop = ofi_uffd_stop,
.monitor.subscribe = ofi_uffd_subscribe,

/* Since UFFD may have many MR cache entries for the same VA range and
* ofi_monitor_unsubscribe() is called for every MR cache entry being
* freed, UFFD unsubscribe needs to be a noop. Else, MR cache entries
* may no longer be monitored.
*/
.monitor.unsubscribe = ofi_monitor_unsubscribe_no_op,
.monitor.valid = ofi_uffd_valid,
.monitor.name = "uffd",
.fd = -1,
.exit_pipe = { -1, -1 },
Expand Down Expand Up @@ -390,16 +405,6 @@ static int ofi_uffd_start(struct ofi_mem_monitor *monitor)
goto close_fd;
}

uffd.monitor.subscribe = ofi_uffd_subscribe;

/* Since UFFD may have many MR cache entries for the same VA range and
* ofi_monitor_unsubscribe() is called for every MR cache entry being
* freed, UFFD unsubscribe needs to be a noop. Else, MR cache entries
* may no longer be monitored.
*/
uffd.monitor.unsubscribe = ofi_monitor_unsubscribe_no_op;
uffd.monitor.valid = ofi_uffd_valid;

FI_INFO(&core_prov, FI_LOG_MR,
"Memory monitor uffd started.\n");

Expand Down Expand Up @@ -456,4 +461,18 @@ static void ofi_uffd_stop(struct ofi_mem_monitor *monitor)
{
}

static int ofi_uffd_subscribe(struct ofi_mem_monitor *monitor,
const void *addr, size_t len,
union ofi_mr_hmem_info *hmem_info)
{
return -FI_ENOSYS;
}

static bool ofi_uffd_valid(struct ofi_mem_monitor *monitor,
const struct ofi_mr_info *info,
struct ofi_mr_entry *entry)
{
return false;
}

#endif /* HAVE_UFFD_MONITOR */

0 comments on commit 0eedfbb

Please sign in to comment.