Use the memory pool instead of kmalloc
[lttng-modules.git] / instrumentation / syscalls / headers / syscalls_pointers_override.h
index dd6f95448eef0fd8a77f3650a12fd5ed0824b112..d22b18021e029cbac4f383640c89900f96f9041b 100644 (file)
@@ -100,9 +100,8 @@ SC_LTTNG_TRACEPOINT_EVENT(pipe2,
                }                                                                       \
                                                                                        \
                if (inp) {                                                              \
-                       tp_locvar->fds_in = kmalloc(                                    \
-                                       tp_locvar->nr_ulong * sizeof(unsigned long),    \
-                                       GFP_ATOMIC | GFP_NOWAIT);                       \
+                       tp_locvar->fds_in = lttng_tp_mempool_alloc(                             \
+                                       tp_locvar->nr_ulong * sizeof(unsigned long));                   \
                        if (!tp_locvar->fds_in)                                         \
                                goto error;                                             \
                                                                                        \
@@ -113,9 +112,8 @@ SC_LTTNG_TRACEPOINT_EVENT(pipe2,
                                goto error;                                             \
                }                                                                       \
                if (outp) {                                                             \
-                       tp_locvar->fds_out = kmalloc(                                   \
-                                       tp_locvar->nr_ulong * sizeof(unsigned long),    \
-                                       GFP_ATOMIC | GFP_NOWAIT);                       \
+                       tp_locvar->fds_out = lttng_tp_mempool_alloc(                            \
+                                       tp_locvar->nr_ulong * sizeof(unsigned long));   \
                        if (!tp_locvar->fds_out)                                        \
                                goto error;                                             \
                                                                                        \
@@ -126,9 +124,8 @@ SC_LTTNG_TRACEPOINT_EVENT(pipe2,
                                goto error;                                             \
                }                                                                       \
                if (exp) {                                                              \
-                       tp_locvar->fds_ex = kmalloc(                                    \
-                                       tp_locvar->nr_ulong * sizeof(unsigned long),    \
-                                       GFP_ATOMIC | GFP_NOWAIT);                       \
+                       tp_locvar->fds_ex = lttng_tp_mempool_alloc(                             \
+                                       tp_locvar->nr_ulong * sizeof(unsigned long));   \
                        if (!tp_locvar->fds_ex)                                         \
                                goto error;                                             \
                                                                                        \
@@ -221,11 +218,11 @@ end:      ; /* Label at end of compound statement. */                                     \
        )
 
 #define LTTNG_SYSCALL_SELECT_code_post \
-       kfree(tp_locvar->fds_in);       \
-       kfree(tp_locvar->fds_out);      \
-       kfree(tp_locvar->fds_ex);
+       lttng_tp_mempool_free(tp_locvar->fds_in);       \
+       lttng_tp_mempool_free(tp_locvar->fds_out);      \
+       lttng_tp_mempool_free(tp_locvar->fds_ex);
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
 #define OVERRIDE_32_select
 #define OVERRIDE_64_select
 SC_LTTNG_TRACEPOINT_EVENT_CODE(select,
@@ -413,13 +410,11 @@ static struct lttng_type lttng_pollfd_elem = {
        {                                                                               \
                int err;                                                                \
                                                                                        \
-               tp_locvar->fds = kmalloc(tp_locvar->alloc_fds,                          \
-                               GFP_ATOMIC | GFP_NOWAIT);                               \
+               tp_locvar->fds = lttng_tp_mempool_alloc(tp_locvar->alloc_fds);          \
                if (!tp_locvar->fds)                                                    \
                        goto error;                                                     \
                err = lib_ring_buffer_copy_from_user_check_nofault(                     \
-                       tp_locvar->fds, ufds,                                           \
-                       nfds * sizeof(struct pollfd));                                  \
+                       tp_locvar->fds, ufds, tp_locvar->alloc_fds);                    \
                if (err != 0)                                                           \
                        goto error;                                                     \
        }                                                                               \
@@ -495,9 +490,9 @@ end:                                                                                        \
        )
 
 #define LTTNG_SYSCALL_POLL_code_post   \
-       kfree(tp_locvar->fds);
+       lttng_tp_mempool_free(tp_locvar->fds);
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
 #define OVERRIDE_32_poll
 #define OVERRIDE_64_poll
 SC_LTTNG_TRACEPOINT_EVENT_CODE(poll,
@@ -762,9 +757,8 @@ static struct lttng_type lttng_epoll_wait_elem = {
                        tp_locvar->fds_length = ret;                            \
                }                                                               \
                                                                                \
-               tp_locvar->events = kmalloc(                                    \
-                       maxalloc * sizeof(struct epoll_event),                  \
-                       GFP_ATOMIC | GFP_NOWAIT);                               \
+               tp_locvar->events = lttng_tp_mempool_alloc(                             \
+                       maxalloc * sizeof(struct epoll_event));                 \
                if (!tp_locvar->events) {                                       \
                        tp_locvar->fds_length = 0;                              \
                        goto skip_code;                                         \
@@ -772,7 +766,7 @@ static struct lttng_type lttng_epoll_wait_elem = {
                                                                                \
                err = lib_ring_buffer_copy_from_user_check_nofault(             \
                        tp_locvar->events, uevents,                             \
-                       maxevents * sizeof(struct epoll_event));                \
+                       maxalloc * sizeof(struct epoll_event));                 \
                if (err != 0)                                                   \
                        tp_locvar->fds_length = 0;                              \
        }                                                                       \
@@ -806,11 +800,11 @@ static struct lttng_type lttng_epoll_wait_elem = {
 
 #define LTTNG_SYSCALL_EPOLL_WAIT_code_post     \
        sc_out(                                 \
-               kfree(tp_locvar->events);       \
+               lttng_tp_mempool_free(tp_locvar->events);       \
        )
 
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
 #define OVERRIDE_32_epoll_wait
 #define OVERRIDE_64_epoll_wait
 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait,
This page took 0.024702 seconds and 4 git commands to generate.