Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp347438lqp; Thu, 4 Apr 2024 15:29:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeHRzhfvod8aM4Wu6bk9G+gXrdcjJhsjguWjfI4pVtdoZ3SD9qsvDB5Zzn7P+F2yRus6G8CnrhqFk/ARiG6giSurunAJ98pVVnZ65FhQ== X-Google-Smtp-Source: AGHT+IF11akLXHMoxDh7UHMpxde0Sz3iaAcS1s54pIShTiS6m7WR+Rm4EI+x2+nu51qSgSzu3lV5 X-Received: by 2002:a17:906:40d7:b0:a4e:9cb0:b644 with SMTP id a23-20020a17090640d700b00a4e9cb0b644mr674617ejk.13.1712269749538; Thu, 04 Apr 2024 15:29:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712269749; cv=pass; d=google.com; s=arc-20160816; b=D0ddoz3kVGDbiO4Rvx3DuR+cWyWN5n1D873vCz9LEWJ6AhOEC4//8h5MA+scrkiqV2 b25PMq4bZsfod5aK7hTd1G2K8TsyfW64apz6HC+EkHsOBM4RR0KxDMCgDDNWyjNPa1tF nNthCJTJK3w9O0yh7c0UAheYXNDYK+w+347GTn4n4TB32G0lc5CS1q3PaEKPO4PK+Wq9 kycTxVC66Zys3g0eg2mncspDJdhMKXrQF4R2cTWR45ssOsHsy7iZYhAv3O2X6I3pIRSt Q89GOsMmUty3rSF19hyV1ixJIcNMuR6Ou3tbXppLcWL9d7I/EEaV7cH48Ri+4aFmuBXm VDQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature:date; bh=cfxyCzvtzmWi1KSrX/XZIalfQOEPT3xbF6m5fU6kp1Y=; fh=OZ2Xn972IvVGF32+E77ZO+JeTM1dtwjDyfuCJMfG2Lk=; b=aOp1OuFnCpuhiFu9UByVybeZ+NX0tOQE/1F0xd7+XAU0w+mHO76thaTe+qmBOlLhjx E9faaEd5y7SRrBz65ePJyMz5ag8kUom9iRJebmi7fHTdY2tlVyqm3JCz7Qsx3F641Eur Cb6wI0b9LUuO4K5+JZoakhb+ZP043S1ur0kD3iVGk02lQ9P+wbFGbfx2fNfdYKHsRJ1f 2n1keO/GZUCo0hQwzL8CmJn4JDPMPIHe8DwRt1VSJ7M9m7B182VmG1POV7Mx7Ql3ADC3 4p396RLdwlPK3qbj7s4vLr/sn7NIPiH1L/CHpxjUko5hilGQgN4u5PcbBq4ygbDyPFN9 E9uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MRSqA7hR; 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-ext4+bounces-1872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1872-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qk12-20020a170906d9cc00b00a46b291e5d7si70398ejb.904.2024.04.04.15.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 15:29:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1872-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=@linux.dev header.s=key1 header.b=MRSqA7hR; 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-ext4+bounces-1872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1872-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 192B31F2384D for ; Thu, 4 Apr 2024 22:29:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED37013C677; Thu, 4 Apr 2024 22:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MRSqA7hR" X-Original-To: linux-ext4@vger.kernel.org Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 3DCA513C3E3; Thu, 4 Apr 2024 22:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712269734; cv=none; b=hANRIifNB+HXylYHuvET0X97q9/GQHeui2+Eyp2nbvGbCjyRmSCIOZZJATaZKxIl/iyMfcTHMy8YbVs3xMmUqkrPQ2BCpsaa8JiQKLPGc9Mx/5ot5effze349o9vKHAQIzjS+fO4F3Vo3cMcM017IaD5vxs4W7mM/gfgptkLT30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712269734; c=relaxed/simple; bh=RxUgTHy6Q08KN0jBS41CMT9Ci5RsJ+C8p9GGt3Gfp6o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Mh1BbqtBN2L8XTewRgd7Ph4tuUeSTYKLrZVt+dlUUInGYTmtkm2VJLg0AjD19+bpma3ONgEitDbYW8d6gCRE5SMV2c5ElHw/RImYrmE7gxFmbflAJRB56tiTlNFA44g4J3kp2BYAJGvQdVeeTecLXQNZHIrSmt3Dk/KfiuMq6XY= 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=MRSqA7hR; arc=none smtp.client-ip=91.218.175.189 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 18:28:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712269730; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cfxyCzvtzmWi1KSrX/XZIalfQOEPT3xbF6m5fU6kp1Y=; b=MRSqA7hRXbZz0tmIJVXahqUTpqENt47k4TugvBcfJSyR0Cm1gh2WA4N6yRjmSx7aVgCNTP AtxKikLCy/Cnvx95nkww4y4oLedWDdmjqq1jSIM2X6aubg8cqXD8PoPTacuEpfuX2MFiLW VByPFt5v8rdJJuUvwqP0pi7SRB4TFpA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Suren Baghdasaryan Cc: Matthew Wilcox , akpm@linux-foundation.org, 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> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Thu, Apr 04, 2024 at 03:17:43PM -0700, Suren Baghdasaryan wrote: > On Thu, Apr 4, 2024 at 10:08 AM Suren Baghdasaryan wrote: > > > > On Thu, Apr 4, 2024 at 10:04 AM Matthew Wilcox wrote: > > > > > > On Thu, Apr 04, 2024 at 09:54:04AM -0700, Suren Baghdasaryan wrote: > > > > +++ b/include/linux/dma-fence-chain.h > > > > @@ -86,10 +86,7 @@ dma_fence_chain_contained(struct dma_fence *fence) > > > > * > > > > * Returns a new struct dma_fence_chain object or NULL on failure. > > > > */ > > > > -static inline struct dma_fence_chain *dma_fence_chain_alloc(void) > > > > -{ > > > > - return kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); > > > > -}; > > > > +#define dma_fence_chain_alloc() kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL) > > > > > > You've removed some typesafety here. Before, if I wrote: > > > > > > struct page *page = dma_fence_chain_alloc(); > > > > > > the compiler would warn me that I've done something stupid. Now it > > > can't tell. Suggest perhaps: > > > > > > #define dma_fence_chain_alloc() \ > > > (struct dma_fence_chain *)kmalloc(sizeof(struct dma_fence_chain), \ > > > GFP_KERNEL) > > > > > > but maybe there's a better way of doing that. There are a few other > > > occurrences of the same problem in this monster patch. > > > > Got your point. > > 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)? Correct, it's not hiding bugs in this case, it's adding type safety. checkpatch is definitely not authoritative, you really have to use your own judgement with it