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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 864BBC433EF for ; Wed, 13 Jul 2022 09:28:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DF4894011A; Wed, 13 Jul 2022 05:28:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18D4C9400E5; Wed, 13 Jul 2022 05:28:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 060D694011A; Wed, 13 Jul 2022 05:28:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EAAC19400E5 for ; Wed, 13 Jul 2022 05:28:41 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C68E680954 for ; Wed, 13 Jul 2022 09:28:41 +0000 (UTC) X-FDA: 79681551642.12.2435C8A Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by imf22.hostedemail.com (Postfix) with ESMTP id 0C090C006F for ; Wed, 13 Jul 2022 09:28:40 +0000 (UTC) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-31c9b70c382so106457287b3.6 for ; Wed, 13 Jul 2022 02:28:40 -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=EvxMIct2Byu0n/iFdfhRxr/Naxkb5ZzEOsfiBVqEb+4HRvcPGC2ccd4acMuW6u77b3 rM/KBH38aOqjqLXBes7qOZL4gqtxzTEdEV6MzC2VYW3ze0Lti1jlJR52q8u/B1XbfFz3 JviCAz9mqlw1lzytU/rqydtNjFDH5P1BqRwQsEFGkTFEvNf2zvlM+TqHZ+atGTyf5LoR glvVTAnnilYDg92b53nYoy2KRpyCE/k67AmBHJNu0VsExFk9ZDyHJI3f7MRgpHUPMx9Z ZIWhKXZpKIUARzFbPW29ju6s0muQSD8uJ6PIGp4TOfGPjAs3mRRQNbMlxJ0xWNWuqH+w vbhA== X-Gm-Message-State: AJIora+YbLIzHx5lC72h64d0I7sBYBFx3uGt0JjF5X2N43InQGokILgg INLDoB7zBRfQ6MrNFA2+XYlwjo5rYfYM+m9qZB6W7w== 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657704521; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YLa+B7g0k4vjWxV/5/J/yQw4cNuAt3dnRpzqWxr+dBM=; b=Gd3K+vXzWhgW2YhOjPzKJc/ZmE1kGq5EfsEGMIC/xNUSa7G3rd1C0q2XOOWtDRuFK8bz8h zjtbgBF3w3PORD7ekfdQiVj0FoaAyCPwW5PpBiLTvgVHnnffaP3FhqJ1/4JgV8oaRetA+m 1CqR9iHT48eN58t35AlA4dnZZhu6xPg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=WCXPC3m3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of elver@google.com designates 209.85.128.170 as permitted sender) smtp.mailfrom=elver@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657704521; a=rsa-sha256; cv=none; b=SzfyGnJAIqXqn2GBaJNdml0MEfeiureisdCPbRwClDcbhaCQkLOwkibut1cmIjoRB+hhz5 s7QsS/97wreFHksuvO/I8C2BL3kO2hg0Ugkwj2BlS+STPutjWi6cqG1q1VJN3+uqnjT2U+ ZE7/4FH5pFB1Kcvc5tS7F8JHG52OqB8= X-Stat-Signature: pr811n8igsc5567odswr4da9r47upf6s X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0C090C006F Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=WCXPC3m3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of elver@google.com designates 209.85.128.170 as permitted sender) smtp.mailfrom=elver@google.com X-Rspam-User: X-HE-Tag: 1657704520-865406 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >