mem-buf: set memalloc_noreclaim for work queues

For the work queues, set the PF_MEMALLOC flag so that
these processes have access to reserved memory.

Change-Id: I07a4e22296c02bfd344e945e9f6542a74b91137e
Signed-off-by: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>
This commit is contained in:
Sudarshan Rajagopalan 2023-06-09 15:16:24 -07:00
parent d83c70b503
commit a7736b49a7
2 changed files with 10 additions and 1 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/completion.h>
@ -12,6 +12,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sched/mm.h>
#include "mem-buf-msgq.h"
#include "trace-mem-buf.h"
@ -337,8 +338,10 @@ static void mem_buf_process_alloc_resp(struct mem_buf_msgq_desc *desc, void *buf
struct mem_buf_msg_hdr *hdr = buf;
struct mem_buf_alloc_resp *alloc_resp = buf;
struct mem_buf_txn *txn;
unsigned int noreclaim_flag;
mutex_lock(&desc->idr_mutex);
noreclaim_flag = memalloc_noreclaim_save();
txn = idr_find(&desc->txn_idr, hdr->txn_id);
if (!txn) {
pr_err("%s no txn associated with id: %d\n", __func__, hdr->txn_id);
@ -357,6 +360,7 @@ static void mem_buf_process_alloc_resp(struct mem_buf_msgq_desc *desc, void *buf
txn->resp_buf);
complete(&txn->txn_done);
}
memalloc_noreclaim_restore(noreclaim_flag);
mutex_unlock(&desc->idr_mutex);
}

View file

@ -28,6 +28,7 @@
#include <linux/lockdep.h>
#include <linux/log2.h>
#include "qti_virtio_mem.h"
#include <linux/sched/mm.h>
#include <acpi/acpi_numa.h>
@ -2412,6 +2413,7 @@ static void virtio_mem_run_wq(struct work_struct *work)
struct virtio_mem *vm = container_of(work, struct virtio_mem, wq);
uint64_t diff;
int rc;
unsigned int noreclaim_flag;
if (unlikely(vm->in_kdump)) {
dev_warn_once(&vm->vdev->dev,
@ -2425,6 +2427,8 @@ static void virtio_mem_run_wq(struct work_struct *work)
return;
atomic_set(&vm->wq_active, 1);
noreclaim_flag = memalloc_noreclaim_save();
retry:
rc = 0;
@ -2487,6 +2491,7 @@ retry:
}
atomic_set(&vm->wq_active, 0);
memalloc_noreclaim_restore(noreclaim_flag);
}
static enum hrtimer_restart virtio_mem_timer_expired(struct hrtimer *timer)