From: Kris Van Hees Date: Tue, 9 Jun 2015 05:07:54 +0000 (-0400) Subject: dtrace: kernel provides SDT trampoline area on SPARC X-Git-Tag: v4.1.12-111.0.20170907_2225~3^2~3^2~70 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=72cfb617b7d90729114fbdac86ea0e25dea0ea4d;p=users%2Fjedix%2Flinux-maple.git dtrace: kernel provides SDT trampoline area on SPARC 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 Acked-by: Nick Alcock --- diff --git a/dtrace/dtrace_dev.c b/dtrace/dtrace_dev.c index 00885ee548575..0a218d0418bb7 100644 --- a/dtrace/dtrace_dev.c +++ b/dtrace/dtrace_dev.c @@ -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) diff --git a/dtrace/sdt_sparc64.c b/dtrace/sdt_sparc64.c index 915a7874cb209..89319821f8855 100644 --- a/dtrace/sdt_sparc64.c +++ b/dtrace/sdt_sparc64.c @@ -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; }