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 4BBBDFA3740 for ; Thu, 27 Oct 2022 20:44:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D71666B0073; Thu, 27 Oct 2022 16:44:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D21988E0001; Thu, 27 Oct 2022 16:44:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C11636B0075; Thu, 27 Oct 2022 16:44:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B1BD76B0073 for ; Thu, 27 Oct 2022 16:44:40 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8F47D1A12BE for ; Thu, 27 Oct 2022 20:44:40 +0000 (UTC) X-FDA: 80067907920.24.69EC29D Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id 1C1FF20021 for ; Thu, 27 Oct 2022 20:44:38 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5AF86B827DA; Thu, 27 Oct 2022 20:44:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0051BC4FF0A; Thu, 27 Oct 2022 20:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1666903475; bh=eSie5cxyhFgYqzyXxlt/yaovtCT91qgoQ7QxhgbrCRA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cwgeAse8AScdR/vozj93GckLyLgrV217HBziNU9X3Uavagf8OmVJvdNpRYjIR979v fnLJGoonLANrwPU4fEb5qkH+t/YUNePk9kk0Z+X/FEgOhzr4fbbu1L+fqXjQeaSdjX ZbcDFIrWNEbpTq+AJVXaMoT+xObDtj+dad+lE5BI= Date: Thu, 27 Oct 2022 13:44:33 -0700 From: Andrew Morton To: andrey.konovalov@linux.dev Cc: Marco Elver , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH] kasan: allow sampling page_alloc allocations for HW_TAGS Message-Id: <20221027134433.61c0d75246cc68455ea6dfd2@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666903479; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eX5iswCEFEjamv9gIuEx12HIvGG8RCEeLnd91qn6Njc=; b=35E5QM+QxYsFbsbIh4PfnUel6YwTos0y/vHutKZ8WLvHsDcg3UXBSkKu+4Z6/ZQwzfMxHc NNdQ97qpxrNXSO33wZ5MZqzVLKzjetGk1Z5BctgoDDKYh0lL2wbojNLYhgQ4VAGyf2Nw+E DDRp0G6RMYSVu3bnjZwT+jw9ybOAMUk= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cwgeAse8; dmarc=none; spf=pass (imf03.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666903479; a=rsa-sha256; cv=none; b=ol4vsFdGgtiZShfqi9mtB21Btdp5bWuaklKJ0keoxGh177goT1EisMzN/JBAplhl8zh88N VmIJ74hYJAwjSAELBZi0JdiMqfUcBsL0l6lIR5YbMi9RiX5VQHLw7ynJ7saK5KDcLC4X0o hwBTvb8gkbFBDsVQ1iPcuAG8gA/khKo= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1C1FF20021 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cwgeAse8; dmarc=none; spf=pass (imf03.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 9oekehebwdhbo8acks8gox37iumynpb9 X-Rspam-User: X-HE-Tag: 1666903478-412642 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 Thu, 27 Oct 2022 22:10:09 +0200 andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Add a new boot parameter called kasan.page_alloc.sample, which makes > Hardware Tag-Based KASAN tag only every Nth page_alloc allocation. > > As Hardware Tag-Based KASAN is intended to be used in production, its > performance impact is crucial. As page_alloc allocations tend to be big, > tagging and checking all such allocations introduces a significant > slowdown in some testing scenarios. The new flag allows to alleviate > that slowdown. > > Enabling page_alloc sampling has a downside: KASAN will miss bad accesses > to a page_alloc allocation that has not been tagged. > The Documentation: > --- a/Documentation/dev-tools/kasan.rst > +++ b/Documentation/dev-tools/kasan.rst > @@ -140,6 +140,10 @@ disabling KASAN altogether or controlling its features: > - ``kasan.vmalloc=off`` or ``=on`` disables or enables tagging of vmalloc > allocations (default: ``on``). > > +- ``kasan.page_alloc.sample=`` makes KASAN tag only > + every Nth page_alloc allocation, where N is the value of the parameter > + (default: ``1``). > + explains what this does but not why it does it. Let's tell people that this is here to mitigate the performance overhead. And how is this performance impact observed? The kernel just gets overall slower? If someone gets a KASAN report using this mitigation, should their next step be to set kasan.page_alloc.sample back to 1 and rerun, in order to get a more accurate report before reporting it upstream? I'm thinking "no"? Finally, it would be helpful if the changelog were to give us some sense of the magnitude of the impact with kasan.page_alloc.sample=1. Does the kernel get 3x slower? 50x?