lkml.org 
[lkml]   [2022]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v5 19/44] kmsan: unpoison @tlb in arch_tlb_gather_mmu()
    From
    This is an optimization to reduce stackdepot pressure.

    struct mmu_gather contains 7 1-bit fields packed into a 32-bit unsigned
    int value. The remaining 25 bits remain uninitialized and are never used,
    but KMSAN updates the origin for them in zap_pXX_range() in mm/memory.c,
    thus creating very long origin chains. This is technically correct, but
    consumes too much memory.

    Unpoisoning the whole structure will prevent creating such chains.

    Signed-off-by: Alexander Potapenko <glider@google.com>
    Acked-by: Marco Elver <elver@google.com>

    ---
    v5:
    -- updated description as suggested by Marco Elver

    Link: https://linux-review.googlesource.com/id/I76abee411b8323acfdbc29bc3a60dca8cff2de77
    ---
    mm/mmu_gather.c | 10 ++++++++++
    1 file changed, 10 insertions(+)

    diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c
    index a71924bd38c0d..add4244e5790d 100644
    --- a/mm/mmu_gather.c
    +++ b/mm/mmu_gather.c
    @@ -1,6 +1,7 @@
    #include <linux/gfp.h>
    #include <linux/highmem.h>
    #include <linux/kernel.h>
    +#include <linux/kmsan-checks.h>
    #include <linux/mmdebug.h>
    #include <linux/mm_types.h>
    #include <linux/mm_inline.h>
    @@ -265,6 +266,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
    static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
    bool fullmm)
    {
    + /*
    + * struct mmu_gather contains 7 1-bit fields packed into a 32-bit
    + * unsigned int value. The remaining 25 bits remain uninitialized
    + * and are never used, but KMSAN updates the origin for them in
    + * zap_pXX_range() in mm/memory.c, thus creating very long origin
    + * chains. This is technically correct, but consumes too much memory.
    + * Unpoisoning the whole structure will prevent creating such chains.
    + */
    + kmsan_unpoison_memory(tlb, sizeof(*tlb));
    tlb->mm = mm;
    tlb->fullmm = fullmm;

    --
    2.37.2.672.g94769d06f0-goog
    \
     
     \ /
      Last update: 2022-08-26 17:13    [W:4.203 / U:0.932 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site