Skip to content

Commit 16d42a1

Browse files
committed
mutex_lock_interruptible
1 parent 62c1e58 commit 16d42a1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/dpusm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dpusm_init(void) {
7777

7878
static void __exit
7979
dpusm_exit(void) {
80-
mutex_lock(&dpusm.lock);
80+
while (mutex_lock_interruptible(&dpusm.lock));
8181

8282
const int active = atomic_read(&dpusm.active);
8383
if (unlikely(active)) {

src/provider.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,19 @@ dpusm_provider_register(dpusm_t *dpusm, struct module *module, const dpusm_pf_t
265265
return -EINVAL;
266266
}
267267

268-
mutex_lock(&dpusm->lock);;
268+
while (mutex_lock_interruptible(&dpusm->lock));
269269

270270
dpusm_ph_t **found = find_provider(dpusm, module_name(module));
271271
if (found) {
272272
printk("%s: DPUSM Provider with the name \"%s\" (%p) already exists. %zu providers registered.\n",
273273
__func__, module_name(module), *found, dpusm->count);
274-
mutex_unlock(&dpusm->lock);;
274+
mutex_unlock(&dpusm->lock);
275275
return -EEXIST;
276276
}
277277

278278
dpusm_ph_t *provider = dpusmph_init(module, funcs);
279279
if (!provider) {
280-
mutex_unlock(&dpusm->lock);;
280+
mutex_unlock(&dpusm->lock);
281281
return -ECANCELED;
282282
}
283283

@@ -286,7 +286,7 @@ dpusm_provider_register(dpusm_t *dpusm, struct module *module, const dpusm_pf_t
286286
printk("%s: DPUSM Provider \"%s\" (%p) added. Now %zu providers registered.\n",
287287
__func__, module_name(module), provider, dpusm->count);
288288

289-
mutex_unlock(&dpusm->lock);;
289+
mutex_unlock(&dpusm->lock);
290290

291291
return 0;
292292
}
@@ -320,20 +320,20 @@ dpusm_provider_unregister_handle(dpusm_t *dpusm, dpusm_ph_t **provider) {
320320

321321
int
322322
dpusm_provider_unregister(dpusm_t *dpusm, struct module *module) {
323-
mutex_lock(&dpusm->lock);;
323+
while (mutex_lock_interruptible(&dpusm->lock));
324324

325325
dpusm_ph_t **provider = find_provider(dpusm, module_name(module));
326326
if (!provider) {
327327
printk("%s: Could not find provider with name \"%s\"\n", __func__, module_name(module));
328-
mutex_unlock(&dpusm->lock);;
328+
mutex_unlock(&dpusm->lock);
329329
return DPUSM_ERROR;
330330
}
331331

332332
void *addr = *provider;
333333
const int rc = dpusm_provider_unregister_handle(dpusm, provider);
334334
printk("%s: Unregistered \"%s\" (%p): %d\n", __func__, module_name(module), addr, rc);
335335

336-
mutex_unlock(&dpusm->lock);;
336+
mutex_unlock(&dpusm->lock);
337337
return rc;
338338
}
339339

@@ -345,7 +345,7 @@ dpusm_provider_unregister(dpusm_t *dpusm, struct module *module) {
345345
/* get a provider by name */
346346
dpusm_ph_t **
347347
dpusm_provider_get(dpusm_t *dpusm, const char *name) {
348-
mutex_lock(&dpusm->lock);
348+
while (mutex_lock_interruptible(&dpusm->lock));
349349
dpusm_ph_t **provider = find_provider(dpusm, name);
350350
if (provider) {
351351
struct module *module = (*provider)->module;
@@ -405,7 +405,7 @@ dpusm_provider_put(dpusm_t *dpusm, void *handle) {
405405
}
406406

407407
void dpusm_provider_invalidate(dpusm_t *dpusm, const char *name) {
408-
mutex_lock(&dpusm->lock);;
408+
while (mutex_lock_interruptible(&dpusm->lock));
409409
dpusm_ph_t **provider = find_provider(dpusm, name);
410410
if (provider && *provider) {
411411
(*provider)->funcs = NULL;
@@ -418,5 +418,5 @@ void dpusm_provider_invalidate(dpusm_t *dpusm, const char *name) {
418418
printk("%s: Error: Did not find provider \"%s\"\n",
419419
__func__, name);
420420
}
421-
mutex_unlock(&dpusm->lock);;
421+
mutex_unlock(&dpusm->lock);
422422
}

0 commit comments

Comments
 (0)