Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7630097rdb; Thu, 4 Jan 2024 02:42:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVcOaPiGVvUBW+09G4V2kfQEu5xoTGhdusW7SuKkWnBm96ras9za3jkbagiHpLv3mgapk3 X-Received: by 2002:a50:d7cb:0:b0:553:8989:f8a9 with SMTP id m11-20020a50d7cb000000b005538989f8a9mr164197edj.92.1704364978719; Thu, 04 Jan 2024 02:42:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704364978; cv=none; d=google.com; s=arc-20160816; b=Erep7oFKirNeChU+tiFBtuKdtBp7A0MG163rVGJ9mGSeN9KsVBDEaIlYZCJJsuv8yG adrDjIHeEfd+EATj6T7aocrcGQ2xMooEanYpGsE4FO0Hvu0ZAKERvWXZTUdUgvfJZQtp rgYD4a18IxNRW5O+Dq3ny0U/cuyjRB3czQ96aVaOJFU2WNFf0hCUITZe89X+JkloQGJg 9T7erKd3xWzq2QrvV7Tv4Tbi117JR07EXjrD+PnNhFF2JvOEeD53R7vR/h+OitDDXq5g YFUqeyLJaR0j38eUt8WBo24mKthVvuUIxgETZ/MlVBnjp3S1MVwxb6OjFRojb8NgwU0l gSVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=LolWQ4Jrb+Z7IGxXTLsLvRDIA9OucvvsNX3g5Br+h1s=; fh=AnoIy5yXpmYRAA/ZJLVC0D5vdVMFCXYVFmK8go1Xijw=; b=uSUnPeNRErlR0UkQYcC2h4Ijb+pt57atPAPfxY66bAHagm5OQr9Cc8QVdGGeuK+/uc +B3hRKvaHDvU0Smeu0uueAgr7p6RaP7PNwoJVp5qCbz/lV8xBacyIJJ5voJteUjIS9iv fOkar+MJMztb/rdw5BLT+IAuAhi9thaSiQBcxif7cNGTVUh8zoUvSozGgcNw4yl7yXvy zqDEgl3edRaAbnFItCafXmy/ZeZgVlkQWi5rNVj9PkzLsTyhbBFdkDYck7CXvSRtzsRh Uo317C+ggo8llbtekERwcKPZfXcQ6MYplYE2hpShTElB9/WQCCelWN1OdHVUdN7TU22K 1MHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hW9rsOHq; spf=pass (google.com: domain of linux-kernel+bounces-16518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r14-20020a056402234e00b00552fd4f41b3si13460718eda.44.2024.01.04.02.42.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 02:42:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hW9rsOHq; spf=pass (google.com: domain of linux-kernel+bounces-16518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7A1D21F21FBB for ; Thu, 4 Jan 2024 10:42:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C94320DD9; Thu, 4 Jan 2024 10:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hW9rsOHq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAA8D20DCE for ; Thu, 4 Jan 2024 10:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-4b73e952ef2so87195e0c.2 for ; Thu, 04 Jan 2024 02:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704364970; x=1704969770; 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=LolWQ4Jrb+Z7IGxXTLsLvRDIA9OucvvsNX3g5Br+h1s=; b=hW9rsOHqD3lAiRGYn/qKxn9ZjQOAPvrzJJk1UMLBY1+VOUBS53IWoiBTYePAsskBYj Zk77AA3IEG0tWN5TTE/XVdlDvMdKMAQ1OK16ptifpMefWRFXQ6c3iQejPD53jRN7+6II 0RFPVw+8MTZZEh4oF1lenUcw0Din+iYgpg+cGZ5pkgTQUVJJt6GLjoEQfbZUVubjAkRw PnzVYhYUROfR37axLxWv0+TJ6VolM/eLkdPSPE3W4rgtwi/H8CUa6LbE0E6PHTRkEjvi LDfKNl0YLNENIfsO/zb+rRnRpKT8LuaN9W+gXdNuRwGmHfmn4u5SRjZ1PdCZuJUOBEfs iOxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704364970; x=1704969770; 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=LolWQ4Jrb+Z7IGxXTLsLvRDIA9OucvvsNX3g5Br+h1s=; b=b9RTGxumhGPDcMRNnU9SMH86jb4e6rPPvEnHuS1Ye35khSe320Rn1EXOQYuHVe9zJK FF9277fY2PQmC21VBPhqyRLIDnfwyymQwNDE2tDBhraDxVB/BSTvXGNfZcP3myveE8Pj LymmfR/xis2g4MwElS+GsXxEx9hA7119HX8imJan0Gqas6k2jEHisgkRGdliPlXw40i/ KmLmC4GG3HOGzpPIXaZzV6U11+rTZAcV1t2XM1Vi6zxtCI18nxMvwAZdiAEkt1hoadY0 LBjq6eY9Epm27xVkDxBSaw7nkcUiSMq37+ZmJZRAL9Op3CQRMwwwpa/XWC0KjBUUOkXC 7zTQ== X-Gm-Message-State: AOJu0YzoECIFVDMoI9uLWp0JBulsL7ujZwu6z3Rg0wxvqBrU84O0oVb2 3ZqVueihwvSJo1LkPbtSZN7a8bT4FESQvrhWfuJXpZlPMYoX X-Received: by 2002:a05:6122:3181:b0:4b6:e60e:e080 with SMTP id ch1-20020a056122318100b004b6e60ee080mr162069vkb.30.1704364969684; Thu, 04 Jan 2024 02:42:49 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1d1ad5692ee43d4fc2b3fd9d221331d30b36123f.1700502145.git.andreyknvl@google.com> In-Reply-To: From: Marco Elver Date: Thu, 4 Jan 2024 11:42:11 +0100 Message-ID: Subject: Re: [PATCH v4 17/22] lib/stackdepot: allow users to evict stack traces To: Oscar Salvador Cc: andrey.konovalov@linux.dev, Andrew Morton , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" On Thu, 4 Jan 2024 at 11:18, Oscar Salvador wrote: > > On Thu, Jan 04, 2024 at 10:25:40AM +0100, Marco Elver wrote: > > I think a boolean makes the interface more confusing for everyone > > else. At that point stack_depot_put merely decrements the refcount and > > becomes a wrapper around refcount_dec, right? > > Thanks Marco for the feedback. > > Fair enough. > > > I think you want to expose the stack_record struct anyway for your > > series, so why not simply avoid calling stack_depot_put and decrement > > the refcount with your own helper (there needs to be a new stackdepot > > function to return a stack_record under the pool_rwlock held as > > reader). > > Yeah, that was something I was experimenting with my last version. > See [0], I moved the "stack_record" struct into the header so page_owner > can make sense of it. I guess that's fine right? Not exposing the internals would be better, but at this point I think your usecase looks like it's doing something that is somewhat out of the bounds of the stackdepot API. I also don't see that it makes sense to add more helpers to the stackdepot API to deal with such special cases. As such, I'd reason that it's ok to expose the struct for this special usecase. > If so, I'd do as you mentioned, just decrementing it with my own helper > so no calls to stack_depot_put will be needed. > > Regarding the locking, I yet have to check the patch that implements > the read/write lock, but given that page_owner won't be evicting > anything, do I still have to fiddle with the locks? You need to grab the lock as a reader to fetch the stack_record and return it. All that should be hidden behind whatever function you'll introduce to return the stack_record (stack_depot_find()?). > > Also, you need to ensure noone else calls stack_depot_put on the stack > > traces you want to keep. If there is a risk someone else may call > > stack_depot_put on them, it obviously won't work (I think the only > > option then is to introduce a way to pin stacks). > > Well, since page_owner won't call stack_depot_put, I don't see > how someone else would be able to interfere there, so I think > I am safe there. > > [0] https://patchwork.kernel.org/project/linux-mm/patch/20231120084300.4368-3-osalvador@suse.de/ > > -- > Oscar Salvador > SUSE Labs