Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp627854rwr; Thu, 4 May 2023 07:41:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UnkYHknWWUKbCEe36FD1Pix+yZ670XvDwMBHQC6+v8ObYFG1pHhtHTRDf3ev59G1YPHYZ X-Received: by 2002:a17:90a:8913:b0:24f:13e7:e42a with SMTP id u19-20020a17090a891300b0024f13e7e42amr2351316pjn.28.1683211269743; Thu, 04 May 2023 07:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683211269; cv=none; d=google.com; s=arc-20160816; b=yydkLkgwdOTpaD/J+AvuaRiaegMpTA6HxhFJhImeUVX1uOc7K4JhozhxZjo3iLHVbX QEGYlqhGF38nLh5Ygf+SzCHJYVgRKsynqgDDiUNjd36R7akL50jWerlJHszGM4cD2JzY 1A9Tgwl/koXRAOVTHLzD8e+6hpYCOKEC0NO41Y7RBpSVT57vjTy7ZZ06FoJ68xsqUpHC cFhjkDDqgg5fObWTIgYm+g/qNGAVjvfvdwghqCTPg6RZ9e7YUWy9vbIbwW6DsPxA9brE SJsrGOrYhsJdA9fIQZt2TVi4h2RXkmQumQrTufhLNz9E8e7su29beG4QEgT4wKUomCYb eDfA== 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=JS6msPuToyJynO3sTVIKpHDiqUqJNNgVeQDo4ExI+FY=; b=FgP6eqwx84f64XY09JJ+dv17FntqR7w6W1LG9MsM/NWWKG5YNBPsvM0Fncac7R5NhE aki/yeY5sZogeAOEFQIE8GGgOZvJQLIUznafFrBXcagkrrvNlIR37HVtxVG0LEh7cVvn xXRbbizE+t7XWtJl/jn+fYm7GMAuNwlc548Komna+2/t2Igg6ypOZjUZDKTztGYhd0wa y2QLCPCqntvOVtcWGPDbob+JqpeNMYKLs7qhdDHX+bdDb6MM8MhSjE/FSLxPZu5rMhXc gLv+S+jXjeY8bp7uUXX+CWlPoxCmHCt2r8ZVWZAJI+kG/96zsviP/vuzhnZvMKI62Gxo QOjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=B5odhRz5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a170902ec8e00b001a97f458716si27780397plg.618.2023.05.04.07.40.55; Thu, 04 May 2023 07:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=B5odhRz5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbjEDObV (ORCPT + 99 others); Thu, 4 May 2023 10:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbjEDObT (ORCPT ); Thu, 4 May 2023 10:31:19 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 393478A74 for ; Thu, 4 May 2023 07:31:18 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-b9a6ab9ede3so787844276.2 for ; Thu, 04 May 2023 07:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683210677; x=1685802677; 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=JS6msPuToyJynO3sTVIKpHDiqUqJNNgVeQDo4ExI+FY=; b=B5odhRz5pl82Qodj9r2guUYfauBi1/TsFjLxRQqEz3zjcJjd//DMmZjNJKPPi7+nQ5 xuKBZ6j/WQW0W3dcKfsj589Fsc+uJ6BYPO2OLNobtTmF3hvusxOFblAjFzy4VuEOrD27 shVv5j4flGfZP5ZKf0oD9z3I5mcfEgazfAAXF3El44hYhX1ZRJaYFp+RYh8KC456HFZc kSCAd/ObzJ2UJVsrp6Z49s4y6jg7flU32RKu03oDmXNXsZW8yRicseUXEdJ33k/uoDns 3t9BrSAOH3jBGP78RFzGvpDDNA510GhlcIeVQC/3SRIP7nZ/gPC/uJcOwTrT82pyTD6i AF6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683210677; x=1685802677; 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=JS6msPuToyJynO3sTVIKpHDiqUqJNNgVeQDo4ExI+FY=; b=JuNetZdWTt6smDm3BBl6yrLXO8GAOqJML+ucF0rpvzqURomWKukMJyAXIYcMkecCAk Vb/1Ige/SFrpf4au4Xuw0A1U9iDhoiqjg/cSyOvmmvtSslvPQODbpFzhjl4+n7eqKXYE 54UekEe3zlSJeCtkpb5qTL1oHAXIDaq8yYW05LKYAwJ1Ul98L+69VCUU55zI3tBH+rIq pbNfZwDrRevfmCLlaFxKpBDJFS5d618FF9bEWse85Z0aj0uBfT1JbW7EsIMuDVEkyXnX y7u+2NljLQucgtrc9G8VYnF8RNPENvysjH2bkFSyVBPpojAWZG9Gjbneel9891ICWIVt 7B6Q== X-Gm-Message-State: AC+VfDwXTuUXDTex+t/GfhGvgb9Fk6F94bMO6xPXSgQp9j+ERDXTvjA7 TaZX4V8/Pv0aisuAMXCVjECMslU45+NxQj9P5fNYIg== X-Received: by 2002:a25:cec1:0:b0:b99:4ac6:3c75 with SMTP id x184-20020a25cec1000000b00b994ac63c75mr122983ybe.10.1683210677091; Thu, 04 May 2023 07:31:17 -0700 (PDT) MIME-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> <20230501165450.15352-35-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 4 May 2023 07:31:05 -0700 Message-ID: Subject: Re: [PATCH 34/40] lib: code tagging context capture support To: Michal Hocko Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 4, 2023 at 1:04=E2=80=AFAM Michal Hocko wrote= : > > On Wed 03-05-23 08:18:39, Suren Baghdasaryan wrote: > > On Wed, May 3, 2023 at 12:36=E2=80=AFAM Michal Hocko = wrote: > > > > > > On Mon 01-05-23 09:54:44, Suren Baghdasaryan wrote: > > > [...] > > > > +static inline void add_ctx(struct codetag_ctx *ctx, > > > > + struct codetag_with_ctx *ctc) > > > > +{ > > > > + kref_init(&ctx->refcount); > > > > + spin_lock(&ctc->ctx_lock); > > > > + ctx->flags =3D CTC_FLAG_CTX_PTR; > > > > + ctx->ctc =3D ctc; > > > > + list_add_tail(&ctx->node, &ctc->ctx_head); > > > > + spin_unlock(&ctc->ctx_lock); > > > > > > AFAIU every single tracked allocation will get its own codetag_ctx. > > > There is no aggregation per allocation site or anything else. This lo= oks > > > like a scalability and a memory overhead red flag to me. > > > > True. The allocations here would not be limited. We could introduce a > > global limit to the amount of memory that we can use to store contexts > > and maybe reuse the oldest entry (in LRU fashion) when we hit that > > limit? > > Wouldn't it make more sense to aggregate same allocations? Sure pids > get recycled but quite honestly I am not sure that information is all > that interesting. Precisely because of the recycle and short lived > processes reasons. I think there is quite a lot to think about the > detailed context tracking. That would be a nice optimization. I'll need to look into the implementation details. Thanks for the idea. > > > > > > > > +} > > > > + > > > > +static inline void rem_ctx(struct codetag_ctx *ctx, > > > > + void (*free_ctx)(struct kref *refcount)) > > > > +{ > > > > + struct codetag_with_ctx *ctc =3D ctx->ctc; > > > > + > > > > + spin_lock(&ctc->ctx_lock); > > > > > > This could deadlock when allocator is called from the IRQ context. > > > > I see. spin_lock_irqsave() then? > > yes. I have checked that the lock is not held over the all list > traversal which is good but the changelog could be more explicit about > the iterators and lock hold times implications. Ack. Will add more information. > > -- > Michal Hocko > SUSE Labs