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 D2185CD1292 for ; Thu, 4 Apr 2024 22:28:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64F136B0083; Thu, 4 Apr 2024 18:28:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D72A6B009C; Thu, 4 Apr 2024 18:28:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 478546B009F; Thu, 4 Apr 2024 18:28:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 290696B009C for ; Thu, 4 Apr 2024 18:28:55 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AF0AD80EEF for ; Thu, 4 Apr 2024 22:28:54 +0000 (UTC) X-FDA: 81973290588.18.6BA90CE Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) by imf18.hostedemail.com (Postfix) with ESMTP id AD2811C000D for ; Thu, 4 Apr 2024 22:28:52 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MRSqA7hR; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf18.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712269733; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cfxyCzvtzmWi1KSrX/XZIalfQOEPT3xbF6m5fU6kp1Y=; b=UfypUT5r3SqUCCZcSfRaKEyXbrVYuYKutO6EFJseCElGv93Ha9HQGLaumtXtWXAOtK8TY5 m9jbCYCn5DjooK0UpNYk4kKEec1PlNzC3cSHVHNJS/N8XoJo5H898CbFHHHtkpy2krgeY8 ilRJocoOvtdpTmHhZZq1vHBeHp23kbw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MRSqA7hR; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf18.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712269733; a=rsa-sha256; cv=none; b=niROydfEvbc1EjiShJv6GKLXTMDOu8tmwzvr6hJKfMMWPBaDZViAOypD9ekq5L2+6RcUtj Wk08DVxW7svbBTQ7/4SJy+uQMcDuuOp+nzf9HCbFMfSOOFOdjlMTvWhFW2h8zJZjfN8yKD Y11v7BOUk6q8WYso9WNVqDSE23GfxKQ= 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> 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 X-Rspamd-Queue-Id: AD2811C000D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zxcrnuij9sr6w5fmfr74be3zrkz4kfug X-HE-Tag: 1712269732-462280 X-HE-Meta: U2FsdGVkX19RUjJMEAoRXAO97vKrQglTdJ+xEbYLiO/kueegITHXePvjaqw3gDUivdqoZziCUXADfE4U0f+FNzdHAUDJql1vNE5OuZDZble1ZizjXmFx/3vQyTm97rKJDtJ3IR9meoOhG93VECuGhrcRgFwFSLhgWhGtn71M2wlkSO3V9s7kKQhEJFqh0wFEXJ5P4EpyqbMyeQAowjhIqpFlED52RDUnZfWGVs3r4oYKj10jzdqgXicM1ykJls4yh2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kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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