From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E76D5C433EF for ; Wed, 13 Jul 2022 09:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235188AbiGMJ2u (ORCPT ); Wed, 13 Jul 2022 05:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235422AbiGMJ2n (ORCPT ); Wed, 13 Jul 2022 05:28:43 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B7515FE9 for ; Wed, 13 Jul 2022 02:28:41 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-2ef5380669cso106187187b3.9 for ; Wed, 13 Jul 2022 02:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YLa+B7g0k4vjWxV/5/J/yQw4cNuAt3dnRpzqWxr+dBM=; b=WCXPC3m3TqqYyHJ+uDfaD+33LK+kR0QTRuUNWFbQ/yiL1aUJNetddXLM+3nxPGejsh Ls/9+uJ8DBwyNtwZzS2bmCqOgmd64HDETf5lolZIerFBDUMyM10UXHSgqJRlGnaP6+Sr 7WQw0xRdGLsRdqbYhZtYiXHgC+f9Xsu3UhqrEzWn4Z1/CSbfHNbd8LkOBe5qRW4ixNbs KyQ5sqcw9dz3EgF4DFFiG0BAHXiangGWZsG4iVmPViGONkbOq3wcpVyCIXBH+7zZmcO/ M08jelPQe0TpKZi1+GOuZgf4DLn4ormxvV2r8Qjs/MYHhlBjn3biZ9auY1KBNWeaQ5Ps V8wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YLa+B7g0k4vjWxV/5/J/yQw4cNuAt3dnRpzqWxr+dBM=; b=Qt3ZLVygtFkcWbCVAKxgWsP9URk70VvxQkghKxqCUvva0+wce4aX/IYW0Wr5HFsco3 vdXnHHiiRJugxgNWnHLFvQqEQNklaFWGSmBvgrOoNkxQvqZUEqH2Y8JEE28k58FcNLT7 JQTsVevciyYQ+g9OiqZo0PMLVvWEV9jmnxWhDdC4SGPjCdvQko7eb2OrglaRrSSy0bcE yLyUWiekIWaO/b54oGc18VvvuM2p3YzVabpU+/UAPL0cwODdeTRN1YFziMEcR1IShMNw Kke6dmWj/oMKen1G1z7pMmA3IwIOIEI0yY02K/08Hkd7qpA0OOmBPz9cIgfqE7toWCW3 rcqA== X-Gm-Message-State: AJIora+JrqoB0jf0nRT/havm2XAuajJkYbaQP2Rpjt5eakCPfOJgtew8 3uDj9wU0tU5AeRk7zxOsxxnFCZJtb39x+9emKCzNhA== X-Google-Smtp-Source: AGRyM1uhGuFtib7Qkw+eg+f4MeHVwIDAHRzhZCC99tpjAc0xrKFlrRMHg2i9KL2/AC4ul/k3MxgtlGExoxaQBzv8w5I= X-Received: by 2002:a81:5dd5:0:b0:31d:c5ac:e3c0 with SMTP id r204-20020a815dd5000000b0031dc5ace3c0mr667093ywb.264.1657704520206; Wed, 13 Jul 2022 02:28:40 -0700 (PDT) MIME-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> <20220701142310.2188015-20-glider@google.com> In-Reply-To: <20220701142310.2188015-20-glider@google.com> From: Marco Elver Date: Wed, 13 Jul 2022 11:28:04 +0200 Message-ID: Subject: Re: [PATCH v4 19/45] kmsan: unpoison @tlb in arch_tlb_gather_mmu() To: Alexander Potapenko Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Jul 2022 at 16:24, Alexander Potapenko wrote: > > This is a hack to reduce stackdepot pressure. Will it cause false negatives or other issues? If not, I'd just call it an optimization and not a hack. > 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 Acked-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 > #include > #include > +#include > #include > #include > #include > @@ -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.0.rc0.161.g10f37bed90-goog >