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 9B430FA3740 for ; Thu, 27 Oct 2022 20:49:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EA896B0071; Thu, 27 Oct 2022 16:49:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09B1A6B0073; Thu, 27 Oct 2022 16:49:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4DF6B0074; Thu, 27 Oct 2022 16:49:33 -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 D7E0F6B0071 for ; Thu, 27 Oct 2022 16:49:33 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BB2E81A12BE for ; Thu, 27 Oct 2022 20:49:33 +0000 (UTC) X-FDA: 80067920226.14.6375583 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) by imf21.hostedemail.com (Postfix) with ESMTP id 7C4041C0009 for ; Thu, 27 Oct 2022 20:49:33 +0000 (UTC) Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-13b103a3e5dso3889563fac.2 for ; Thu, 27 Oct 2022 13:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6gMhKdjIcVkb7+wRScD/tsvQKFhD8+gTEKVp7SkZezo=; b=lGZ+sBWRnyP5BGvyPx980rEGmYXua8iPzcBs7NJCcTrsuEavACBGAq7SxHpre+xhwB NztLWDYEDq2GIRAASFC4OzKhYSDVZIQceLIwTUidhX3y5jHv7eBdgwRG3cLS27JibyaF i3nQ9qUnJd2zw0o/XaAd8L3zXzCSt6gEGNM/viJs9e82PrBPppfcHOshS7GHVmy44Thq yXRdl9iIA9s86i4oCt2g/CiI9F2+8Wn0TmbxPcev6YNu8Bf1oVOAWX+1IYrPaZIcGFGT XjR/4CsQlemlAjvu6L8SD4v/MRCDVMUFIMIAgik7/8k92VO9lejaZiiz0+5utiVfPZMP LISg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6gMhKdjIcVkb7+wRScD/tsvQKFhD8+gTEKVp7SkZezo=; b=aMw+PDjJleNIF+ERvVpJ/AfcjGUFxyLwxpYklzieLJZNP7Y2rmrWom/lSIGYGcWVDg eLktK+X0BR61in1SWIy8t4r5qY9pB2SvcuZSiEkGEK1R9OmjGihQwyHTsV53CpoMiO6a HxoeFhuELjAa00xmYJP+F1nMcRhbckCYdF8gC5Z02ZQmg9dAPQNcvZVZmJIf23Zdqgbo qQWANZN1/EwCnez3cxAdCb6nzj3pMgzbmjRnglosN15E4KxxeFKbmsVs4b6qLWhcbQJZ 6fxKqbEPRmHgqcNl8+QoWvFTVtEehD8ofu2a8I3D09XUVq29jZRaEo25RKSDwJyp7TKL yjKg== X-Gm-Message-State: ACrzQf2CJD7HVPCmYlym4vKNxa+1NVx+VhqKohNyPq+VA1CCSYS6c03F yMqjO6dfDa06uePtOGmICSzmguxyBIgLtrPgaA8= X-Google-Smtp-Source: AMsMyM5edfi5XwySLJEj0tekv6YB1g1njior10MpJLQfO4dBgONxmY9fPrcnsyP1WHmdzHFdW9n+uRQ3Dlm2hUmjLsM= X-Received: by 2002:a05:6870:c182:b0:12a:e54e:c6e8 with SMTP id h2-20020a056870c18200b0012ae54ec6e8mr6661840oad.207.1666903772503; Thu, 27 Oct 2022 13:49:32 -0700 (PDT) MIME-Version: 1.0 References: <20221027134433.61c0d75246cc68455ea6dfd2@linux-foundation.org> In-Reply-To: <20221027134433.61c0d75246cc68455ea6dfd2@linux-foundation.org> From: Andrey Konovalov Date: Thu, 27 Oct 2022 22:49:21 +0200 Message-ID: Subject: Re: [PATCH] kasan: allow sampling page_alloc allocations for HW_TAGS To: Andrew Morton Cc: andrey.konovalov@linux.dev, Marco Elver , 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666903773; a=rsa-sha256; cv=none; b=Ih7Ubd9+iFDo6EeS9dMSqYbtKR3dSjK9gMiHF5Lp0j/yvbgKhctIFUo4jeV7IdrYvwj87z S4YmwEUG3j/5xKm09W7DnzsMwk/vndk+e4BLCJXrCu7lWhHPEUjlnOFZyB/JG63LSeA0K+ S5m+kCnbzyjsENiR/5tEX7fXEWxflu0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lGZ+sBWR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.160.47 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666903773; 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=6gMhKdjIcVkb7+wRScD/tsvQKFhD8+gTEKVp7SkZezo=; b=ZZQNqTkh3QAlX0qkciDOOsPG2FQ9WjVbLGLSuIOTPaigb7UkiXkecEUkg3wbOgNTOS0tpJ vka7FekS0LAS3Hm9lCRfiS5wc+fhTnQ3nI3yfH61XPQGykk3kjv1p6lqoOALSevcsjyTAq uV+ZfPwfu3nzliHOTb8dBgRPLOoFWU8= X-Stat-Signature: r9178nijucedxewhkh17px8pbq4cjqta X-Rspamd-Queue-Id: 7C4041C0009 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lGZ+sBWR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.160.47 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com X-Rspamd-Server: rspam09 X-HE-Tag: 1666903773-666697 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, Oct 27, 2022 at 10:44 PM Andrew Morton wrote: > > 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? Hi Andrew, I will add explanations for all these points in v2. Thank you!