Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2290458rdf; Mon, 6 Nov 2023 09:41:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4frW6no0xh7MYG99H7R9dVmBcrMG+HhxyQiJpqouFKRWooY3wtajQc/VOyf3JBP1//9yX X-Received: by 2002:a17:903:244d:b0:1cc:4d99:36f2 with SMTP id l13-20020a170903244d00b001cc4d9936f2mr23222675pls.56.1699292516481; Mon, 06 Nov 2023 09:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699292516; cv=none; d=google.com; s=arc-20160816; b=iQxFkTfyuEHp2pqG/vP5oX8jJi5NKUz+fO+D8b6Q3SpukzuqTet8Vm54GWicBA+9no CbqbTI9jLDK7f8+154yzacNu4cUjxCA4qxcULcH55oIvg+lP6N1gME3j4ID2OqHANhVA PVuTYpflSHlP8okOJzv8mtk5rNeG2QlDQ6yfPm/xtSa1dx/7cahIMWNOUvd+Ya1eeUai Hm9Bfiji5fOnX5vyEBTDsxyihBXGOlY7FqSCfs6ymn8gCTZF4JoZV8sr0NzblUU/Om88 D8g5Ncraw78/BH5rla3+/UwuPWEzB2OnfY+FRZvEit7pH7HSydA26XHxlwF98nrx7COU uAaA== 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=PQokn8UoRY8iyQHlIyiff09+YQ846OAlOmMikNVi4QE=; fh=5+L7uDpD4jkJrN4RKVrHhQN237X0qFSnK7EFFw/OBkI=; b=yGbw6NSesc/a7N9OuAcS4Q2WlNxyDO9KVERZXXzjmF8HMN0LJXbhGnKaAQJ1iDOzlI C7WhtBRwO5gCrxO9yQtU16xJ/Rd7TXnRWvv8c8EydwM/f9AoGly5lRBeZFzgOasb1GWJ SCJQmGykNw9IkKeIFp3FXKv8UDHR4Bfl/b/nG2MuX1iJrdLq+zp1XnB6gVwxmAy2b5X9 lf2R9d+F7LgXmVQFyVRRs0q3NZ/l32pSFq8sAhtJyjfbirF7DZBLAMCkVy8C9UqdioDS X1l0tc+QP7ROyKVq14BmCEhJQb/9+uRv55Z4loluOJCw+JXPO6wmvpccWcxFJ2077Jx4 DgTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y7bLdpSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id kp8-20020a170903280800b001c9c108bf6esi8107598plb.387.2023.11.06.09.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 09:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y7bLdpSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9276D8079CAE; Mon, 6 Nov 2023 09:41:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbjKFRln (ORCPT + 99 others); Mon, 6 Nov 2023 12:41:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjKFRlm (ORCPT ); Mon, 6 Nov 2023 12:41:42 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62ABD45 for ; Mon, 6 Nov 2023 09:41:39 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-280200949c3so3493412a91.0 for ; Mon, 06 Nov 2023 09:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699292499; x=1699897299; 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=PQokn8UoRY8iyQHlIyiff09+YQ846OAlOmMikNVi4QE=; b=Y7bLdpSLCiknwdgFuUphflbtEdlKzes3D/gdhBDCajS1EmTA973AmAgYkAMT3IBlBf XW5ovyke3q/513Jh8DAHfR2WqLBlMn1V3tbPSasEZ2dTQ4d+O0weDekxGGrDk108GSdD 2hquGE/kXf1NTi2JiZ+RVwNgRnSqHgzFHA/Ns/wzTj2zTu0ZL9X4LyCkascxV7XvaFXp tIE6YBikgKpaD14V1kyLSYuDnPiU4iDzER9bC05wtKFoKhIp3fEC4ZqazXI/CLMhOZBd iFjNugJKcSmwBCZsDGhrn0dMyyHXmqohA8ZQN3fYD2RYQaaR08QR505QfddXazyDpaMb CgRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699292499; x=1699897299; 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=PQokn8UoRY8iyQHlIyiff09+YQ846OAlOmMikNVi4QE=; b=h2/WlqMc2m/jeL1zBMfwyRZ5cvTWyYqsqhCyoEbPYMvTI0SJD8uSlp+8KlZHsJSq+7 5zbTwQ1cnsYisat0fIjJHa3nhVXc/0SiPpQS1BuAZk+ZVCHXgKMDQR4q+gOmqSsLbjU5 HAD7uJHz/OvTDdPM2NfaXW6lUemGwSPgTwpBvE6fQkXPCcREQAVhM5Ox4fI/O7UcpA6m OoYGQ6bheUy/dZSeK2YTM90gMd3ih4HTxwhVVqah3H3GVOuK7LpyNj0Pf3mioFWAWwjW M1dajWUuL6hU078Fb6znkfiz17/xY9jmhhgyjEF0W0IPXXtn+jVg2Qb7yTf9JYTpdWkA nmCA== X-Gm-Message-State: AOJu0YybTIU/A9JWMWyrAQbQNm+hry0pKUDNZned07MNaoWXDvBSWV9i P3cYGe72uR0UWA0twY1/5bSfnKC6HGcB83WWmsA= X-Received: by 2002:a17:90b:4a50:b0:26d:17da:5e9f with SMTP id lb16-20020a17090b4a5000b0026d17da5e9fmr10375032pjb.1.1699292499209; Mon, 06 Nov 2023 09:41:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Mon, 6 Nov 2023 18:41:28 +0100 Message-ID: Subject: Re: [PATCH v3 00/19] stackdepot: allow evicting stack traces To: Marco Elver , Alexander Potapenko Cc: andrey.konovalov@linux.dev, 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 09:41:53 -0800 (PST) On Fri, Nov 3, 2023 at 10:37=E2=80=AFPM Andrey Konovalov wrote: > > On Tue, Oct 24, 2023 at 3:14=E2=80=AFPM Marco Elver wr= ote: > > > > 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? > > With the current default stack depot slot size of 64 frames, a single > stack trace takes up ~3-4x on average compared to precisely sized > slots (KMSAN is closer to ~4x due to its 3-frame-sized linking > records). > > However, as the tag-based KASAN modes evict old stack traces, the > average total amount of memory used for stack traces is ~0.5 MB (with > the default stack ring size of 32k entries). > > I also have just mailed an eviction implementation for Generic KASAN. > With it, the stack traces take up ~1 MB per 1 GB of RAM while running > syzkaller (stack traces are evicted when they are flushed from > quarantine, and quarantine's size depends on the amount of RAM.) > > The only problem is KMSAN. Based on a discussion with Alexander, it > might not be possible to implement the eviction for it. So I suspect, > with this change, syzbot might run into the capacity WARNING from time > to time. > > The simplest solution would be to bump the maximum size of stack depot > storage to x4 if KMSAN is enabled (to 512 MB from the current 128 MB). > KMSAN requires a significant amount of RAM for shadow anyway. > > Would that be acceptable? > > > 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. > > This shouldn't be hard to implement. > > However, as one of the perf improvements, I'm thinking of saving a > stack trace directly into a stack depot slot (to avoid copying it). > With this, we won't know the stack trace size before it is saved. So > this won't work together with the size classes. On a second thought, saving stack traces directly into a stack depot slot will require taking the write lock, which will badly affect performance, or using some other elaborate locking scheme, which might be an overkill. > > 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. ;-) > > First thing on my TODO list wrt perf improvements :) > > > Acked-by: Marco Elver > > > > The series looks good in its current state. However, see my 2 > > higher-level comments above. > > Thank you!