Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp360053lqp; Thu, 4 Apr 2024 16:01:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOMC9ZpaAj/4XHrZCYzi7XNzEX2utQCczfJ2flc9JXlw8gfdZ3Oe+2B5OAaN7jdXGlsexmNuzB27VcA/rPj2pZi4x6SALgrETK5fN3cA== X-Google-Smtp-Source: AGHT+IFSwtfmHKKiV7t1+J8qwOkrVkHqbtOJ+nZC3uT7USq4NxzKMJbi2zjPIY8ElrAfxuP13CyS X-Received: by 2002:a05:6214:5084:b0:696:a22a:2c25 with SMTP id kk4-20020a056214508400b00696a22a2c25mr4309437qvb.0.1712271667502; Thu, 04 Apr 2024 16:01:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712271667; cv=pass; d=google.com; s=arc-20160816; b=trpdcicGjKw0+L/1C2kqStlwcjiSpiJovHzD9/Z8w/1F9TIvx21VwMMjBjoNfbF2jv yWDphIB8+JdQ1JMPyeSOZQ3amS98YEaecg37PORNG1tLOYLTQhrMcH9yIgl8mctL12b8 nI+nFddvuVmLsrvOGwrG6+iI6kbKCE9gq+B+oxJLEGso2HrZe/Otc4MuDCQBleyoScXy f01InCoBO1dNqqza67FUNzEJmQoTLZdCXOH2TzDwJUPBRIPnqE+gOs4jtyY7YxX2MsHa 0p85CZnwlfOJF+YDbKb0GjWQcxy6jonjv90erybBLLPd+WyVtrtF5eUJuAWwvb1H7vjz ixSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=KHLNB8rkpoKwDhM7NRf7iWUfLDgvBLjzklimu7mkdKs=; fh=FUyDD/NItxp1uF+zzv1IhWGFjyratOfhbzIpG/p5Cbs=; b=FSj/eGdEq0VugsjgiTPUCuxQecdsxkA8Iw62cdNmYr8E0J0irqU1edvCXOuKDWHiav Kn7Nyd+TfSyR+F0U3uJvzxQDZf55LNpmfULdE7Z50T+JE+cqllIWSIcf1hIcPMiOj6pI Yo7v1BPVxKTmXjximmWn0zM+m7rth8QQ1A0Q3VM9E1hJBD6znFGB7r8wKH/6R7a9yKLs SCA84+O7tFxTTyMpA7SrLGnv/Z8ItlNBbX6fP2nnmbTNviKvKvblY8fyRTbZnZ46doNS BdVa5HbNKM2P16Q3mJFxRN4IfrOM0QtG1JxMIrS40d+6iHx8CV0d17tvIJmiM0OFwVal iwQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RjT1djYl; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-nfs+bounces-2654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jo23-20020a056214501700b006993dd372d8si413401qvb.459.2024.04.04.16.01.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RjT1djYl; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-nfs+bounces-2654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6BD4D1C20DE6 for ; Thu, 4 Apr 2024 23:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 415E913BC0A; Thu, 4 Apr 2024 23:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RjT1djYl" X-Original-To: linux-nfs@vger.kernel.org Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39DE1130AE1 for ; Thu, 4 Apr 2024 23:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712271663; cv=none; b=HeiFf1xlc8JI6CMiMS3M1MntACkBfQohO1Q904LD0MXQ2iKDRxRGGoIE3M5qc2oLPLsdSJ6wtk+C1xWUFA6iUlV4lGi49ZmxfvhmHP+FNVSSONykwZhDrwKn+UdlWHj6/FigEKiM/R4ehcwmm9DTu+edvpGWVwRBv62Z40zU0p4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712271663; c=relaxed/simple; bh=7HXE5M3oO4PodeStVnSZa8DXP/cTOPjYZEumGvFvNpA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fiNhUZCHB7mEe7PSVvkGgaUVJ5PVg/u75rOz6gag/kV6gyQ8T+0nrxg1/vy3e00d1W/OwFFMgX7tLzGu9Y16YvUNaymtuk10T9DcitCWf5j4hq++fGJQTIq4VogpVosNlLuaP4Ynhp9DczXDoMZfntK2alrHZTYLZco60Wbyoew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RjT1djYl; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Thu, 4 Apr 2024 19:00:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712271659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KHLNB8rkpoKwDhM7NRf7iWUfLDgvBLjzklimu7mkdKs=; b=RjT1djYlTZqBwHogqp4zy40F3SqAdaK+3oWOfGDaM6L3NSOO4dCastLQfuNaOlT1Dgo7Wv i9k29lxad1FbeHT3aK6BLtfd8jnI/QWfQOgpcP7kCCmnpZ6YfJaUcPMAV7nzKK1Ptjb3Iu +YlbAoFGlEHtL49GVJGZLcl1jqHQD6A= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Andrew Morton Cc: Matthew Wilcox , 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> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240404154150.c25ba3a0b98023c8c1eff3a4@linux-foundation.org> X-Migadu-Flow: FLOW_OUT 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. 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. 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. Additionally: the alloc_hooks() macro is for more than this. It's also for more usable fault injection - remember every thread we have where people are begging for every allocation to be __GFP_NOFAIL - "oh, error paths are hard to test, let's just get rid of them" - never mind that actually do have to have error paths - but _per callsite_ selectable fault injection will actually make it practical to test memory error paths. And Kees working on stuff that'll make use of the alloc_hooks() macro for segregating kmem_caches. 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...