From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5290FC67861 for ; Fri, 5 Apr 2024 12:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79C6D6B0174; Fri, 5 Apr 2024 08:44:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74C6A6B0175; Fri, 5 Apr 2024 08:44:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 613E46B0176; Fri, 5 Apr 2024 08:44:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3CCA66B0174 for ; Fri, 5 Apr 2024 08:44:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EA2BEA0772 for ; Fri, 5 Apr 2024 12:44:35 +0000 (UTC) X-FDA: 81975446910.29.EC88627 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 4F884A001B for ; Fri, 5 Apr 2024 12:44:34 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=u5ed4rhu; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712321074; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eeNIVwqmbnOxALTxtADLGm9TG4sDVgGYt1HYshiYKqc=; b=XjaHwpSz9PE80GqZ2gOTzHkwSe+vd49SbjvymN1ZrDdtNjlrxsoMm/XRy+JBTR91/d8gD2 vPFzuLLAkU4ziooRT/4kAxPuzGrb5v9lYWlgX9ym2f5fyYWHgyFVrpTQ6sVrANQJCM2Fpb Gc0vuOaOpZZRTIK6JVYLgLWpkuwksvg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712321074; a=rsa-sha256; cv=none; b=QpU8ioWlKU2BX7qFXfFr5fw8qU999pfk4xeEErhWJ9D3t5A9g9aJJ+f0BlX5TbrgbX3TF9 WjbltJ2OIbl6savPLsQW+ZVRXIIl1FnkIzptqgb5/Ynkoj28b65MHTj0STYRXH2uY1uJ5R eirfZm6PoiW2qtFy7esw1zJ5p9qAFQY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=u5ed4rhu; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eeNIVwqmbnOxALTxtADLGm9TG4sDVgGYt1HYshiYKqc=; b=u5ed4rhuZriAmkiqPN+PL+siyW LqRb4vlEwDanh3tAUYLOdMIV7AkIlisbY/us6TAVJuto+5fuwLvpi9TPIrnjWbaPPJNccNZW+iz9n CE7C1RkLY5MAKN+mK5a2RxNIgLnodNe3aX7iDp0V7aCmr5P/N6ISdHIVtmL/cESx2/auaAWvOPmPb KuyRV5Y+LQqQCk5pQAdOvh7O24Xw0aWYZroHPNWg+x3RZAuUdwa4MbZzNihetVBFDxn0z1t842ZIz FOV6F7MyMIx1gNWKJJYhVEkf93kF4Zc6qtlbIo+KLHjWxeAtAZV2JO/tPX3rOWtiHHQwKzPY7f2Nl e0gCTrgg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsivU-0000000AUMn-1hDK; Fri, 05 Apr 2024 12:44:12 +0000 Date: Fri, 5 Apr 2024 13:44:12 +0100 From: Matthew Wilcox To: Kent Overstreet Cc: Andrew Morton , Suren Baghdasaryan , joro@8bytes.org, will@kernel.org, trond.myklebust@hammerspace.com, anna@kernel.org, arnd@arndb.de, herbert@gondor.apana.org.au, davem@davemloft.net, jikos@kernel.org, benjamin.tissoires@redhat.com, tytso@mit.edu, jack@suse.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, jakub@cloudflare.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH 1/1] mm: change inlined allocation helpers to account at the call site Message-ID: References: <20240404165404.3805498-1-surenb@google.com> <20240404154150.c25ba3a0b98023c8c1eff3a4@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4F884A001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pku8kgnriookhx7ro8dz9pdabue1uh8e X-HE-Tag: 1712321074-68564 X-HE-Meta: U2FsdGVkX1+bAKc3Fv1Vja3gAcMR0VqO4gqxBpHncsKaZGYVexLdaP2iK4k6wybmBLVY64rgAWg3VMeMRW2+uY/N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z7uRsJ6hpEMux/XFDR5zf/lolRYl3A0PuBenj700qex/nb92Xdk2Zljrhl+xrMqSkChT4hGfGmjKnxq+jwFYtGYq5tXTrnizCwQGPTvc8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Apr 04, 2024 at 07:00:51PM -0400, Kent Overstreet wrote: > On Thu, Apr 04, 2024 at 03:41:50PM -0700, Andrew Morton wrote: > > On Thu, 4 Apr 2024 18:38:39 -0400 Kent Overstreet wrote: > > > > > On Thu, Apr 04, 2024 at 11:33:22PM +0100, Matthew Wilcox wrote: > > > > On Thu, Apr 04, 2024 at 03:17:43PM -0700, Suren Baghdasaryan wrote: > > > > > Ironically, checkpatch generates warnings for these type casts: > > > > > > > > > > WARNING: unnecessary cast may hide bugs, see > > > > > http://c-faq.com/malloc/mallocnocast.html > > > > > #425: FILE: include/linux/dma-fence-chain.h:90: > > > > > + ((struct dma_fence_chain *)kmalloc(sizeof(struct dma_fence_chain), > > > > > GFP_KERNEL)) > > > > > > > > > > I guess I can safely ignore them in this case (since we cast to the > > > > > expected type)? > > > > > > > > I find ignoring checkpatch to be a solid move 99% of the time. > > > > > > > > I really don't like the codetags. This is so much churn, and it could > > > > all be avoided by just passing in _RET_IP_ or _THIS_IP_ depending on > > > > whether we wanted to profile this function or its caller. vmalloc > > > > has done it this way since 2008 (OK, using __builtin_return_address()) > > > > and lockdep has used _THIS_IP_ / _RET_IP_ since 2006. > > > > > > Except you can't. We've been over this; using that approach for tracing > > > is one thing, using it for actual accounting isn't workable. > > > > I missed that. There have been many emails. Please remind us of the > > reasoning here. > > I think it's on the other people claiming 'oh this would be so easy if > you just do it this other way' to put up some code - or at least more > than hot takes. Well, /proc/vmallocinfo exists, and has existed since 2008, so this is slightly more than a "hot take". > But, since you asked - one of the main goals of this patchset was to be > fast enough to run in production, and if you do it by return address > then you've added at minimum a hash table lookup to every allocate and > free; if you do that, running it in production is completely out of the > question. And yet vmalloc doesn't do that. > Besides that - the issues with annotating and tracking the correct > callsite really don't go away, they just shift around a bit. It's true > that the return address approach would be easier initially, but that's > not all we're concerned with; we're concerned with making sure > allocations get accounted to the _correct_ callsite so that we're giving > numbers that you can trust, and by making things less explicit you make > that harder. I'm not convinced that _THIS_IP_ is less precise than a codetag. They do essentially the same thing, except that codetags embed the source location in the file while _THIS_IP_ requires a tool like faddr2line to decode kernel_clone+0xc0/0x430 into a file + line number. > This is all stuff that I've explained before; let's please dial back on > the whining - or I'll just bookmark this for next time... Please stop mischaracterising serious thoughtful criticism as whining. I don't understand what value codetags bring over using _THIS_IP_ and _RET_IP_ and you need to explain that.