Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7967099rdb; Thu, 4 Jan 2024 13:45:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEsuAdKFdIcXqlI+eqI7a2XX8/zBSoE7YmbMelEcRmKrKd/ibafAusNvkFY2K43NYzbDrV X-Received: by 2002:a17:902:eac2:b0:1d4:462a:60bd with SMTP id p2-20020a170902eac200b001d4462a60bdmr1209982pld.55.1704404720971; Thu, 04 Jan 2024 13:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704404720; cv=none; d=google.com; s=arc-20160816; b=LbICkxHIhW4SpVnzCggeTfi+NEsZa25XfT5y5MfwScdLGu6v+mrDjhSGoYD6JQsOme i+Mtgvr6c09vYkbxC84ovVtq4L/8lwq+1yVxta9Vy06sQ2XN53fhrpYUyMejDdjKV9GN 298TD34n3e/xefcTJwH58PWIh1Yzyy5gMdXv2vN7b/ktcXQFpQqfls6BwTF+wpw1ojNw 4ElL0d+vsTyyKSxlaF1O66cyGrO+Fuf/usPcBw+mByEBpd4G6qbeVv1B/vwOl2P8A3di jaGhUaGsxVyHBCajqn43Hjs6BiW7zfz0hTeQ3gcLzRVHadVLJYd8YkwqQtwKkd9Uveic H8SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=67YixbK7ditBELwNuITWzoarFGr4jyX+RjaNFzFyyto=; fh=737rU5uR2cF1HdIrraDhh8lybzNtNGyWWaele3m/Fy4=; b=ROFgUUN6C/IHZg4M7tFf3hVZfFdFcZ1zuJd8Xy5UpkSxpMl/JzrDSVhZgeCqZ1dGow lbljRrjk4vlxaWwciHNGYxEaXQ1OMxj07cfrHHDBJMf4UdZsiQsHoaLgdEkbCQ5WKxbp /fwgmQviaIaQxHUb/QTd6whQ5FjtvV5/fRYi/9oVFbMdTmWOSAsJVFcgyAeaVc2CD8k0 FNHO2D9sDaxWRYPfJAqqAhmsroxr05rMxD4C7SHtLoqCImEpRnOUpPUR3ZDYi132a2gp CxKzV5sj8Mx6FEBgGmJ7zc1iuuO4MS6vPmK2C0nA2Dgnb/Kd45SPaZMsNrQvsNyDjyA4 N+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZxkXNWKV; spf=pass (google.com: domain of linux-kernel+bounces-17251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t16-20020a639550000000b005cd84983a5asi197045pgn.721.2024.01.04.13.45.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:45:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZxkXNWKV; spf=pass (google.com: domain of linux-kernel+bounces-17251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A4CCCB23EE3 for ; Thu, 4 Jan 2024 21:44:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4417A2C862; Thu, 4 Jan 2024 21:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZxkXNWKV" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 677022C6BE; Thu, 4 Jan 2024 21:44:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50D01C433C7; Thu, 4 Jan 2024 21:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704404666; bh=qmkVGkFZ7N/03sFNMtroJyKLYvamcso6OXSxZb6lC8o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZxkXNWKVaf1lvZwh2WEDFAzLx5sRzxdwJSIS6we8WgA/IV/VGdWMA7gKEEbxsZwEk Pam+FQeekr4Xe+b6AcmjAsWHCJupmtYEyiWCl+v9YqWij7Wec0E2afxccf8W81SW7w c73k9L3Lg0D+QKrsn29t7IdYNN5oP6qae6yHBVbWwuAPRreXxhLqrdXE9hXDZOngjH JHEEKvvyc5uqjb3PZDUlDiGUwcLH7tv+PsFoaS9XOWvz5GSfEChjftQ01Qc+eXH97N fV93XcT2xwytJ+hiFWJPIc71q8my7LYNElLbbAL7V2BbPGYbvCM51eVoWUcwkWLYqW 2J7JJjt4/WOHw== Date: Thu, 4 Jan 2024 13:44:24 -0800 From: Jakub Kicinski To: Mina Almasry Cc: Shakeel Butt , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev, "David S. Miller" , Eric Dumazet , Paolo Abeni , Stefan Hajnoczi , Stefano Garzarella , David Howells , Jason Gunthorpe , Christian =?UTF-8?B?S8O2bmln?= , Yunsheng Lin , Willem de Bruijn Subject: Re: [PATCH net-next v3 2/3] net: introduce abstraction for network memory Message-ID: <20240104134424.399fee0a@kernel.org> In-Reply-To: References: <20231220214505.2303297-1-almasrymina@google.com> <20231220214505.2303297-3-almasrymina@google.com> <20231221232343.qogdsoavt7z45dfc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 21 Dec 2023 15:44:22 -0800 Mina Almasry wrote: > The warning is like so: >=20 > ./include/net/page_pool/helpers.h: In function =E2=80=98page_pool_alloc= =E2=80=99: > ./include/linux/stddef.h:8:14: warning: returning =E2=80=98void *=E2=80= =99 from a > function with return type =E2=80=98netmem_ref=E2=80=99 {aka =E2=80=98long= unsigned int=E2=80=99} makes > integer from pointer without a cast [-Wint-conversion] > 8 | #define NULL ((void *)0) > | ^ > ./include/net/page_pool/helpers.h:132:24: note: in expansion of macro > =E2=80=98NULL=E2=80=99 > 132 | return NULL; > | ^~~~ >=20 > And happens in all the code where: >=20 > netmem_ref func() > { > return NULL; > } >=20 > It's fixable by changing the return to `return (netmem_ref NULL);` or > `return 0;`, but I feel like netmem_ref should be some type which > allows a cast from NULL implicitly. Why do you think we should be able to cast NULL implicitly? netmem_ref is a handle, it could possibly be some form of=20 an ID in the future, rather than a pointer. Or have more low bits stolen for specific use cases. unsigned long, and returning 0 as "no handle" makes perfect sense to me. Note that 0 is a special case, bitwise types are allowed to convert to 0/bool and 0 is implicitly allowed to become a bitwise type. This will pass without a warning: typedef unsigned long __bitwise netmem_ref; netmem_ref some_code(netmem_ref ref) { // direct test is fine if (!ref) // 0 "upgrades" without casts return 0; // 1 does not, we need __force return (__force netmem_ref)1 | ref; } The __bitwise annotation will make catching people trying to cast to struct page * trivial. You seem to be trying hard to make struct netmem a thing. Perhaps you have a reason I'm not getting?