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 X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A7AC433E2 for ; Fri, 11 Sep 2020 13:33:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E998D22275 for ; Fri, 11 Sep 2020 13:33:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cL1oEi6G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E998D22275 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EE788900002; Fri, 11 Sep 2020 09:33:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBC906B005D; Fri, 11 Sep 2020 09:33:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0F55900002; Fri, 11 Sep 2020 09:33:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id B8E016B005A for ; Fri, 11 Sep 2020 09:33:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 752B2181AEF15 for ; Fri, 11 Sep 2020 13:33:57 +0000 (UTC) X-FDA: 77250873714.22.rock71_010df94270ef Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 498C718038E67 for ; Fri, 11 Sep 2020 13:33:57 +0000 (UTC) X-HE-Tag: rock71_010df94270ef X-Filterd-Recvd-Size: 7109 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 13:33:56 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id u126so9395553oif.13 for ; Fri, 11 Sep 2020 06:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TpsoM88cyk0U9ujavsoiNiP/xNpunXVnqQMw3rUrW70=; b=cL1oEi6GisMpZ+1vyaA1YZmE9+hCJmDs4kjImnwwOvOvKuOrq7EHDUtsuuabzR57Po K0AAX9GUto+YmGqhasb5W+vSlZpIfwGIpXn8/ZobsoDeJAJ/YCW6Jf2ybVuHSXZ02iHQ h6tve/Bzu8Wpl7KaWn7eZFKsYkyrouec6acrsO3QrHhdbgZgDli4Blz30Kn6EMMfCBB6 58ax9jDb2e5Q/SgCE0G1rBCJ/6kVKL7K1KguH/4zVty6MT6Hs8WiLxSXGArkPLwwuURv HHvmieKXwiJoMkOUJQMjpACLQQ0BtYCF8oF3Vir4JYh/XjFSG9+Miqora4bd5lLjf1sX HUkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TpsoM88cyk0U9ujavsoiNiP/xNpunXVnqQMw3rUrW70=; b=Pubjq0N80WUPxQCm2KNg2nSL15XQ/B5HqiSup+6tqmeevs8q9yn/nBKAGtXIaFJSJA Tv2LOIlR43Ur5pb9OJPa7bUt/QJArvdvaVF1kUa1lBltUE6UiyfDsnHX96pZC43S9Lm1 gXzlFa7PT2ZUVhCiYplvXLUGg4QCsJO7LP97hf117PkWSv3BC2LGNmTyuZhPhwSp5mug hLFHUI9OytrueE+vfOBlvk85TyZRymlfO490p5htWdcl3hJ20wKJnZdGJyhKotgkZWi3 Z36/Yp9qMTiBcvMZ5qkfznLw97GG/w8SfOB8hZF+1gfrAt0vyu4GRUGYWEYJjQNi/ZoM HukQ== X-Gm-Message-State: AOAM5314VZFMory4kGzJ9FX8Bq0PIYs9L7MEYF9q7PdCktjuQ8uxPQV7 uroeWvzqH40Lobws+e+QnkuL/kLYuVOR09GKG7VI4A== X-Google-Smtp-Source: ABdhPJzVyxHRpCzzWlwpCs+zsjH4vVQha0aihZX+rNn7CbuvYFeOPOIR3N4j0lJ6yIb7854KZDwveUXgHPVXHY+FMZ4= X-Received: by 2002:aca:54d1:: with SMTP id i200mr1268021oib.172.1599831235876; Fri, 11 Sep 2020 06:33:55 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200908153102.GB61807@elver.google.com> <20200908155631.GC61807@elver.google.com> In-Reply-To: From: Marco Elver Date: Fri, 11 Sep 2020 15:33:44 +0200 Message-ID: Subject: Re: [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector To: Dmitry Vyukov Cc: Vlastimil Babka , Dave Hansen , Alexander Potapenko , Andrew Morton , Catalin Marinas , Christoph Lameter , David Rientjes , Joonsoo Kim , Mark Rutland , Pekka Enberg , "H. Peter Anvin" , "Paul E. McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Dave Hansen , Eric Dumazet , Greg Kroah-Hartman , Ingo Molnar , Jann Horn , Jonathan Corbet , Kees Cook , Peter Zijlstra , Qian Cai , Thomas Gleixner , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 498C718038E67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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, 11 Sep 2020 at 15:10, Dmitry Vyukov wrote: > On Fri, Sep 11, 2020 at 2:03 PM Marco Elver wrote: > > On Fri, 11 Sep 2020 at 09:36, Dmitry Vyukov wrote: [...] > > > By "reasonable" I mean if the pool will last long enough to still > > > sample something after hours/days? Have you tried any experiments with > > > some workload (both short-lived processes and long-lived > > > processes/namespaces) capturing state of the pool? It can make sense > > > to do to better understand dynamics. I suspect that the rate may need > > > to be orders of magnitude lower. > > > > Yes, the current default sample interval is a lower bound, and is also > > a reasonable default for testing. I expect real deployments to use > > much higher sample intervals (lower rate). > > > > So here's some data (with CONFIG_KFENCE_NUM_OBJECTS=1000, so that > > allocated KFENCE objects isn't artificially capped): > > > > -- With a mostly vanilla config + KFENCE (sample interval 100 ms), > > after ~40 min uptime (only boot, then idle) I see ~60 KFENCE objects > > (total allocations >600). Those aren't always the same objects, with > > roughly ~2 allocations/frees per second. > > > > -- Then running sysbench I/O benchmark, KFENCE objects allocated peak > > at 82. During the benchmark, allocations/frees per second are closer > > to 10-15. After the benchmark, the KFENCE objects allocated remain at > > 82, and allocations/frees per second fall back to ~2. > > > > -- For the same system, changing the sample interval to 1 ms (echo 1 > > > /sys/module/kfence/parameters/sample_interval), and re-running the > > benchmark gives me: KFENCE objects allocated peak at exactly 500, with > > ~500 allocations/frees per second. After that, allocated KFENCE > > objects dropped a little to 496, and allocations/frees per second fell > > back to ~2. > > > > -- The long-lived objects are due to caches, and just running 'echo 1 > > > /proc/sys/vm/drop_caches' reduced allocated KFENCE objects back to > > 45. > > Interesting. What type of caches is this? If there is some type of > cache that caches particularly lots of sampled objects, we could > potentially change the cache to release sampled objects eagerly. The 2 major users of KFENCE objects for that workload are 'buffer_head' and 'bio-0'. If we want to deal with those, I guess there are 2 options: 1. More complex, but more precise: make the users of them check is_kfence_address() and release their buffers earlier. 2. Simpler, generic solution: make KFENCE stop return allocations for non-kmalloc_caches memcaches after more than ~90% of the pool is exhausted. This assumes that creators of long-lived objects usually set up their own memcaches. I'm currently inclined to go for (2). Thanks, -- Marco