]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: kernel provides SDT trampoline area on SPARC
authorKris Van Hees <kris.van.hees@oracle.com>
Tue, 9 Jun 2015 05:07:54 +0000 (01:07 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Tue, 21 Jul 2015 06:51:24 +0000 (02:51 -0400)
The allocation of the SDT trampolines was done previously using vmalloc
which may cause the trampolines to be too far away from the code that
they provide a call to dtrace_probe() for, making it impossible to put
a jump to the trampoline in a single instruction at the probe location.
By using module_alloc on SPARC, the trampolines are allocated in the
memory region where modules live, which is by design within the jump
range.

The allocated memory is known to be of sufficient size for trampolines,
yet its actual use is not determined at the kernel level.  It is simply
provided as a chunk of memory in the appropriate range.

Orabug: 21220344

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
dtrace/dtrace_dev.c
dtrace/sdt_sparc64.c

index 00885ee54857546d4552e75c0ad79e36621ce1e4..0a218d0418bb76fdbd6a8bc8e5675f57a94eaf0d 100644 (file)
@@ -1125,14 +1125,12 @@ static struct miscdevice helper_dev = {
 
 static void module_add_pdata(void *dmy, struct module *mp)
 {
-       if (mp->pdata) {
-               pr_warn_once("%s: pdata already assigned for %s\n",
-                            __func__, mp->name);
-               return;
-       }
-
+       dmy = mp->pdata;
        mp->pdata = kmem_cache_alloc(dtrace_pdata_cachep,
                                     GFP_KERNEL | __GFP_ZERO);
+
+       if (dmy)
+               PDATA(mp)->sdt_tab = dmy;
 }
 
 static void module_del_pdata(void *dmy, struct module *mp)
@@ -1140,8 +1138,9 @@ static void module_del_pdata(void *dmy, struct module *mp)
        if (!mp->pdata)
                return;
 
+       dmy = PDATA(mp)->sdt_tab;
        kmem_cache_free(dtrace_pdata_cachep, mp->pdata);
-       mp->pdata = NULL;
+       mp->pdata = dmy;
 }
 
 static void dtrace_module_loading(struct module *mp)
index 915a7874cb20983273d04040e48ab1036a15877f..89319821f88553897e118c52ffcb4bc826f9450b 100644 (file)
@@ -157,18 +157,6 @@ int sdt_provide_module_arch(void *arg, struct module *mp)
                return 1;
        }
 
-       if (PDATA(mp)->sdt_tab == NULL) {
-               PDATA(mp)->sdt_tab = __vmalloc(mp->sdt_probec *
-                                       SDT_TRAMP_SIZE * sizeof(sdt_instr_t),
-                                       GFP_DMA32, PAGE_KERNEL);
-
-               if (PDATA(mp)->sdt_tab == NULL) {
-                       pr_info("%s(): cannot allocate trampolines for %s\n",
-                               __func__, mp->name);
-                       return 0;
-               }
-       }
-
        return 1;
 }