Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1864017rdb; Mon, 9 Oct 2023 05:36:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOTTP5Tu/Y9dov3QMWTX+jOwyeRse30W2nWjSbbPhn2cpam2P4/Bcm+l49RDV4EbXcIh9F X-Received: by 2002:a05:6358:917:b0:14a:e358:f436 with SMTP id r23-20020a056358091700b0014ae358f436mr18286047rwi.1.1696854964156; Mon, 09 Oct 2023 05:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854964; cv=none; d=google.com; s=arc-20160816; b=sxgz6aqy8cNpp9iRjD23qn4ZS1O1asWlXy4+mgPD4tXT5/ZfrvHvxkVIv3tb09Ek7Z ZuJ4ocgFyk1uhdhxnYVkXcLhSX0m5H5nukhdBSglaXpPWjq/ZOtMLVdoYZyBCQ8QrRIx 3J7tVJH/QzpBmASfy4k32OxhLZpdbeUb5gNVf7a66VoSzeMBFg2E872JONmKli408LoM RsDEnP74tbCzPwNdQ9Z+xXmlLyeoUQqWiG8mIOXshUwYwpu2T5D74nn7M8A7HvW7DS9F /tkOFFWdoSSIE7MOvdKqT9cKVBClPqlMkJ8VqpNLuGfD3bNu5zutC8YDfXc7zZokIN4J fqTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=wOKyQdcpzYH1S2DyazYIOAoD7VFJ1kfohupYEjtWCjA=; fh=V/PGgQ38PLjy/jSt8FbdZZv04WrFFf9tmvU0C3LWpo8=; b=FPhc3kw8uphhsR+DbMnUxGqavC+wdws8nOWvnsHGSGu2I6v/8x9UsSCQYPm6j3Prrl 43Hzm4JEfjdDNSbIJrDS//fraoRvF9C91uOb+40QGmoi9TGjguaoET9fxdXx28RJqIeu V2JEEyhhPAcd6AFY4XtsHNKzgWcXtuwbhJ+EGI8FLY/NSsHcUjyiW6cE4kk01xnikof0 9zck1l/kQacGc5l+OGQSeiwhWIkwZUzBBI0tTVVZyejijxrbfwtEqGMS45vUJVjHBQfE yknbUlbJXoOQDRbQDuEM2mUPQR7FUjPUSOYwphsJSkjqIfpUrF3uo0vvr6JJvUN69Zy1 0snw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Vq2buXPK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j10-20020a65558a000000b0057c3103bf15si470886pgs.277.2023.10.09.05.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Vq2buXPK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id C7B41804C636; Mon, 9 Oct 2023 05:36:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376445AbjJIMfp (ORCPT + 99 others); Mon, 9 Oct 2023 08:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346571AbjJIMfn (ORCPT ); Mon, 9 Oct 2023 08:35:43 -0400 Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEAF8F for ; Mon, 9 Oct 2023 05:35:40 -0700 (PDT) Received: by mail-vs1-xe2c.google.com with SMTP id ada2fe7eead31-4527d65354bso1898774137.0 for ; Mon, 09 Oct 2023 05:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696854939; x=1697459739; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wOKyQdcpzYH1S2DyazYIOAoD7VFJ1kfohupYEjtWCjA=; b=Vq2buXPKPs+lTz5qet9MIBDSqx8oLhBQNKhUg3SCYZgF5x0V7hjcYID0zbJW7EADgT dmcgkyfuNm5I5WGA10uvMX1selKUEt6bW2CFPYvpvn7VavYnZTw3VWHpmtqHAYcOds77 /e19jyyn1U+Ct2zsVfCF6jsU3WDlr0HQ2FtmplRKtXkl5Oxc50ODakHt2VMy+611dSMi xUyMlNLKXfDzXoWpGtnm6RVpf/v+DT5qy+m2ud2akIv9XmU9k6xknWYwj3SgiH2k6j2g +ffGxAS0Cx8ppKNDLYmZbonfbEDGDhII10eLX9nIhgWvTKysWvdJpyXGYuTIRXVdw4sC 5xwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696854939; x=1697459739; h=content-transfer-encoding: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=wOKyQdcpzYH1S2DyazYIOAoD7VFJ1kfohupYEjtWCjA=; b=XG+/Joe6fRrzEB5SPiKagxrgD8REQBfAT3YXqlCvd4/0jUo5mhZbLbsY+YrSaH3jrA XmVZq9YSZFpyJCaGaRPeAgogXqIaQGrAFxJmgHbDtMl9ovz/30AjwNO1h272vzN0YaJk FtSe+oBphXjPMPGz+sKDrI3TjcOgsNJ54UQx0fqxXvi7zFyL2XzwiyzJ+AOJDuynEQ6g kZV4116BclWLPgc/h2YJj2R+CT3bUbiRnb6y5nvJQ70BXTtr9ry2yGUhWETndbpFDLvP vQKdYcRt1hM7+5wadq2+PrPxpH4F41tICMeqiPF3z7UedKNULDe91wLBTB4QFPf8Z4k0 kivA== X-Gm-Message-State: AOJu0YyakkSJVGfMKvc+0Cz9Na+NLikdhO/8mQgFMIONMnEe1Sma661F iC9Wke0PzGpSpiHS5Mn51StSsUSLN6B30F+VbO3fAg== X-Received: by 2002:a05:6102:7c2:b0:44e:98d8:c62e with SMTP id y2-20020a05610207c200b0044e98d8c62emr12922722vsg.33.1696854939344; Mon, 09 Oct 2023 05:35:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Mon, 9 Oct 2023 14:35:03 +0200 Message-ID: Subject: Re: [PATCH v2 00/19] stackdepot: allow evicting stack traces To: Andrey Konovalov Cc: Alexander Potapenko , 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 , andrey.konovalov@linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 05:36:01 -0700 (PDT) On Thu, 5 Oct 2023 at 22:36, Andrey Konovalov wrote: > > On Wed, Sep 13, 2023 at 7:14=E2=80=AFPM wrot= e: > > > > From: Andrey Konovalov > > > > Currently, the stack depot grows indefinitely until it reaches its > > capacity. Once that happens, the stack depot stops saving new stack > > traces. > > > > This creates a problem for using the stack depot for in-field testing > > and in production. > > > > For such uses, an ideal stack trace storage should: > > > > 1. Allow saving fresh stack traces on systems with a large uptime while > > limiting the amount of memory used to store the traces; > > 2. Have a low performance impact. > > > > Implementing #1 in the stack depot is impossible with the current > > keep-forever approach. This series targets to address that. Issue #2 is > > left to be addressed in a future series. > > > > This series changes the stack depot implementation to allow evicting > > unneeded stack traces from the stack depot. The users of the stack depo= t > > can do that via new stack_depot_save_flags(STACK_DEPOT_FLAG_GET) and > > stack_depot_put APIs. > > > > Internal changes to the stack depot code include: > > > > 1. Storing stack traces in fixed-frame-sized slots; the slot size is > > controlled via CONFIG_STACKDEPOT_MAX_FRAMES (vs precisely-sized > > slots in the current implementation); > > 2. Keeping available slots in a freelist (vs keeping an offset to the n= ext > > free slot); > > 3. Using a read/write lock for synchronization (vs a lock-free approach > > combined with a spinlock). > > > > This series also integrates the eviction functionality in the tag-based > > KASAN modes. > > > > Despite wasting some space on rounding up the size of each stack record= , > > with CONFIG_STACKDEPOT_MAX_FRAMES=3D32, the tag-based KASAN modes end u= p > > consuming ~5% less memory in stack depot during boot (with the default > > stack ring size of 32k entries). The reason for this is the eviction of > > irrelevant stack traces from the stack depot, which frees up space for > > other stack traces. > > > > For other tools that heavily rely on the stack depot, like Generic KASA= N > > and KMSAN, this change leads to the stack depot capacity being reached > > sooner than before. However, as these tools are mainly used in fuzzing > > scenarios where the kernel is frequently rebooted, this outcome should > > be acceptable. > > > > There is no measurable boot time performance impact of these changes fo= r > > KASAN on x86-64. I haven't done any tests for arm64 modes (the stack > > depot without performance optimizations is not suitable for intended us= e > > of those anyway), but I expect a similar result. Obtaining and copying > > stack trace frames when saving them into stack depot is what takes the > > most time. > > > > This series does not yet provide a way to configure the maximum size of > > the stack depot externally (e.g. via a command-line parameter). This wi= ll > > be added in a separate series, possibly together with the performance > > improvement changes. > > Hi Marco and Alex, > > Could you PTAL at the not-yet-reviewed patches in this series when you > get a chance? There'll be a v3 with a few smaller still-pending fixes, right? I think I looked at it a while back and the rest that I didn't comment on looked fine, just waiting for v3. Feel free to send a v3 by end of week. I'll try to have another look today/tomorrow just in case I missed something, but if there are no more comments please send v3 later in the week.