Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1877881rda; Tue, 24 Oct 2023 06:14:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXjGJP2xr7gSNsyHcInKB/XUrLC3UHARdWwCziBsYy5prHJoc2E3vQeXEY6HH6gg+a9Qsa X-Received: by 2002:a05:6359:5c01:b0:168:cf32:4da8 with SMTP id pu1-20020a0563595c0100b00168cf324da8mr7895801rwb.10.1698153284859; Tue, 24 Oct 2023 06:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153284; cv=none; d=google.com; s=arc-20160816; b=Eaglq1+oiprxdkcSUO2Nm3mVNz6jUpfKNkCtszpQScPqwS4rC+RgJvC/ybXlRwDiBL s94NIJ3JxjwaUmyoYmKXnZ4BiikjmtwPKuJ84doWlkkn5y+4nBBgFqKBIHbm/bkmOPib I5DMgUwBEdZLHwEaMZZUPylF/VMCAQ9kjX7DRrTWX4yh+jfrAt7ykggYKs4jZlKb2IPq xBQdpQkiVOHtU93S0h0V7x8rz/lbcbEevuoyjlfL99qixbwSyLlALwWBvbkzQzSvPCU1 L2ueLilnTDtfiklHcAUvRaRUz0Q9yji+515X5O7/COZL4PQy2wkxwzYZobS7AseiwebJ oInQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nEr9urFwA/XFdZ4nlXaG4cbFnHUMhCkx9szJZ37Mwg4=; fh=3EgVQPQxbxv+XfZ2sWOggyb2K8Rxmj6Eg9mP1jVgo94=; b=Ja4X6YFxLntRsyVIxAv1ZJ5pe5LO/WdIGK5HmDX0f7SaSkYq/fXgpm255nGsMJ/T35 NXrs1Z8MkLqXTQ/E4xE/vYslP2j1sWdG0potDHxcjR52Pydv/s/vFhcRuV/bnMaghf3h Qr+K058LK++s/rsVTgbcMVMA6iJcGsSlNWJjbIbHt27JpGkvrao7rQmo89m4Rnv9R16y UHF+akrOEzRHebXWOnDX31wVj5X278nQmu6vT43QNniOrdLuKxGfeKwrm3LePj/h0pIc TMAO5QoMIZu/xXjCiNq7m56krn6zj0gv5G83fd743oW+BWzDpDNMy92NGbeur7iCS/dz 4SdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=syAtvyUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 131-20020a630089000000b005b8f38f9975si636593pga.751.2023.10.24.06.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=syAtvyUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 78E6580A32C4; Tue, 24 Oct 2023 06:14:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbjJXNOg (ORCPT + 99 others); Tue, 24 Oct 2023 09:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232084AbjJXNOf (ORCPT ); Tue, 24 Oct 2023 09:14:35 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2647ADD for ; Tue, 24 Oct 2023 06:14:33 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3b2ec9a79bdso3223603b6e.3 for ; Tue, 24 Oct 2023 06:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698153272; x=1698758072; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=nEr9urFwA/XFdZ4nlXaG4cbFnHUMhCkx9szJZ37Mwg4=; b=syAtvyUHXKO+N3kn4Ka696c9uX/VUlQgIOPAWUq/T+P9mmwiT1SLLh/JQLL5vm77q9 PbGXVzakdBwplZTTQMEjv7B1y7znXqEXzCTlX/yJPddrE90k+JsEs+9gz6OEz66skNbt c1AQTLD3c2YV3juxm6ZoREJqvwR1PQROdpq/OENHQtF7uUef79wVDKvC/g8+vnm5F5Nk 4KnVBsqdJO1Y+a84pgfSjlgV81WA1ZrRt4C9/kWkrhxG7bwcQvM71vMWEdelsnVCwV9r dywyUmw59bYF51w4T2EMFzG8JhUlR8Irn1YjAujWnHCRojp9ztGhNd+wF6jcToumWNhI 6pxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698153272; x=1698758072; 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=nEr9urFwA/XFdZ4nlXaG4cbFnHUMhCkx9szJZ37Mwg4=; b=hJp5QOdiP/x4qUclylX37FAWAeQOeaovKFRrjBvuTPLQe6ZL6antKf+OY7EbT6220p tiOcurPziy4k/0ugPFTvRYOui8XXSwz+vZIsFYRHle0hVK9Tw9UHlHpEOTWojHejz8NK +LI8/N5mgut0ZwBwKekjj6UKoFTs+XUb1JRTleSGcj9vcmH3ANHkqssOiQ34ZSUoN5qZ srjj1sZOfHGEmz5BcThwbnLbbHkp2ToAHpZAAHDCrKRilaOVHdsswSc9rCsb4jF6Y5JY 0CG+Tx7x/eVBxrUhfBH4AW6W68OeaxEdbdt0Axf2uPRykOE7FYMydUcweaEXkNGZKD7z hfcg== X-Gm-Message-State: AOJu0YwWpcwGqxtDSA9cnqsGxMWHZfT1p5IOkhZGSQfhfUpjqWWBf+Ra 9vHEtzh+d8nTrunh8tSMYL6sJqFH1PFLLq0QCj3jcA== X-Received: by 2002:aca:d12:0:b0:3a7:6ff5:c628 with SMTP id 18-20020aca0d12000000b003a76ff5c628mr13328519oin.11.1698153272314; Tue, 24 Oct 2023 06:14:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Tue, 24 Oct 2023 15:13:54 +0200 Message-ID: Subject: Re: [PATCH v3 00/19] stackdepot: allow evicting stack traces To: andrey.konovalov@linux.dev Cc: Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:14:42 -0700 (PDT) On Mon, 23 Oct 2023 at 18:22, wrote: [...] > --- > > Changes v2->v3: > - Fix null-ptr-deref by using the proper number of entries for > initializing the stack table when alloc_large_system_hash() > auto-calculates the number (see patch #12). > - Keep STACKDEPOT/STACKDEPOT_ALWAYS_INIT Kconfig options not configurable > by users. > - Use lockdep_assert_held_read annotation in depot_fetch_stack. > - WARN_ON invalid flags in stack_depot_save_flags. > - Moved "../slab.h" include in mm/kasan/report_tags.c in the right patch. > - Various comment fixes. > > Changes v1->v2: > - Rework API to stack_depot_save_flags(STACK_DEPOT_FLAG_GET) + > stack_depot_put. > - Add CONFIG_STACKDEPOT_MAX_FRAMES Kconfig option. > - Switch stack depot to using list_head's. > - Assorted minor changes, see the commit message for each path. > > Andrey Konovalov (19): > lib/stackdepot: check disabled flag when fetching > lib/stackdepot: simplify __stack_depot_save > lib/stackdepot: drop valid bit from handles > lib/stackdepot: add depot_fetch_stack helper > lib/stackdepot: use fixed-sized slots for stack records 1. I know fixed-sized slots are need for eviction to work, but have you evaluated if this causes some excessive memory waste now? Or is it negligible? If it turns out to be a problem, one way out would be to partition the freelist into stack size classes; e.g. one for each of stack traces of size 8, 16, 32, 64. > lib/stackdepot: fix and clean-up atomic annotations > lib/stackdepot: rework helpers for depot_alloc_stack > lib/stackdepot: rename next_pool_required to new_pool_required > lib/stackdepot: store next pool pointer in new_pool > lib/stackdepot: store free stack records in a freelist > lib/stackdepot: use read/write lock 2. I still think switching to the percpu_rwsem right away is the right thing, and not actually a downside. I mentioned this before, but you promised a follow-up patch, so I trust that this will happen. ;-) > lib/stackdepot: use list_head for stack record links > kmsan: use stack_depot_save instead of __stack_depot_save > lib/stackdepot, kasan: add flags to __stack_depot_save and rename > lib/stackdepot: add refcount for records > lib/stackdepot: allow users to evict stack traces > kasan: remove atomic accesses to stack ring entries > kasan: check object_size in kasan_complete_mode_report_info > kasan: use stack_depot_put for tag-based modes > > include/linux/stackdepot.h | 59 ++++-- > lib/Kconfig | 10 + > lib/stackdepot.c | 418 ++++++++++++++++++++++++------------- > mm/kasan/common.c | 7 +- > mm/kasan/generic.c | 9 +- > mm/kasan/kasan.h | 2 +- > mm/kasan/report_tags.c | 27 +-- > mm/kasan/tags.c | 24 ++- > mm/kmsan/core.c | 7 +- > 9 files changed, 365 insertions(+), 198 deletions(-) Acked-by: Marco Elver The series looks good in its current state. However, see my 2 higher-level comments above.