Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp714460lqp; Fri, 5 Apr 2024 06:53:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3FS1d4993kMJsR9g3wddL4MtWGEO3iVsL9oHdsbSxbEfshDdOnziu8kqx78qBElg0L8gYwtekeInIwlcJKwPFXq/pFOPlUmoHILJ2nQ== X-Google-Smtp-Source: AGHT+IH52FEBcLYMGPw3DQbCC4ga8xk9f97Z7F8f/r0NC06lYNDTyFpndPL4KTo8E974tHwBSSKt X-Received: by 2002:a17:906:37cd:b0:a51:9449:6fa1 with SMTP id o13-20020a17090637cd00b00a5194496fa1mr961016ejc.15.1712325212557; Fri, 05 Apr 2024 06:53:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712325212; cv=pass; d=google.com; s=arc-20160816; b=vfMDn7wZA9FFuZUtGxOQybMTAVYy8qFTJacrQwafOcjMcwaCSSfpnUBnnL6k8dsm4z 3jIr8gR5z8VdNv4aJVO1oyry1X+9hGrfUlqOF0TYMgONl0xDVMs3i6hotBFgWOic/NLv LKwiij9xw0j3viLUddC5/fHt0eLkxcNs5AvZtoVMNgink6WDL19gwrRkDOcHvzlUxXZP Wav8Xyy528KtvD3bi3JOzj9dB03QPQ9ZzoNdQ7qL43YCxqOu9HhRgaxJmSqjUWFJ01/3 JAZ7n3LmpGLWVCdopnS2SupW/sVvyvnDxG0W8tSozEjVSkBUWLcWRSowc7DVa1ocp81k QaIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lAHdE5NFk++ufix28SzhuwWBAI0pKipkj98VJiYe3GU=; fh=7/mr4T+73aumJqXv/dH2JncmLYfYkhLYOOCt3PpMjBk=; b=hte4WpAr4GHarsRKFlT9oZSZqJPuHEK07OxkuO13VOMWhJoTWYL7SEX+4eZah0hZMQ WcIxOlWsXNbvAZ6WzO8NMI8Wl9tMo+9KexgetKkIsrJaolazLJjj0GnAKtvrxB6nrmbs UJFQPFA+TBKhYBxtVpLQcjD/l/H5RGXczq1/v4nwNB0N37yK3Y6PSznMVsPNNFdVqG6W UGp3dD1zB7KzKAdkqlXleL1dNocC0gxlyqCYWlpgQmlJXVZIBpJRWMuf3Y9azw2Qh5im Xv/Fd3Y7olrLGCDrufZ/eiNWLY0CW5dcZZcokHRDSUmlOs82CDlroiBEiaPwdJD5BApH uUjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aYTVf2I+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-3371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3371-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h18-20020a17090619d200b00a4ea02e824fsi723231ejd.366.2024.04.05.06.53.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aYTVf2I+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-3371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3371-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 1AF3F1F22720 for ; Fri, 5 Apr 2024 13:53:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB12B16D9D0; Fri, 5 Apr 2024 13:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aYTVf2I+" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.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 5973116D9B5 for ; Fri, 5 Apr 2024 13:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712325203; cv=none; b=itEBIthWUjcNvJgdJOgaJf7Sj9taIKcIVgKrRv4DSCCVtTgccJ+LOhLAKBgD2WrToehdMcdFnQwUm+RwfgnHttmV+mWoDbXG/foE4KVb4kb4KZZCHoS9zZpnCf7HiwlGBL4u8VQX5Q4NzlvTuK8dU3GhO+XqF/rBJb9S2kOLQ80= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712325203; c=relaxed/simple; bh=0BksyQPOyLKGmYa0FEtepwJD1JDHx0EJaEKX0tpkO58=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ILNjJ+VlLB8IBKPqXxdy3PQKMuWqRYxyrztFyZcGjwLgApzUWdHFVCGTcRcr7E3T/jqTLSK3hHNe+nG/R0c6Z/o1l8DNEniFlda13Yu/vwfRYoxhCkL0f97aIrPyS4eHJFJ70sQqYGpIgqK8z6RjL+lIo4x4UZAX1KC4wLQqvuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aYTVf2I+; arc=none smtp.client-ip=209.85.219.172 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-yb1-f172.google.com with SMTP id 3f1490d57ef6-dbed0710c74so2069225276.1 for ; Fri, 05 Apr 2024 06:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712325200; x=1712930000; 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=lAHdE5NFk++ufix28SzhuwWBAI0pKipkj98VJiYe3GU=; b=aYTVf2I+TyRnSSdH8+I/CVMYO1BJa7hB9/v01eKTU4OrNL9qd16Jg0wQfeflZu4I00 bJzKgnoYGjlF2wFjjjOIkrUvFIjP/gbka8Ca/nK2NNuY96Fo8i0pVlzBoXDg1TkGWJgh e74bm5LQIwxwotdUhDKtFybHE4VYNE/OXkfP4r8mdYC/WVnYYO2zvp0is9rK/LvGlb1u rNp+xyY2kEDgPEpFHmoCvWu4DRKLOea8E3f1pcxL98WGt6zjQX+gyOrqvrhhCb7mBZhQ NliJCHdvq8o1zOgd+ypWl8ttBwBOiemAKjdJsQE5P4duBu286hd2IUmiV+Z3y72bJNxi hYIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712325200; x=1712930000; 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=lAHdE5NFk++ufix28SzhuwWBAI0pKipkj98VJiYe3GU=; b=P8OD68dR4ERCEdkSqB1qVSSKcyXO8dgNJ2tpdPKp/ZnsAQu1ELZT7HZ5hYLkjPv5vK ADChJ97EZGApbqaBUdDmgM6xC04AtPJu+iyRKzyLJsEWCDb8CCZrzylFZWEu6b8SSCwU 2BPnmHW+NC30VBGczpJATY0T6FzlbQUMsGxnYxLBtTyr1NnnIxG+BDTJponJjhOBlTli GFzN+07Ib3l5XSQjXaFHqNvFcEsIV68fr/KcgLiTVF0+Y/Fn0472XaY7Bzn5LPOKtCj9 0AUs77AGk5pyJLIr0t+iTPtI0Px03rZMhmYwN027aAZZAsBGVb+MZ3UMHhqBoQNoGCEk eSyw== X-Forwarded-Encrypted: i=1; AJvYcCWKvytKu+73KZjNmjmlQ/enHAE1b0rn5AiA5VnfcFlKeo5gauDMhyjMZAEfuSVnizwTte9mkEw7A66eKRfg4STaEvDFJjZCEyxKMU3E X-Gm-Message-State: AOJu0YyhjHAWZB5dBgEMEcztmGjnuj617jrUClgekMP/q99FmFd+NmSM 1sNtydofWcN+FLRMlf2gVMOaI04TvJXi6uLdIrrTafsF53FJyK+OT9hdV92LUOAPdAxwqUnjQkL 5fcIDBfIdocQmjJXc2LuLKDU4ZfbSkneKeryw X-Received: by 2002:a25:f454:0:b0:dcd:b624:3e55 with SMTP id p20-20020a25f454000000b00dcdb6243e55mr1115241ybe.54.1712325200128; Fri, 05 Apr 2024 06:53:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240404165404.3805498-1-surenb@google.com> <20240404154150.c25ba3a0b98023c8c1eff3a4@linux-foundation.org> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 5 Apr 2024 06:53:09 -0700 Message-ID: Subject: Re: [PATCH 1/1] mm: change inlined allocation helpers to account at the call site To: Matthew Wilcox Cc: Kent Overstreet , Andrew Morton , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 5, 2024 at 5:44=E2=80=AFAM Matthew Wilcox = wrote: > > 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 wrot= e: > > > > > > 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_ch= ain), > > > > > > 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. vmallo= c > > > > > has done it this way since 2008 (OK, using __builtin_return_addre= ss()) > > > > > and lockdep has used _THIS_IP_ / _RET_IP_ since 2006. > > > > > > > > Except you can't. We've been over this; using that approach for tra= cing > > > > 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 givin= g > > 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. The conceptual difference between codetag and _THIS_IP_/_RET_IP_ is that codetag injects counters at the call site, so you don't need to spend time finding the appropriate counter to operate on during allocation.